diff --git a/public/assets/common.js b/public/assets/common.js index 1c550f7..5e2fb7e 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -48,12 +48,23 @@ window.BL = (function () { // "Part of the network": the list comes from the hub through /api/network-sites, the built-in copy if it does not answer const NET = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'], ['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] })); + // the footer links carry a referral username (Marty 2026-11-15): the signed-in member's own network username, else the sponsor this + // visitor came in on (/api/me names both; the bl.ref cookie holds a wallet, so it is never used here). Tracked links get it as s1 + // (LinkSpin sends it on as ?ref=), plain links as ?ref=. Earners Corner takes none. + const REF_RE = /^[A-Za-z0-9_.-]{1,40}$/; + const okRef = v => !!v && REF_RE.test(v) && !/^0x[0-9a-f]{40}$/i.test(v); + function netRef(href, s, ref) { + if (!ref || s.id === 'earnerscorner') return href; + try { const u = new URL(href); u.searchParams.set(s.go ? 's1' : 'ref', ref); return u.toString(); } catch (e) { return href; } + } function netLine(el) { if (!el) return; - const paint = list => { el.innerHTML = 'Part of the network · One account across the network: ' + list.map(s => (s.id === 'dlb' || /downlinebanners\.com/.test(s.url)) - ? '' + esc(s.name) + '' : '' + esc(s.name) + '').join(' · '); }; - paint(NET); - fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) paint(l); }).catch(() => {}); + let list = NET, ref = ''; + const paint = () => { el.innerHTML = 'Part of the network · One account across the network: ' + list.map(s => (s.id === 'dlb' || /downlinebanners\.com/.test(s.url)) + ? '' + esc(s.name) + '' : '' + esc(s.name) + '').join(' · '); }; + paint(); + fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) { list = l; paint(); } }).catch(() => {}); + fetch('/api/me', { credentials: 'same-origin' }).then(r => r.json()).then(m => { const r = m && m.signedIn && okRef(m.username) ? m.username : (m && okRef(m.refName) ? m.refName : ''); if (r) { ref = r; paint(); } }).catch(() => {}); } // one spot tile; href goes through the /go relay, which counts the click function tile(t, opts) { diff --git a/public/board.html b/public/board.html index 19ac82d..bc7a3be 100644 --- a/public/board.html +++ b/public/board.html @@ -31,7 +31,7 @@