// Fuel Your Offers (2026-10-24), LinkSpin: the Monthly Refuel panel on Credits and Ads. The streak lives on InstantAdPay // and is shared by both sites; /api/my/refuel relays InstantAdPay's view. Hidden while the refuelStreak switch is off. (function () { const $ = id => document.getElementById(id); const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); const n = v => Number(v || 0).toLocaleString('en-US'); window.FUEL = window.FUEL || {}; function site(name, s, minUsd) { return s && s.refueled ? '
' + name + '+' + s.pct + '% · ' + n(s.bonus) + ' credits
' : '
' + name + 'not yet ($' + minUsd + '+ counts)
'; } function body(v) { if (v.error) return '

' + esc(v.error) + '

'; if (!v.active) { return '

' + (v.started ? 'Your last streak ended. ' : '') + 'A package of $' + v.minUsd.linkspin + ' or more here, or $' + v.minUsd.iap + '+ on InstantAdPay, ' + (v.started ? 'starts it again' : 'starts your monthly refuel streak and sets your own refuel day') + '.

' + '

Bonus ad credits: month 1 +' + v.ladder.single[0] + '%, then +' + v.ladder.single.slice(1).join('%, +') + '%. Refuel both sites in the same cycle and each gets +' + v.ladder.both.join('%, +') + '%.

' + 'Start my streak'; } const c = v.cycle || {}; let h = v.windowOpen ? '

Your refuel window is open. Refuel day ' + esc(v.refuelDayLabel) + ', grace to ' + esc(v.graceLabel) + ' (Central). Next refuel: +' + v.next.single + '%, or +' + v.next.both + '% on each site with both.

' : '

Next refuel day ' + esc(v.refuelDayLabel) + ' (Central). Window opens ' + esc(v.opensLabel) + ', grace to ' + esc(v.graceLabel) + '.

'; if (c.month) h += '
' + site('InstantAdPay', c.iap, v.minUsd.iap) + site('LinkSpin', c.linkspin, v.minUsd.linkspin) + '
'; if (!v.windowOpen && c.month && !c.both) h += '

Refuel ' + (c.linkspin && c.linkspin.refueled ? 'InstantAdPay ($' + v.minUsd.iap + '+)' : 'LinkSpin ($' + v.minUsd.linkspin + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to +' + v.next.secondEngine + '%.

'; if (v.pitStop && (v.pitStop.linkspin || v.pitStop.usedLinkspin)) h += '

Pit Stop ' + (v.pitStop.linkspin ? 'available here: +' + v.pitStop.pct + '% on a $' + v.minUsd.linkspin + '+ top-up, once this cycle. It does not count as your refuel.' : 'used here this cycle.') + '

'; h += '

' + (v.freeMiss.available ? 'One free miss left this year.' : 'Free miss for this year used.') + '

'; return h + '' + (v.windowOpen ? 'Refuel now' : 'Buy a package') + ''; } async function load() { const panel = $('rfPanel'); if (!panel) return; try { const v = await (await fetch('/api/my/refuel', { cache: 'no-store' })).json(); window.FUEL.refuel = v; if (!v || !v.on) { panel.hidden = true; return; } $('rfMeta').textContent = v.active ? 'streak: ' + v.streak + ' month' + (v.streak === 1 ? '' : 's') : 'shared with InstantAdPay'; $('rfBody').innerHTML = body(v); panel.hidden = false; } catch (e) { panel.hidden = true; } } window.FUEL.loadRefuel = load; load(); setInterval(load, 300000); // ---- the Refuel Kit: members-only LinkSpin banners with your @name and a QR to your link ---- const post = async (url, body) => { const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }); const j = await r.json().catch(() => ({})); if (!r.ok || j.error) throw new Error(j.error || ('HTTP ' + r.status)); return j; }; const note = (el, m) => { if (el) el.textContent = m; }; function kitHtml(k, d) { const head = '
' + esc(k.label) + (k.theme ? ' · ' + esc(k.theme) : '') + '' + (k.unlocked ? 'yours' : 'locked') + '
'; if (!k.unlocked) return head + '

Your next counted refuel unlocks it: $25+ here or $20+ on InstantAdPay' + (d.nextRefuel ? ' (refuel day ' + esc(d.nextRefuel) + ')' : '') + '.

'; return head + '

Your ' + esc(d.name || 'name') + ' and a QR to your link on every banner. Yours to keep after the month.

' + '
' + (k.gif ? '' : '') + '
' + '
' + '
' + k.sizes.filter(s => s.ready).map(s => '
' + '
' + s.size + '
').join('') + '
'; } async function loadKits() { const panel = $('rkPanel'); if (!panel) return; try { const d = await (await fetch('/api/my/kits', { cache: 'no-store' })).json(); if (!d || !d.on || !d.kits || !d.kits.length) { panel.hidden = true; return; } $('rkBody').innerHTML = d.kits.slice(0, 3).map(k => '
' + kitHtml(k, d) + '
').join('') + (d.customNote ? '

Custom banners credit: ' + esc(d.customNote) + '

' : '') + '

Ad credits buy delivery only. No banner may promise income.

'; panel.hidden = false; panel.querySelectorAll('[data-kbs]').forEach(b => b.addEventListener('click', async () => { const m = b.dataset.kbs; const out = panel.querySelector('[data-kres="' + m + '"]'); const g = panel.querySelector('[data-kgif="' + m + '"]'); b.disabled = true; note(out, 'Drawing your banners and loading them...'); try { const r = await post('/api/my/kits/bannerspin', { month: m, variant: g && g.checked ? 'gif' : 'still' }); note(out, r.results.map(x => x.size + ': ' + (x.error ? x.error : x.already ? 'already in "' + x.spin + '"' : (x.created ? 'new Banner Spin "' : 'added to "') + x.spin + '"')).join(' | ') + ' (see Banner Spin under Links)'); } catch (e) { note(out, e.message); } b.disabled = false; })); panel.querySelectorAll('[data-kmake]').forEach(b => b.addEventListener('click', async () => { const cell = b.closest('[data-kcell]'); b.disabled = true; try { const g = panel.querySelector('[data-kgif="' + cell.dataset.month + '"]'); const r = await post('/api/my/kits/render', { month: cell.dataset.month, size: cell.dataset.size, variant: g && g.checked && cell.dataset.size !== '1200x630' ? 'gif' : 'still' }); cell.querySelector('[data-kimg]').innerHTML = 'Your ' + esc(r.size) + ' Refuel Kit banner
Download
'; const c = cell.querySelector('[data-kcopy]'); c.addEventListener('click', () => { try { navigator.clipboard.writeText(c.dataset.kcopy); c.textContent = 'Copied'; } catch (e) {} }); } catch (e) { cell.querySelector('[data-kimg]').textContent = e.message; } b.disabled = false; })); } catch (e) { panel.hidden = true; } } window.FUEL.loadKits = loadKits; loadKits(); })();