Dwell timers no longer stall on phones: a focused ad frame or a touch device counts as an active tab (Brian Holland 2026-10-09: no timer, no close on the welcome tour and verified ads on mobile)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-09 08:44:27 -05:00
parent 75339757e5
commit f53bd67d30
4 changed files with 9 additions and 5 deletions
+4 -2
View File
@@ -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(); }
+3 -1
View File
@@ -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.');
+1 -1
View File
@@ -1149,7 +1149,7 @@
<script src="/assets/common.js?v=20261007a"></script><script src="/assets/welcome.js?v=20260923b"></script>
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261007ra"></script>
<script src="/assets/my.js?v=20261009a"></script>
<script src="/assets/my.js?v=20261009b"></script>
<script src="/assets/chat.js?v=20260907l"></script>
</body>
</html>
+1 -1
View File
@@ -46,6 +46,6 @@
</div>
<iframe class="vframe" id="vFrame" sandbox="allow-scripts allow-same-origin allow-forms allow-popups" referrerpolicy="no-referrer" title="Advertiser site"></iframe>
</div>
<script src="/assets/view.js?v=20260919a"></script>
<script src="/assets/view.js?v=20261009a"></script>
</body>
</html>