Landing: keep the share link's ?r= when the cookie is refused (URL + localStorage fallback for the join link)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-29 09:49:01 -05:00
parent 8a850e1443
commit 10b850b34b
+5
View File
@@ -95,6 +95,11 @@
.map(([l, v]) => '<div class="stat"><div class="v num">' + v + '</div><div class="l">' + l + '</div></div>').join('');
const cfg = await (await fetch('/api/config')).json();
// arrived on a member's share link: sign-ups go to that member's InstantAdPay join page
// the share link's ?r= is the truth even when the cookie was refused (blocked cookies, a framed view, a
// different browser later): read it from the URL, keep a copy in this browser, and build the join link here
// (2026-09-29: referrals were landing under the company with the cookie missing)
try { const rq = String(new URLSearchParams(location.search).get('r') || '').trim().slice(0, 40); if (/^[A-Za-z0-9_.-]{1,40}$/.test(rq)) localStorage.setItem('ph.ref', rq); } catch (e) {}
if (!cfg.ref) { let alt = ''; try { alt = String(new URLSearchParams(location.search).get('r') || localStorage.getItem('ph.ref') || '').trim().slice(0, 40); } catch (e) {} if (/^[A-Za-z0-9_.-]{1,40}$/.test(alt)) { cfg.ref = alt; cfg.joinUrl = 'https://instantadpay.com/join/' + encodeURIComponent(alt) + '?from=polhunter'; } }
if (cfg.ref) { document.querySelectorAll('a[href="https://instantadpay.com/?from=polhunter"]').forEach(a => { a.href = cfg.joinUrl; }); const inv = document.createElement('span'); inv.className = 'pill'; inv.style.marginLeft = '10px'; inv.innerHTML = '<i></i> Invited by @' + cfg.ref.replace(/[<>&"]/g, ''); document.querySelector('.hero-copy .pill').after(inv); }
document.getElementById('recent').innerHTML = (r.recent || []).length ? r.recent.map(x => '<div class="row"><span>' + x.who + '</span><span class="site">' + x.site + '</span><span class="pol">+' + x.pol + ' POL</span><a class="when" href="' + cfg.explorer + '/tx/' + x.tx + '" target="_blank" rel="noopener">verify ↗</a></div>').join('')
: '<div class="row"><span class="site">No drips yet. The first hunter gets the first line.</span></div>';