Drip Runner trial (2026-09-30): /api/my/driprunner hand-off, /refuel verified-visit page for the game (advertiser charged, viewer gets fuel not credits, signed callback + receipt), completeVisit(opts)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-30 13:33:37 -05:00
parent 3ae9ab55e9
commit 587272673b
4 changed files with 164 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
/* Drip Runner refuel: one verified visit, then back to the game with a signed receipt. */
(function () {
'use strict';
var $ = function (id) { return document.getElementById(id); };
var q = new URLSearchParams(location.search); var tok = q.get('t') || '';
var nonce = ''; try { nonce = JSON.parse(atob(tok.split('.')[0].replace(/-/g, '+').replace(/_/g, '/'))).nonce || ''; } catch (e) {}
var ret = null, dwell = 8, left = 8, timer = null, done = false;
function msg(title, text, backUrl) { $('rfFrame').innerHTML = '<div class="rf-msg" style="background:#0b1020;height:100%"><h1>' + title + '</h1><p>' + text + '</p></div>'; $('rfDone').hidden = true; $('rfCheck').hidden = true; if (backUrl) { var b = $('rfBack'); b.hidden = false; b.onclick = function () { location.href = backUrl; }; } }
function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]; }); }
function api(p, body) { return fetch(p, body ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}).then(function (r) { return r.json(); }); }
function ring() { $('rfN').textContent = left; $('rfRing').style.setProperty('--p', ((dwell - left) / dwell * 100) + '%'); }
function tick() {
if (document.hidden) return; // the timer only runs while the page is in front
left--; if (left > 0) return ring();
clearInterval(timer); ring(); $('rfHint').textContent = 'One quick check to count the visit:';
challenge();
}
function challenge() {
api('/api/refuel/challenge?n=' + encodeURIComponent(nonce)).then(function (c) {
if (c.early) { setTimeout(challenge, (c.wait || 1) * 1000 + 300); return; }
if (c.error) { $('rfHint').textContent = c.error; return; }
$('rfPrompt').textContent = 'Tap the ' + c.prompt + ':'; var w = $('rfOpts'); w.innerHTML = '';
c.options.forEach(function (em, i) { var b = document.createElement('button'); b.type = 'button'; b.textContent = em; b.addEventListener('click', function () { answer(i); }); w.appendChild(b); });
$('rfCheck').hidden = false;
});
}
function answer(i) {
api('/api/refuel/done', { n: nonce, answer: i }).then(function (r) {
if (r.error) { if (r.retry) return challenge(); $('rfHint').textContent = r.error; $('rfCheck').hidden = true; return; }
done = true; $('rfCheck').hidden = true; $('rfHint').textContent = 'Visit counted. Your tank is full.';
var b = $('rfDone'); b.disabled = false; b.textContent = 'Back to the run'; b.onclick = function () { location.href = r.ret; };
setTimeout(function () { location.href = r.ret; }, 1200);
});
}
if (!tok) return msg('No refuel link', 'Open this page from the game’s Refuel button.');
api('/api/refuel/open?t=' + encodeURIComponent(tok)).then(function (r) {
if (r.error) return msg('Refuel link problem', esc(r.error));
if (r.done) { location.href = r.ret; return; }
if (r.none) return msg('No sponsor pages right now', r.why === 'cap' ? 'You have done today’s verified visits on InstantAdPay. Refuels reopen tomorrow.' : 'No verified-visit packs are running at the moment. Try again in a while.', r.ret + '&none=1');
ret = r.ret; dwell = r.dwell || 8; left = Math.max(1, dwell - (r.elapsed || 0));
$('rfTitle').textContent = r.title || 'Member site'; try { $('rfUrl').textContent = new URL(r.target).hostname; } catch (e) {}
var f = document.createElement('iframe'); f.src = r.target; f.setAttribute('referrerpolicy', 'no-referrer'); f.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups'); $('rfFrame').innerHTML = ''; $('rfFrame').appendChild(f);
var o = $('rfOpen'); o.href = r.target; o.hidden = false;
ring(); timer = setInterval(tick, 1000);
}).catch(function () { msg('Could not load the visit', 'Check your connection and go back to the game.'); });
})();
+42
View File
@@ -0,0 +1,42 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<meta name="robots" content="noindex,nofollow">
<title>Refuel · InstantAdPay verified visit</title>
<link rel="stylesheet" href="/assets/site.css?v=20260929b">
<style>
html,body{height:100%}
body{margin:0;display:flex;flex-direction:column;background:#0b1020;color:#e6edf3}
.rf-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 14px;background:#0E1730;border-bottom:1px solid #22304f;font-size:13px}
.rf-bar b{color:#fff}.rf-bar .rf-url{color:#8fa3c4;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;max-width:45%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rf-frame{flex:1;min-height:0;background:#fff;position:relative}
.rf-frame iframe{position:absolute;inset:0;width:100%;height:100%;border:0}
.rf-dock{padding:12px 14px calc(12px + env(safe-area-inset-bottom,0px));background:#0E1730;border-top:1px solid #22304f}
.rf-row{display:grid;grid-template-columns:48px 1fr;gap:12px;align-items:center}
.rf-ring{width:48px;height:48px;border-radius:50%;background:conic-gradient(#FF6A1A var(--p,0%),#22304f 0);display:grid;place-items:center;font:800 13px ui-monospace,Menlo,Consolas,monospace;position:relative}
.rf-ring:after{content:"";position:absolute;inset:5px;border-radius:50%;background:#0E1730}.rf-ring span{position:relative;z-index:1}
.rf-dock p{margin:0;font-size:13px;color:#afc0d8}.rf-dock p b{color:#fff}
.rf-opts{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.rf-opts button{font-size:24px;padding:8px 14px;border-radius:10px;border:1px solid #22304f;background:#141F3A;cursor:pointer}
.rf-btn{display:block;width:100%;margin-top:10px;padding:13px;border-radius:12px;border:0;font:800 15px system-ui,sans-serif;letter-spacing:.06em;text-transform:uppercase;color:#fff;background:linear-gradient(180deg,#FFB088,#FF6A1A 55%,#D44E00);cursor:pointer}
.rf-btn[disabled]{opacity:.45}
.rf-btn.ghost{background:transparent;border:1px solid #22304f;color:#afc0d8;font-size:13px;padding:10px}
.rf-msg{padding:24px 18px;text-align:center}
.rf-msg h1{font-size:22px;margin:0 0 8px}.rf-msg p{color:#afc0d8}
a.rf-open{color:#8FF0FF;font-size:12px}
</style>
</head>
<body>
<div class="rf-bar"><span>InstantAdPay · <b>verified visit</b> · refuel for Drip Runner</span><span class="rf-url" id="rfUrl"></span></div>
<div class="rf-frame" id="rfFrame"></div>
<div class="rf-dock" id="rfDock">
<div class="rf-row"><div class="rf-ring" id="rfRing"><span id="rfN">…</span></div><div><p><b id="rfTitle">Loading the sponsor page…</b></p><p id="rfHint">Stay on this page. The timer only runs while it is in front.</p><a class="rf-open" id="rfOpen" href="#" target="_blank" rel="noopener" hidden>Page not showing? Open it in a new tab (the timer keeps running here).</a></div></div>
<div id="rfCheck" hidden><p id="rfPrompt" style="margin-top:10px"></p><div class="rf-opts" id="rfOpts"></div></div>
<button class="rf-btn" id="rfDone" type="button" disabled>Waiting…</button>
<button class="rf-btn ghost" id="rfBack" type="button" hidden>Back to the game</button>
</div>
<script src="/assets/refuel.js?v=20260930a"></script>
</body>
</html>