diff --git a/public/assets/my.js b/public/assets/my.js
index fb96554..72b556d 100644
--- a/public/assets/my.js
+++ b/public/assets/my.js
@@ -3,6 +3,8 @@
(async function () {
// back-office shell: no marketing nav here; rehearsal notice lives in the top bar
const $ = IAP.$;
+ // dwell timers pause when the tab is away; a focused ad frame or a touch device counts as active (phones never report hasFocus reliably)
+ const tabActive = () => document.visibilityState === 'visible' && (document.hasFocus() || !!(document.activeElement && document.activeElement.tagName === 'IFRAME') || (window.matchMedia && window.matchMedia('(pointer: coarse)').matches));
try {
const c = await IAP.getConfig();
if (c.rehearsal && $('boRehearsal')) {
@@ -2281,7 +2283,7 @@
refresh();
// countdown pauses off-tab; the server separately enforces the dwell on its own clock
ibTimer = setInterval(() => {
- if (document.visibilityState !== 'visible' || !document.hasFocus()) return;
+ if (!tabActive()) return;
left -= 1;
if (left > 0) { refresh(); return; }
clearInterval(ibTimer);
@@ -2849,7 +2851,7 @@
$('ggTimer').textContent = left + 's';
await new Promise(done => {
const t = setInterval(() => {
- if (document.visibilityState !== 'visible' || !document.hasFocus()) return;
+ if (!tabActive()) return;
left -= 1;
$('ggTimer').textContent = Math.max(0, left) + 's';
if (left <= 0) { clearInterval(t); done(); }
diff --git a/public/assets/view.js b/public/assets/view.js
index a348861..f184140 100644
--- a/public/assets/view.js
+++ b/public/assets/view.js
@@ -7,6 +7,8 @@
const token = location.pathname.split('/').pop();
const framed = window.self !== window.top; // shown inside the dashboard's in-page ad overlay
let left = 5, timer = null, credited = false, asking = false;
+ // 'active' = visible and (focused, or the ad frame itself holds focus, or a touch device where hasFocus() is unreliable)
+ const tabActive = () => document.visibilityState === 'visible' && (document.hasFocus() || !!(document.activeElement && document.activeElement.tagName === 'IFRAME') || (window.matchMedia && window.matchMedia('(pointer: coarse)').matches));
const setMsg = t => { $('vMsg').textContent = t; };
async function j(url, body) {
const r = await fetch(url, body
@@ -18,7 +20,7 @@
if (credited || asking) return;
// In the in-page overlay the iframe often doesn't hold focus even though it's
// fully on screen, so gate on tab visibility only when framed.
- if (document.visibilityState !== 'visible' || (!framed && !document.hasFocus())) {
+ if (document.visibilityState !== 'visible' || (!framed && !tabActive())) {
$('vTimer').classList.add('paused');
$('vTimer').textContent = 'paused';
setMsg(framed ? 'Keep this ad on screen to finish the countdown.' : 'Come back to this tab to keep the countdown moving.');
diff --git a/public/my.html b/public/my.html
index e5cdc5d..8267bc5 100644
--- a/public/my.html
+++ b/public/my.html
@@ -1149,7 +1149,7 @@
-
+