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:
@@ -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