From 7d20cd2c353d96d7cb3fada821a4afd0b32b0fe8 Mon Sep 17 00:00:00 2001 From: martbost Date: Fri, 9 Oct 2026 09:16:51 -0500 Subject: [PATCH] Login ad: frame the sponsor's page inside the gate under the timer bar (open-in-tab link, dashboard button), new-tab fallback only when the site refuses framing (Brian Holland: no timer, no way out on the ad tab) Co-Authored-By: Claude Fable 5.1 --- public/assets/my.js | 36 +++++++++++++++++++++++++++++------- public/my.html | 8 +++++--- server.js | 19 ++++++++++++++++++- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/public/assets/my.js b/public/assets/my.js index 72b556d..603d21c 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -2994,11 +2994,12 @@ if (r.account) fillLineBanner(r.account); })); - // ── login ad interstitial (ClickBaitPays pattern): after a successful - // sign-in the sponsor card appears; "Open Ad" opens the CTA link in a NEW - // tab (a real, counted click) while the timer counts down on THIS page — - // deliberately not paused, the member is expected to be in the ad tab. - // At zero, "Go to dashboard" appears. + // ── login ad interstitial: after a successful sign-in the sponsor card + // appears; "Open Ad" loads the sponsor's page INSIDE the gate, under our bar + // (countdown, open-in-new-tab, dashboard button), so the timer and the way + // out sit on the ad itself (Brian Holland, 2026-10-09: "no timer, no X"). + // Sites that refuse framing open in a new tab instead, with the bar saying + // so; the timer is not paused, the member is expected to be on the ad. async function showLoginAd() { try { const { ad } = await (await fetch('/api/ads/slot?type=login')).json(); @@ -3007,19 +3008,38 @@ const openBtn = $('lgOpen'); const goBtn = $('lgContinue'); const timer = $('lgTimer'); + const frame = $('lgFrame'); + const tab = $('lgOpenTab'); + const body = gate.querySelector('.lgate-body'); + const framed = !!(ad.frameable && frame); $('lgCreative').innerHTML = ad.imageUrl ? 'sponsor ad' : '' + (ad.title ? String(ad.title).replace(/[&<>]/g, '') : 'Visit today\'s sponsor') + ''; $('lgStatus').textContent = 'Login ad sponsor — click "Open Ad" to begin.'; + const how = $('lgHow'); + if (how) how.textContent = framed + ? 'The sponsor\'s page opens right here under this bar. The timer counts down at the top; when it hits zero, your dashboard button appears beside it.' + : 'This sponsor\'s site does not allow loading inside a frame, so it opens in a new tab. The timer counts down here; come back to this tab when it hits zero for your dashboard button.'; timer.hidden = true; goBtn.hidden = true; + if (tab) tab.hidden = true; + if (frame) { frame.hidden = true; frame.src = 'about:blank'; } + if (body) body.hidden = false; openBtn.disabled = false; gate.hidden = false; await new Promise(done => { openBtn.onclick = () => { - window.open(ad.targetUrl, '_blank'); // the click relay counts it openBtn.disabled = true; - $('lgStatus').textContent = 'Ad open in a new tab. View it and come back — the timer runs here.'; + if (framed) { + frame.src = ad.targetUrl; // the click relay counts it, then redirects inside the frame + frame.hidden = false; + if (body) body.hidden = true; + if (tab) { tab.href = ad.siteUrl || ad.targetUrl; tab.hidden = false; } + $('lgStatus').textContent = 'Today\'s sponsor. Have a look; your dashboard button appears when the timer ends.'; + } else { + window.open(ad.targetUrl, '_blank'); // the click relay counts it + $('lgStatus').textContent = 'The sponsor opened in a new tab (that site does not allow framing). View it and come back; the timer runs here.'; + } let left = ad.dwell || 10; timer.hidden = false; timer.textContent = 'Time remaining: ' + left + 's'; @@ -3036,6 +3056,8 @@ }; }); gate.hidden = true; + if (frame) { frame.src = 'about:blank'; frame.hidden = true; } + if (body) body.hidden = false; $('lgTimer').classList.remove('done'); } catch (e) {} } diff --git a/public/my.html b/public/my.html index 8267bc5..c1b2295 100644 --- a/public/my.html +++ b/public/my.html @@ -66,15 +66,17 @@ InstantAdPay Login ad sponsor — click "Open Ad" to begin. + +

Today's login sponsor

-

The ad opens in a new tab. The timer counts down right here — - when it hits zero, your dashboard button appears above.

+

The sponsor's page opens right here under this bar. The timer counts down at the top; + when it hits zero, your dashboard button appears beside it.

Why you are seeing this again: to keep resources optimised we do not keep anyone signed in for longer than 4 hours. After that your session ends and you re-authenticate here. @@ -1149,7 +1151,7 @@ - + diff --git a/server.js b/server.js index 0cce070..5e3d414 100644 --- a/server.js +++ b/server.js @@ -457,6 +457,16 @@ function headUrl(url) { req.on('error', reject); req.on('timeout', () => req.destroy(new Error('timeout'))); req.end(); }); } +// login-ad gate: can this sponsor's page load inside our frame? Cached 6 h per campaign + url; an answer that +// takes longer than 4 s counts as "no" for this sign-in (new-tab fallback) while the check finishes for the cache. +const loginFrameCache = new Map(); +async function loginFrameable(id, url) { + const key = id + '|' + url, hit = loginFrameCache.get(key); + if (hit && Date.now() - hit.ts < 6 * 3600 * 1000) return hit.ok; + if (!url) return false; + const check = frameCheck(url).then(r => { loginFrameCache.set(key, { ok: !!r.ok, ts: Date.now() }); return !!r.ok; }).catch(() => false); + return Promise.race([check, new Promise(r => setTimeout(() => r(false), 4000))]); +} async function frameCheck(url) { const h = await frameFetch(url, 0); if (h.error) return { ok: false, reason: 'We checked your URL and ' + h.error + '. Fix the URL and try again.' }; @@ -4005,7 +4015,14 @@ const server = http.createServer(async (req, res) => { const ad = await ads.serve(t, Object.assign({ width: Number(u.searchParams.get('w')) || 0, height: Number(u.searchParams.get('h')) || 0 }, viewerGeo(req))); // login ads: the member clicks "Open Ad" (a real, counted click into a // new tab) while the countdown runs on our interstitial page - if (ad && t === 'login') ad.dwell = ads.rates().loginDwellSeconds || 10; + if (ad && t === 'login') { + ad.dwell = ads.rates().loginDwellSeconds || 10; + // 2026-10-09: the gate frames the sponsor's page under our bar (timer + way out visible on the ad itself). + // Login campaigns were never frame-checked, so check here, once per campaign, and fall back to a new tab. + const site = await ads.targetOf(ad.id); + ad.siteUrl = site; + ad.frameable = await loginFrameable(ad.id, site); + } return json(res, 200, { ad }); } m = /^\/api\/ads\/click\/(\d+)$/.exec(p);