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:
+29
-7
@@ -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) {}
|
||||
}
|
||||
|
||||
+5
-3
@@ -66,15 +66,17 @@
|
||||
<span class="lg-brand">Instant<em>AdPay</em></span>
|
||||
<span class="lgate-note small muted" id="lgStatus">Login ad sponsor — click "Open Ad" to begin.</span>
|
||||
<span class="lg-timer mono" id="lgTimer" hidden>…</span>
|
||||
<a class="btn small sec" id="lgOpenTab" target="_blank" rel="noopener" hidden title="Signing up is easier in a full tab">Open site in a new tab ↗</a>
|
||||
<button class="btn small" id="lgContinue" type="button" hidden>Go to dashboard</button>
|
||||
</div>
|
||||
<iframe class="lgate-frame" id="lgFrame" hidden sandbox="allow-scripts allow-same-origin allow-forms allow-popups" referrerpolicy="no-referrer" title="Sponsor site"></iframe>
|
||||
<div class="lgate-body">
|
||||
<div class="lgate-card">
|
||||
<p class="eyebrow">Today's login sponsor</p>
|
||||
<div id="lgCreative"></div>
|
||||
<p style="margin-top:18px"><button class="btn" id="lgOpen" type="button">Open Ad</button></p>
|
||||
<p class="small muted">The ad opens in a new tab. The timer counts down right here —
|
||||
when it hits zero, your dashboard button appears above.</p>
|
||||
<p class="small muted" id="lgHow">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.</p>
|
||||
<p class="small muted" style="margin-top:10px;opacity:.85">Why you are seeing this again:
|
||||
to keep resources optimised we do not keep anyone signed in for longer than
|
||||
<strong>4 hours</strong>. After that your session ends and you re-authenticate here.
|
||||
@@ -1149,7 +1151,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=20261009b"></script>
|
||||
<script src="/assets/my.js?v=20261009c"></script>
|
||||
<script src="/assets/chat.js?v=20260907l"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user