Files
instantadpay/public/assets/refuel.js
T
martbost a058fd515d Warp & Wares integration, gated (2026-10-29): the 30-day Trade Wars-style season game, same protocol as POL Miner and Turkey Drop. WW_SSO_SECRET / WW_URL (default https://warpwares.saasy.top, staging for now) / WW_ALT_URLS / WW_SEASON_START + WW_SEASON_END (default 2026-11-30..2026-12-30, Central, end exclusive) with wwMint/wwOpen/wwIsGameUrl/wwCallback (code defaults only, no env set); GAME_AUTH warpwares (in-game sign-in kit); /api/my/warpwares hand-off + iap.return + my.js redirect; a new visit kind 'dock' in ads.js VISIT_KINDS with its own daily cap (dockCapPerDay, default 10; repeats after the cooldown like refuels; house visits count toward it) and the refuel rail serving game 'warpwares' with that kind (label 'sponsor dock', receipt kind ww-dock, note 'Warp & Wares sponsor dock', refuel.js done text 'Your bonus turns are waiting on the bridge'); GAMES() card with the season window (hidden until 'warpwares' is in gamesLive, its 'Opens' date shown only once live, gone after the season) and STRIP line; growth snapshot counts a season start only when live; walletnudge entry (idle until the secret is set); gamestats + gamepass GAMES/NAMES + GP_SECRETS; Game Pass perks row 'the Season Pass' shown only while the game is in the public games list (gpShown, the Turkey Drop pattern); cap-nudge names; promo tools Games entry (warpwares.saasy.top/?ref=, 3 posts) shown only while live; chatbot CANNED warpwares + fact follow gamesLive and the season window (coming-soon and season-over answers, KB answer kept out of the prompt unless live), KNOWLEDGE_DATE 2026-10-29b; my.js?v=20261029ww, promo.js?v=20261029ww, refuel.js?v=20261029ww. qa/warpwares.mjs (bash qa/run.sh warpwares): 21 checks on a local copy with a mock game (card gating, the hand-off token, a sponsor dock open/challenge/done with receipt + callback, the dock cap separate from refuels, chatbot gating), all passing. Not merged, not deployed.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-29 16:43:49 -05:00

66 lines
6.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* 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 = '', tokRet = ''; try { var claims = JSON.parse(atob(tok.split('.')[0].replace(/-/g, '+').replace(/_/g, '/'))); nonce = claims.nonce || ''; tokRet = claims.ret || ''; } catch (e) {}
// every dead end on this page keeps a way back to the run (Marty, 2026-09-30)
var gameHome = tokRet ? tokRet.split('?')[0] : 'https://driprunner.saasy.top/play';
var GAME = 'Drip Runner', inGame = false; try { inGame = window.parent !== window; } catch (e) { inGame = true; } // Gem Kingdom shows this page in an overlay (2026-10-03)
function setGame(r) { if (!r || !r.game) return; GAME = r.game; var bar = document.querySelector('.rf-bar span'); if (bar) bar.innerHTML = 'InstantAdPay \u00b7 <b>verified visit</b> \u00b7 ' + (r.label || 'refuel') + ' for ' + esc(GAME); }
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; var b = $('rfBack'); b.hidden = false; var to = backUrl || gameHome; b.textContent = backUrl ? 'Back to the game' : 'Back to Drip Runner'; b.onclick = function () { location.href = to; }; }
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
var vid = document.getElementById('rfVideo'); if (vid && (vid.paused || vid.ended && left > 1)) return; // a video must actually be playing
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; var gk = GAME === 'Gem Kingdom', ch = GAME === 'ClutterHunt', sw = GAME === 'SpellWheel', ww = GAME === 'Warp & Wares';
$('rfHint').textContent = gk ? 'Visit counted. Your heroes are back on their feet.' : (ch || sw) ? 'Visit counted. Your hint is ready.' : ww ? 'Visit counted. Your bonus turns are waiting on the bridge.' : 'Visit counted. Your tank is full.';
if (gk && inGame) { try { window.parent.postMessage({ gkContinue: nonce, ok: true }, '*'); } catch (e) {} }
var b = $('rfDone'); b.disabled = false; b.textContent = gk ? 'Back to the battle' : ch ? 'Back to the room' : sw ? 'Back to the puzzle' : ww ? 'Back to the bridge' : '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) {
setGame(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(r.why === 'cap' ? 'That is today’s refuels' : 'No sponsor pages right now', r.why === 'cap' ? 'You have used today’s refuels. Your run and progress are saved, and refuels reopen at midnight Central. Your regular InstantAdPay visits are not affected.' : 'You have used every sponsor page and video running right now. Try again later: new ones start all the time.', r.ret + '&none=1');
ret = r.ret; dwell = r.dwell || 8; left = Math.max(1, dwell - (r.elapsed || 0));
if (r.mode === 'video') { // no sponsor pages left: a member video ad instead
$('rfTitle').textContent = r.title || 'Member video'; $('rfUrl').textContent = 'video ad';
$('rfHint').textContent = 'You have visited every sponsor page running right now, so this refuel is a short member video. Keep it playing.';
var v = document.createElement('video'); v.id = 'rfVideo'; v.src = r.video.url; v.autoplay = true; v.muted = true; v.playsInline = true; v.setAttribute('playsinline', ''); v.loop = true; v.controls = false;
v.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#000';
$('rfFrame').innerHTML = ''; $('rfFrame').appendChild(v);
var un = document.createElement('button'); un.type = 'button'; un.textContent = 'Tap for sound'; un.style.cssText = 'position:absolute;right:10px;bottom:10px;z-index:2;padding:8px 12px;border-radius:8px;border:0;background:rgba(0,0,0,.6);color:#fff;font:600 12px system-ui';
un.onclick = function () { v.muted = false; v.play().catch(function () {}); un.remove(); }; $('rfFrame').appendChild(un);
v.play().catch(function () { $('rfHint').textContent = 'Tap the video to start it. The timer runs while it plays.'; v.onclick = function () { v.play(); }; });
ring(); timer = setInterval(tick, 1000); return;
}
$('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.'); });
})();