pa help mga sir pano po kaya to
gusto ko kasi pag open ng new tab then in closed ni user agad ung tab gusto na dedetect kaso kahit naka open pa ung tab sinasabi nya na naka closed agad ung tab
function openTaskInNewTab(url, taskToken) {
let newWindow = window.open(url, '_blank');
if (newWindow) {
// Check if the new tab or window is opened
setTimeout(() => {
let timer = setInterval(() => {
if (newWindow.closed) {
clearInterval(timer);
Swal.fire({
icon: 'error',
title: 'Task Not Completed',
text: 'Make sure to complete the task for the reward.',
});
}
}, 500);
// Automatically reward user after a set duration
setTimeout(() => {
clearInterval(timer);
if (!newWindow.closed) {
rewardUser(taskToken);
}
}, 5000);
}, 1000);
} else {
// Notify user if popups are blocked
Swal.fire({
icon: 'warning',
title: 'Popup Blocked',
text: 'Please allow popups for this site to receive rewards.',
});
}
}
gusto ko kasi pag open ng new tab then in closed ni user agad ung tab gusto na dedetect kaso kahit naka open pa ung tab sinasabi nya na naka closed agad ung tab
function openTaskInNewTab(url, taskToken) {
let newWindow = window.open(url, '_blank');
if (newWindow) {
// Check if the new tab or window is opened
setTimeout(() => {
let timer = setInterval(() => {
if (newWindow.closed) {
clearInterval(timer);
Swal.fire({
icon: 'error',
title: 'Task Not Completed',
text: 'Make sure to complete the task for the reward.',
});
}
}, 500);
// Automatically reward user after a set duration
setTimeout(() => {
clearInterval(timer);
if (!newWindow.closed) {
rewardUser(taskToken);
}
}, 5000);
}, 1000);
} else {
// Notify user if popups are blocked
Swal.fire({
icon: 'warning',
title: 'Popup Blocked',
text: 'Please allow popups for this site to receive rewards.',
});
}
}
patry ako ahhh