Traffic-exchange frames: framed pages open sign-in, Get a Position, My Team, wallet and off-site links in a new tab carrying ?ref=<sponsor>
Traffic exchanges, rotators and Massifly Adpoints show 5xyourteam.com inside another site's frame, where the browser drops the SameSite=Lax fx.ref and fx.sid cookies, so signing in, buying or joining from the frame lost the sponsor (Marty 2026-11-19). - common.js: framed (window.top !== window.self) -> /team, /join, /admin, /sso/ and off-site links get target=_blank rel=noopener (on load and again at click time); /team, /join and /sso/ links add ?ref= from the page's ?ref= (or ?r=), the coach page it is, or the cookie. The wallet buttons ([data-wallet-signin], Pay = [data-full-window]) open this page in a new tab with ?ref= instead of signing inside the frame. Public pages stay in the frame. - server: /sso/start?...&ref=<name> sets fx.ref first-party and 302s to the plain start; /sso/* sends X-Frame-Options DENY (/team and /admin already did). Sponsor rules unchanged. - coach.js marks the coach; join.js keeps Pay clickable when framed; asset tags bumped. Checked with the fake traffic-exchange harness (cross-site frame, JS a.click()): 11/11 flows open a new tab with the sponsor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+35
-1
@@ -5,6 +5,40 @@ window.FX = (function () {
|
||||
const $ = id => document.getElementById(id);
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json()));
|
||||
// Traffic exchanges, rotators and Massifly Adpoints show these pages inside another site's frame, where the browser drops the
|
||||
// fx.ref and sign-in cookies (SameSite=Lax). Framed (Marty 2026-11-19, the IAP / PolHunter / ViralAdBlitz frame pattern): sign-in,
|
||||
// Get a Position, My Team and off-site links open in a new tab, a new tab back to this site carries ?ref=<sponsor> so it sets the
|
||||
// cookie first-party, and the wallet buttons (sign in, pay) open this page in a new tab instead. The sponsor: the page's own
|
||||
// ?ref= (or ?r=), else the coach page it is, else the cookie.
|
||||
const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })();
|
||||
const REF_RE = /^[A-Za-z0-9_.-]{2,40}$|^0x[0-9a-fA-F]{40}$/;
|
||||
function pageRef() {
|
||||
const q = new URLSearchParams(location.search); const r = q.get('ref') || q.get('r');
|
||||
if (r && REF_RE.test(r)) return r;
|
||||
const pg = document.body && document.body.dataset.pageRef; if (pg && REF_RE.test(pg)) return pg;
|
||||
const c = /(?:^|;\s*)fx\.ref=([^;]+)/.exec(document.cookie); let v = ''; try { v = c ? decodeURIComponent(c[1]) : ''; } catch (e) {}
|
||||
return REF_RE.test(v) ? v : '';
|
||||
}
|
||||
const withRef = url => { const r = pageRef(); return r ? url + (url.indexOf('?') < 0 ? '?' : '&') + 'ref=' + encodeURIComponent(r) : url; };
|
||||
const NEW_TAB = /^\/(team|join|admin|sso)(\/|$)/; // sign-in, buying and member pages: never usable inside a frame
|
||||
function frameLink(a) {
|
||||
if (!framed || !a || !a.href || a.hasAttribute('download')) return;
|
||||
let x; try { x = new URL(a.href, location.href); } catch (e) { return; }
|
||||
if (!/^https?:$/.test(x.protocol)) return;
|
||||
const own = x.origin === location.origin;
|
||||
if (own && !NEW_TAB.test(x.pathname)) return; // public pages stay in the frame
|
||||
if (own && /^\/(team|join|sso)(\/|$)/.test(x.pathname) && !x.searchParams.get('ref')) { const r = pageRef(); if (r) { x.searchParams.set('ref', r); a.setAttribute('href', x.pathname + x.search + x.hash); } }
|
||||
a.target = '_blank'; if (!/noopener/.test(a.rel || '')) a.rel = ((a.rel || '') + ' noopener').trim();
|
||||
}
|
||||
const frameLinks = () => { if (framed) document.querySelectorAll('a[href]').forEach(frameLink); };
|
||||
if (framed) {
|
||||
document.addEventListener('click', e => {
|
||||
const t = e.target.closest && e.target.closest('a[href], [data-wallet-signin], [data-full-window]'); if (!t) return;
|
||||
if (t.tagName === 'A') return frameLink(t);
|
||||
e.preventDefault(); e.stopImmediatePropagation(); window.open(withRef(location.pathname), '_blank', 'noopener');
|
||||
}, true);
|
||||
document.addEventListener('DOMContentLoaded', frameLinks);
|
||||
}
|
||||
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
||||
const n = x => Number(x || 0).toLocaleString('en-US');
|
||||
function status(msg, cls, id) { const el = $(id || 'status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; }
|
||||
@@ -110,7 +144,7 @@ window.FX = (function () {
|
||||
(root || document).querySelectorAll('[data-wallet-signin]').forEach(b => { b.onclick = async () => {
|
||||
try { status('Check your wallet for the sign-in message.'); await FXWallet.signIn(); location.reload(); } catch (e) { status(String(e && e.message || e).slice(0, 300), 'err'); } }; });
|
||||
}
|
||||
return { $, esc, getConfig, short, status, getJSON, post, n, polOf, when, ago, left, initials, renderNav, renderFooter, setWeek, weekNo, card, silentSso, signInBlock, wireSignIn };
|
||||
return { $, esc, getConfig, short, framed, pageRef, withRef, frameLink, frameLinks, status, getJSON, post, n, polOf, when, ago, left, initials, renderNav, renderFooter, setWeek, weekNo, card, silentSso, signInBlock, wireSignIn };
|
||||
})();
|
||||
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub through
|
||||
// /api/network-deals). Not on the 1080x1080 draft-day card or the admin page.
|
||||
|
||||
Reference in New Issue
Block a user