Invite friends card in the lobby + ?ref attribution on every entry page

Marty: members could not find their referral link. A signed-in player now sees an
"Invite friends" card right under Play: their /r/<username> link (previews with their
own card), Copy (clipboard API, select+copy fallback, prompt last) with a Copied!
confirmation, and Share where the phone has a share sheet. Link stats and the how-it-works
line moved into the card. No username yet: the card says how to get one.

Attribution: ?ref=<name> on /, /play and /signin (and ?r= on the landing, where framed
/r/<name> lands) now sets the same dr.ref sponsor cookie as /r/<name>, last touch wins.
/r/<name> for a name the game does not know keeps it as /?ref=<name> instead of
dropping it. signin.js also reads ?ref straight from the URL. Tests cover each path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-05 07:25:22 -05:00
parent 09692de8c6
commit 11d6f46950
6 changed files with 71 additions and 11 deletions
+26 -2
View File
@@ -88,6 +88,17 @@ canvas#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch
.tip{margin:12px 0 0;padding:10px 12px;border-radius:10px;background:rgba(34,211,238,.07);border:1px solid rgba(34,211,238,.25);font-size:12px;line-height:1.45;color:var(--ink2);text-align:left}.tip b{display:block;font:700 9px var(--body);letter-spacing:.16em;text-transform:uppercase;color:var(--cyan);margin-bottom:3px}
.shrHow{margin:6px 0 8px;font-size:11px;line-height:1.45;color:var(--ink2)}.shrHow a{color:inherit}
.shr{margin-top:10px;padding:10px 12px;border-radius:10px;border:1px solid var(--line);background:rgba(14,23,45,.6);font-size:11px;color:var(--muted);text-align:center}.shr b{color:var(--gold)}.shr .btn{margin-top:8px}
/* invite friends card (2026-10-05) */
.inv{margin-top:14px;padding:14px 14px 12px;border-radius:14px;border:1px solid rgba(34,211,238,.5);background:linear-gradient(180deg,rgba(14,40,58,.92),rgba(14,23,45,.96));box-shadow:0 0 34px -14px rgba(34,211,238,.6);text-align:left}
.inv .eyebrow{font:800 13px var(--display);letter-spacing:.14em;text-transform:uppercase;color:var(--cyan2)}
.invLead{margin:6px 0 10px;font-size:13px;line-height:1.45;color:var(--ink)}
.invLbl{display:block;font:700 9px var(--body);letter-spacing:.16em;text-transform:uppercase;color:var(--muted);margin-bottom:4px}
.invLink{display:block;width:100%;padding:10px 11px;border-radius:10px;border:1px solid var(--line);background:rgba(5,9,18,.75);color:var(--gold2);font:700 13px var(--mono);user-select:all;-webkit-user-select:all}
.invLink:focus{outline:2px solid var(--cyan);outline-offset:1px}
.invBtns{display:flex;gap:10px}.invBtns .btn{flex:1 1 0;min-width:0;font-size:13px;padding:12px 8px}
.invBtns .btn.done{background:linear-gradient(180deg,#A7F3D0,var(--ok) 55%,#059669)}
.invNote{margin:8px 0 0;font-size:11px;line-height:1.45;color:var(--muted)}.invNote a{color:var(--cyan2)}
.invStat{margin-top:10px;padding-top:8px;border-top:1px solid var(--line);font-size:11px;color:var(--muted)}.invStat b{color:var(--gold)}
.toast{position:absolute;left:50%;bottom:calc(70px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:20;background:var(--panel2);border:1px solid var(--line);color:var(--ink);font-size:12px;padding:8px 12px;border-radius:10px;opacity:0;transition:opacity .2s;pointer-events:none;max-width:92%;text-align:center}
.toast.on{opacity:1}
/* member welcome offer (2026-10-05): an extra card under the chapter-clear result, never during a run, never blocking */
@@ -130,9 +141,22 @@ canvas#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch
<div class="tip" id="lTip" hidden></div>
<button class="btn" id="bPlay" type="button">Play</button>
<div class="row2"><button class="btn ghost" id="bHangar" type="button">Hangar</button><button class="btn ghost" id="bBalance" type="button">Balance</button></div>
<!-- invite friends (2026-10-05, Marty: members could not find their link): a signed-in player's own /r/<username> link, right under Play -->
<section class="inv" id="lShare" hidden aria-labelledby="invTitle">
<div class="eyebrow" id="invTitle">Invite friends</div>
<p class="invLead">Invite friends to Drip Runner. When they join InstantAdPay from your link, you are their sponsor.</p>
<div id="invHas">
<label class="invLbl" for="invLink">Your invite link</label>
<input class="invLink" id="invLink" type="text" readonly value="" aria-label="Your invite link">
<div class="invBtns"><button class="btn" id="bCopy" type="button">Copy link</button><button class="btn ghost" id="bShare" type="button">Share</button></div>
<p class="invNote">It shows your own card when you post it on Telegram, Facebook or X.</p>
<div class="invStat" id="lShareStat"></div>
<p class="shrHow" id="lShareHow"></p>
</div>
<p class="invNote" id="invNone" hidden>Your invite link uses your InstantAdPay username. <a id="invNoneGo" href="https://instantadpay.com/my">Set your username on InstantAdPay</a>, then come back here.</p>
</section>
<a class="btn gold" id="bLevel" href="https://instantadpay.com/my#buy" style="text-decoration:none;text-align:center;font-size:13px;padding:11px">Level up on InstantAdPay</a>
<a class="btn" id="bSignin" href="#" hidden style="text-decoration:none;text-align:center">Sign in to keep progress</a>
<div class="shr" id="lShare" hidden><div id="lShareStat"></div><p class="shrHow" id="lShareHow"></p><button class="btn ghost" id="bShare" type="button">Share your link</button></div>
<div class="member" id="lMember"><i></i>connecting…</div>
<div id="moreGames" class="moreGames" hidden></div>
<div class="member" style="margin-top:6px"><a id="lIap" href="https://instantadpay.com/my" style="color:var(--muted)">InstantAdPay dashboard</a> · <a href="/" style="color:var(--muted)">tester briefing</a></div>
@@ -181,6 +205,6 @@ canvas#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch
<script src="https://instantadpay.com/assets/game-signin.js?v=20261003a" async></script>
<script src="https://instantadpay.com/assets/game-strip.js?v=20261003a"></script>
<script src="/spawn.js"></script>
<script src="/play.js?v=20261005a"></script>
<script src="/play.js?v=20261005b"></script>
</body>
</html>
+20 -3
View File
@@ -71,9 +71,11 @@ function lobby() {
$('lMember').innerHTML = '<i class="' + (ME.wallet ? '' : 'no') + '"></i>InstantAdPay · ' + (ME.username ? '@' + ME.username : '#' + ME.memberId) + ' · ' + (ME.wallet ? ME.wallet.slice(0, 6) + '…' + ME.wallet.slice(-4) : 'no wallet on file');
$('bSignin').hidden = true;
var rf = ME_EXTRA.referrals || {};
$('lShare').hidden = !ME_EXTRA.share;
// the invite card shows for every signed-in player; without a username there is no link yet, so it says how to get one
$('lShare').hidden = false; $('invHas').hidden = !ME_EXTRA.share; $('invNone').hidden = !!ME_EXTRA.share; $('invNoneGo').href = IAP + '/my';
$('invLink').value = ME_EXTRA.share || ''; $('bShare').hidden = !navigator.share;
$('lShareHow').innerHTML = 'Players whose InstantAdPay sponsor is you are your team. Each time one of them refuels, ' + (rf.pct || 10) + '% of what that refuel adds to the pool is credited to your balance, and it is sent to your wallet with your drips at ' + Number((BAL && BAL.threshold) || 0.25).toFixed(2) + ' POL. <a href="/#team" target="_blank" rel="noopener">How it works</a>';
$('lShareStat').innerHTML = 'Your link: <b>' + (rf.clicks || 0) + '</b> visits · <b>' + (rf.count || 0) + '</b> players on your team · <b>' + f3(rf.earned) + '</b> POL earned from their refuels (' + (rf.pct || 0) + '% of each)';
$('lShareStat').innerHTML = 'Your link: <b>' + (rf.clicks || 0) + '</b> visit' + (rf.clicks === 1 ? '' : 's') + ' · <b>' + (rf.count || 0) + '</b> player' + (rf.count === 1 ? '' : 's') + ' on your team · <b>' + f3(rf.earned) + '</b> POL earned from their refuels (' + (rf.pct || 0) + '% of each)';
}
show('ovLobby');
}
@@ -167,7 +169,22 @@ function starterOffer(o) {
$('cOfferNo').addEventListener('click', function () { $('cOffer').hidden = true; });
$('bNext').addEventListener('click', function () { if (!R) return; R.paused = false; R.inv = 1.5; hideAll(); });
$('bShareClear').addEventListener('click', function () { share(this.dataset.text || 'Play Drip Runner with me:'); });
$('bShare').addEventListener('click', function () { share('I am playing Drip Runner, a game that pays in POL. Hop the network, dodge the bots:'); });
$('bShare').addEventListener('click', function () { share('Come play Drip Runner with me. Hop the network, dodge the bots:'); });
// Copy: the clipboard API where the page may use it, else select the field and copy, else a prompt to copy by hand
var copyT = null;
function copied(ok) {
var b = $('bCopy'); clearTimeout(copyT);
if (!ok) { window.prompt('Copy your invite link', ME_EXTRA.share); return; }
b.textContent = 'Copied!'; b.classList.add('done'); toast('Invite link copied. Paste it anywhere.');
copyT = setTimeout(function () { b.textContent = 'Copy link'; b.classList.remove('done'); }, 2200);
}
function copyFallback() { var f = $('invLink'), ok = false; try { f.focus(); f.select(); f.setSelectionRange(0, f.value.length); ok = document.execCommand('copy'); } catch (e) { ok = false; } f.blur(); copied(ok); }
$('bCopy').addEventListener('click', function () {
var url = ME_EXTRA.share; if (!url) return;
if (navigator.clipboard && navigator.clipboard.writeText && window.isSecureContext !== false) navigator.clipboard.writeText(url).then(function () { copied(true); }, copyFallback);
else copyFallback();
});
$('invLink').addEventListener('focus', function () { this.select(); });
$('bRestart').addEventListener('click', function () { endRun().then(newRun); });
function endRun() { var id = R && R.id; R = null; hideAll(); return id ? api('/api/run/end', { runId: id }).catch(function () {}) : Promise.resolve(); }
['bLobby1', 'bLobby2'].forEach(function (id) { $(id).addEventListener('click', function () { endRun().then(loadMe).then(lobby); }); });
+1 -1
View File
@@ -23,6 +23,6 @@ html{background:#050912}
<p class="back"><a href="/play">Keep playing as a guest</a></p>
</main>
<script src="https://instantadpay.com/assets/game-signin.js?v=20261003b"></script>
<script src="/signin.js"></script>
<script src="/signin.js?v=20261005b"></script>
</body>
</html>
+2 -1
View File
@@ -5,5 +5,6 @@
if (!window.IAPSignin) { box.innerHTML = '<p>Sign-in could not load. <a href="https://instantadpay.com/api/my/driprunner" style="color:var(--cyan)">Sign in on InstantAdPay instead</a>.</p>'; return; }
var m = /(?:^|;\s*)dr\.ref=([^;]+)/.exec(document.cookie || ''); // the share link a guest arrived on: their sponsor
var s = /(?:^|;\s*)dr\.src=([^;]+)/.exec(document.cookie || ''); // paid-traffic source, if any (2026-10-03)
IAPSignin.mount(box, { game: 'driprunner', src: s ? decodeURIComponent(s[1]).split('|')[0] : '', ref: m ? decodeURIComponent(m[1]) : '', title: 'Sign in to run', oneTap: IAPSignin.origin + '/api/my/driprunner' });
var q = String(new URLSearchParams(location.search).get('ref') || '').replace(/[^A-Za-z0-9_.-]/g, '').slice(0, 40); // /signin?ref=<name> works even where the cookie was refused (2026-10-05)
IAPSignin.mount(box, { game: 'driprunner', src: s ? decodeURIComponent(s[1]).split('|')[0] : '', ref: q || (m ? decodeURIComponent(m[1]) : ''), title: 'Sign in to run', oneTap: IAPSignin.origin + '/api/my/driprunner' });
})();