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
+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.');