From 0112422c724cf50fb3756486e3780b5d830f428b Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 3 Oct 2026 10:19:39 -0500 Subject: [PATCH] Cross-promo strip: /api/public/games (live list, Spooky Doors while in season), /g/ counted hop (signed-in straight into the game), shared /assets/game-strip.js; Drip Runner card says 0.10 POL Co-Authored-By: Claude Opus 5.5 --- public/assets/game-strip.js | 36 ++++++++++++++++++++++++++++ server.js | 28 +++++++++++++++++++++- tools/patch_game_strip.py | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 public/assets/game-strip.js create mode 100644 tools/patch_game_strip.py diff --git a/public/assets/game-strip.js b/public/assets/game-strip.js new file mode 100644 index 0000000..2d03ff8 --- /dev/null +++ b/public/assets/game-strip.js @@ -0,0 +1,36 @@ +/* InstantAdPay "More games" strip (2026-10-03). Served by instantadpay.com and loaded by every network game, so the list + of games lives in one place (/api/public/games: live games, Spooky Doors only while its season runs). Each card goes + through /g/?from=, which counts the hop and lands a signed-in member straight in the game. + Theme with CSS variables on the container (--gs-*). Usage: + IAPGames.strip(el, { current: 'driprunner', title: 'More games' }); */ +(function () { + var IAP = 'https://instantadpay.com'; + try { var me = document.currentScript && document.currentScript.src; if (me) IAP = new URL(me).origin; } catch (e) {} + var CSS = '.iapgs{--ink:var(--gs-ink,#f2efff);--mu:var(--gs-muted,#b7b0d6);--card:var(--gs-card,rgba(255,255,255,.06));--ln:var(--gs-line,rgba(255,255,255,.16));--hot:var(--gs-hot,#ff8a1f);color:var(--ink);font-family:var(--gs-font,inherit);text-align:left}' + + '.iapgs .gs-h{font-size:12px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;color:var(--mu);margin:0 0 8px}' + + '.iapgs .gs-row{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(150px,1fr);gap:10px;overflow-x:auto;scroll-snap-type:x mandatory;padding-bottom:4px;-webkit-overflow-scrolling:touch}' + + '.iapgs a.gs-c{scroll-snap-align:start;display:flex;flex-direction:column;text-decoration:none;color:var(--ink);background:var(--card);border:1px solid var(--ln);border-radius:12px;overflow:hidden;min-width:0}' + + '.iapgs a.gs-c:hover,.iapgs a.gs-c:focus-visible{border-color:var(--ink)}' + + '.iapgs .gs-c img{display:block;width:100%;aspect-ratio:1200/630;object-fit:cover;background:#000}' + + '.iapgs .gs-t{padding:8px 10px 10px;display:grid;gap:3px}.iapgs .gs-t b{font-size:14px;line-height:1.2}' + + '.iapgs .gs-t small{font-size:12px;line-height:1.35;color:var(--mu)}.iapgs .gs-t em{font-style:normal;font-size:10.5px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--mu)}' + + '.iapgs .gs-t em.hot{color:var(--hot)}'; + function esc(s) { return String(s == null ? '' : s).replace(/[&<>"]/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); } + var cache = null; + function list() { if (!cache) cache = fetch(IAP + '/api/public/games', { credentials: 'omit' }).then(function (r) { return r.json(); }).then(function (j) { return (j && j.games) || []; }).catch(function () { cache = null; return []; }); return cache; } + function strip(el, opt) { + if (!el) return Promise.resolve(0); opt = opt || {}; + if (!document.getElementById('iapgsCss')) { var s = document.createElement('style'); s.id = 'iapgsCss'; s.textContent = CSS; document.head.appendChild(s); } + return list().then(function (games) { + var g = games.filter(function (x) { return x.slug !== opt.current; }); + if (!g.length) { el.hidden = true; return 0; } + el.classList.add('iapgs'); el.hidden = false; + el.innerHTML = '

' + esc(opt.title || 'More games') + '

' + g.map(function (x) { + return '' + + '' + esc(x.tag) + '' + esc(x.name) + '' + esc(x.line) + ''; + }).join('') + '
'; + return g.length; + }); + } + window.IAPGames = { strip: strip, list: list, origin: IAP }; +})(); diff --git a/server.js b/server.js index cfed082..a5c39ef 100644 --- a/server.js +++ b/server.js @@ -1373,13 +1373,29 @@ function GAMES() { { slug: 'spookydoors', name: 'Spooky Doors', tag: 'Halloween \u00b7 Oct 4 to 31', blurb: 'Trick or treat! Walk the street, knock on doors and fill your candy bucket. Every door is a short visit to a member\u2019s page or ad, and candy climbs a ladder with POL at set levels. Gone after Halloween night.', art: SD_URL() + '/og-spookydoors.jpg', play: '/api/my/spookydoors', pays: 'POL at set candy levels', season: { start: SD_SEASON.start, end: SD_SEASON.end }, progress: sdProgress }, { slug: 'driprunner', name: 'Drip Runner', tag: 'Arcade runner', blurb: 'Hop the network, dodge the bots, clear chapters. Each first clear drips POL into your game balance, and a refuel on a member\u2019s page keeps your run alive.', - art: DR_URL() + '/og-driprunner.jpg?v=20261002', artPos: 'left', play: '/api/my/driprunner', pays: 'POL to your wallet at 0.25', progress: drProgress }, + art: DR_URL() + '/og-driprunner.jpg?v=20261002', artPos: 'left', play: '/api/my/driprunner', pays: 'POL to your wallet at 0.10', progress: drProgress }, { slug: 'gemkingdom', name: 'Gem Kingdom', tag: 'Fantasy match-3', blurb: 'Match gems to battle monsters with three heroes, earn stars and rebuild your village. Crowns for instant upgrades come from your ad credits.', art: GK_URL() + '/fantasy/og-gemkingdom.jpg?v=20261002', play: '/api/my/gemkingdom', cta: 'Play', pays: 'POL for first clears; Crowns from ad credits' }, { slug: 'polhunter', name: 'PolHunter', tag: 'Scavenger hunt', blurb: 'Hunt hidden codes on sites across the network. Every find drips POL straight to your wallet.', art: 'https://polhunter.com/img/hero-800.webp', play: '/api/my/polhunter', pays: 'POL per find' }, ]; } +// -- cross-promo strip (2026-10-03): one short line per game and where a signed-out player lands (the game's own page) +const STRIP = () => ({ + spookydoors: { line: 'Halloween only. Run the graveyard, knock on doors, climb the candy ladder to POL.', open: SD_URL() + '/play', host: SD_URL().replace(/^https?:\/\//, '') }, + driprunner: { line: 'Hop, dodge the bots, clear chapters. Every first clear drips POL.', open: DR_URL() + '/play', host: DR_URL().replace(/^https?:\/\//, '') }, + gemkingdom: { line: 'Match gems, beat the bosses, rebuild your kingdom. First clears pay POL.', open: GK_URL() + '/play', host: GK_URL().replace(/^https?:\/\//, '') }, + polhunter: { line: 'Find hidden codes on sites across the network. Every find drips POL.', open: 'https://polhunter.com/', host: 'polhunter.com' }, +}); +// live for the strip: in gamesLive, and a seasonal game until its season ends (Marty 2026-10-03: Spooky Doors may show before +// its formal announcement; "if someone manages to see it and play it, that's fine") +function stripGames() { + const sc = siteConfig(); const live = new Set(String(sc.gamesLive == null ? 'polhunter' : sc.gamesLive).split(',').map(x => x.trim().toLowerCase()).filter(Boolean)); + const day = todayCT(), S = STRIP(); const lbl = d => { const t = new Date(d + 'T12:00:00Z'); t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); }; + return GAMES().filter(g => live.has(g.slug) && S[g.slug] && !(g.season && day >= g.season.end)) + .map(g => ({ slug: g.slug, name: g.name, tag: g.season ? 'Limited time \u00b7 ends ' + lbl(g.season.end) : g.tag, line: S[g.slug].line, art: g.art, artPos: g.artPos || 'center', seasonal: !!g.season })); +} + // -- PassiveDrip hand-off (2026-10-01): same token shape as Drip Runner, its own secret (PD_SSO_SECRET, also stored in // PassiveDrip's site_config iap_sso_secret). PassiveDrip signs the member in or creates the account, carries the sponsor // over by email, and OFFERS the wallet with one confirm tap; it never writes or overwrites a payout address silently. @@ -3042,6 +3058,16 @@ const server = http.createServer(async (req, res) => { doorTokens.set(nonce, t); return json(res, 200, Object.assign({ ok: true, posted, host, credits, ret: t.doneRet }, house, gold)); } + // -- cross-promo strip (2026-10-03): the list every game reads, and the counted hop between games + if (p === '/api/public/games' && req.method === 'GET') return json(res, 200, { games: stripGames() }, { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'public, max-age=300' }); + { const mg = /^\/g\/([a-z]{3,20})$/.exec(p); if (mg && req.method === 'GET') { + const g = GAMES().find(x => x.slug === mg[1]); const S = STRIP()[mg[1]]; + if (!g || !S) { res.writeHead(302, { Location: '/my#games', 'Cache-Control': 'no-store' }); return res.end(); } + const from = String(u.searchParams.get('from') || '').toLowerCase().replace(/[^a-z]/g, '').slice(0, 20); const src = STRIP()[from]; + traffic.hit('/g/' + g.slug, req.headers.referer || (src ? 'https://' + src.host + '/' : ''), req.headers['user-agent']); // Traffic tab: host = sending game, path g/ + const s = await auth.fromRequest(req); + res.writeHead(302, { Location: (s && s.email) ? g.play : S.open, 'Cache-Control': 'no-store' }); return res.end(); // signed in here: straight into the game, signed in + } } // -- Games hub (2026-10-01): the registry is here, the live list is site config (gamesLive) if (p === '/api/my/games' && req.method === 'GET') { const s = await auth.fromRequest(req); diff --git a/tools/patch_game_strip.py b/tools/patch_game_strip.py new file mode 100644 index 0000000..96301be --- /dev/null +++ b/tools/patch_game_strip.py @@ -0,0 +1,47 @@ +# Cross-promo strip (Marty, 2026-10-03: "cross-promote the other games from inside each game", Spooky Doors included now). +# /api/public/games = the live list (CORS *), /g/?from= = counted hop (Traffic tab: host = the sending game, +# path g/) that lands a signed-in member straight in the game through the usual hand-off, else on the game's own page. +ROOT = 'D:/Projects/HighRisk/onchain-ad-membership/site/' +def edit(path, pairs): + b = open(ROOT + path, 'rb').read(); crlf = b.count(b'\r\n') > b.count(b'\n') // 2 + s = b.decode('utf-8').replace('\r\n', '\n') + for a, r in pairs: + if s.count(a) != 1: raise SystemExit('%s anchor %d: %s' % (path, s.count(a), a[:70])) + s = s.replace(a, r) + if crlf: s = s.replace('\n', '\r\n') + open(ROOT + path, 'wb').write(s.encode('utf-8')); print('patched', path) + +HELP = r"""// -- cross-promo strip (2026-10-03): one short line per game and where a signed-out player lands (the game's own page) +const STRIP = () => ({ + spookydoors: { line: 'Halloween only. Run the graveyard, knock on doors, climb the candy ladder to POL.', open: SD_URL() + '/play', host: SD_URL().replace(/^https?:\/\//, '') }, + driprunner: { line: 'Hop, dodge the bots, clear chapters. Every first clear drips POL.', open: DR_URL() + '/play', host: DR_URL().replace(/^https?:\/\//, '') }, + gemkingdom: { line: 'Match gems, beat the bosses, rebuild your kingdom. First clears pay POL.', open: GK_URL() + '/play', host: GK_URL().replace(/^https?:\/\//, '') }, + polhunter: { line: 'Find hidden codes on sites across the network. Every find drips POL.', open: 'https://polhunter.com/', host: 'polhunter.com' }, +}); +// live for the strip: in gamesLive, and a seasonal game until its season ends (Marty 2026-10-03: Spooky Doors may show before +// its formal announcement; "if someone manages to see it and play it, that's fine") +function stripGames() { + const sc = siteConfig(); const live = new Set(String(sc.gamesLive == null ? 'polhunter' : sc.gamesLive).split(',').map(x => x.trim().toLowerCase()).filter(Boolean)); + const day = todayCT(), S = STRIP(); const lbl = d => { const t = new Date(d + 'T12:00:00Z'); t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); }; + return GAMES().filter(g => live.has(g.slug) && S[g.slug] && !(g.season && day >= g.season.end)) + .map(g => ({ slug: g.slug, name: g.name, tag: g.season ? 'Limited time \u00b7 ends ' + lbl(g.season.end) : g.tag, line: S[g.slug].line, art: g.art, artPos: g.artPos || 'center', seasonal: !!g.season })); +} + +""" +ROUTES = r""" // -- cross-promo strip (2026-10-03): the list every game reads, and the counted hop between games + if (p === '/api/public/games' && req.method === 'GET') return json(res, 200, { games: stripGames() }, { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'public, max-age=300' }); + { const mg = /^\/g\/([a-z]{3,20})$/.exec(p); if (mg && req.method === 'GET') { + const g = GAMES().find(x => x.slug === mg[1]); const S = STRIP()[mg[1]]; + if (!g || !S) { res.writeHead(302, { Location: '/my#games', 'Cache-Control': 'no-store' }); return res.end(); } + const from = String(u.searchParams.get('from') || '').toLowerCase().replace(/[^a-z]/g, '').slice(0, 20); const src = STRIP()[from]; + traffic.hit('/g/' + g.slug, req.headers.referer || (src ? 'https://' + src.host + '/' : ''), req.headers['user-agent']); // Traffic tab: host = sending game, path g/ + const s = await auth.fromRequest(req); + res.writeHead(302, { Location: (s && s.email) ? g.play : S.open, 'Cache-Control': 'no-store' }); return res.end(); // signed in here: straight into the game, signed in + } } +""" +edit('server.js', [ + ("// -- PassiveDrip hand-off (2026-10-01): same token shape as Drip Runner", HELP + "// -- PassiveDrip hand-off (2026-10-01): same token shape as Drip Runner"), + (" // -- Games hub (2026-10-01): the registry is here, the live list is site config (gamesLive)\n", ROUTES + " // -- Games hub (2026-10-01): the registry is here, the live list is site config (gamesLive)\n"), + ("pays: 'POL to your wallet at 0.25', progress: drProgress }", "pays: 'POL to your wallet at 0.10', progress: drProgress }"), +]) +print('ok')