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 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-09 09:16:51 -05:00
parent efb6020e40
commit 7d20cd2c35
3 changed files with 52 additions and 11 deletions
+29 -7
View File
@@ -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
? '<img src="' + ad.imageUrl + '" alt="sponsor ad">'
: '<span class="lg-linkcard">' + (ad.title ? String(ad.title).replace(/[&<>]/g, '') : 'Visit today\'s sponsor') + '</span>';
$('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) {}
}