// Fuel Your Offers (2026-10-24): the Refuel card on the Overview. Hidden while the refuelStreak switch is off // (/api/my/refuel answers { on:false }). Everything here is ad credits, never cash. (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'); const goBuy = () => { const m = document.querySelector('.bo-menu [data-pane="buy"]'); if (m) m.click(); else location.hash = '#buy'; }; window.FUEL = window.FUEL || {}; const HOW = '

How the Refuel streak works

'; // the member guide (2026-10-24) function siteLine(name, s, minUsd) { if (s && s.refueled) return '
  • ' + name + ': refueled ' + esc(s.dayLabel ? 'on ' + s.dayLabel : '') + ', +' + s.pct + '% (' + n(s.bonus) + ' bonus credits)
  • '; return '
  • ' + name + ': not yet this cycle (a $' + minUsd + '+ package counts)
  • '; } function cardHtml(v) { const head = '

    ⛽ Monthly Refuel

    ' + (v.active ? 'streak: ' + v.streak + ' month' + (v.streak === 1 ? '' : 's') : 'not started') + '
    '; if (!v.active) { const lapsed = v.started ? '

    Your last streak ended' + (v.misses && v.misses[0] ? ' after ' + esc(v.misses[0].day) : '') + '. Your next package of $' + v.minUsd.iap + '+ here (or $' + v.minUsd.linkspin + '+ on LinkSpin) starts it again at month 1.

    ' : ''; return head + (lapsed || '

    Refuel your ads every month and the bonus grows. A package of $' + v.minUsd.iap + ' or more here, or $' + v.minUsd.linkspin + ' or more on LinkSpin, starts your streak and sets your own refuel day.

    ') + '

    Month 1 +' + v.ladder.single[0] + '% bonus ad credits, month 2 +' + v.ladder.single[1] + '%, month 3 +' + v.ladder.single[2] + '%, month 4 and up +' + v.ladder.single[3] + '%. Refuel both InstantAdPay and LinkSpin in the same cycle and each gets +' + v.ladder.both.join('%, +') + '%. It stacks on Five Dollar Friday and Wired Wednesday.

    ' + '' + HOW; } const c = v.cycle || {}; const when = v.windowOpen ? '

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

    ' : '

    Next refuel day: ' + esc(v.refuelDayLabel) + ' (Central time). The window opens ' + esc(v.opensLabel) + ' and the grace runs to ' + esc(v.graceLabel) + '.

    '; const sites = c.month ? '

    This cycle (month ' + c.month + (c.both ? ', both engines' : '') + '):

    ' : ''; let twin = ''; if (!v.windowOpen && c.month && !c.both) twin = '

    Refuel ' + (c.iap && c.iap.refueled ? 'LinkSpin ($' + v.minUsd.linkspin + '+)' : 'InstantAdPay ($' + v.minUsd.iap + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to +' + v.next.secondEngine + '%; the one you already refueled is topped up to match.' // the second engine is on the other site: a direct way there (2026-10-25), landing on LinkSpin's Refuel panel with an arrival strip + (c.iap && c.iap.refueled ? ' Refuel LinkSpin ↗ (same email signs you in)' : '') + '

    '; let pit = ''; if (v.pitStop) { const here = v.pitStop.iap ? 'available here (+' + v.pitStop.pct + '% on a $' + v.minUsd.iap + '+ top-up, once this cycle)' : v.pitStop.usedIap ? 'used here this cycle' : null; if (here) pit = '

    Pit Stop: ' + here + '. It keeps your ads running between refuel days; it does not count as your refuel.

    '; } const miss = '

    ' + (v.freeMiss.available ? 'You have one free miss this year: if a grace passes, your streak is kept once.' : 'Your free miss for this year is used.') + (v.best > v.streak ? ' Best streak: ' + v.best + ' months.' : '') + '

    '; return head + when + sites + twin + pit + miss + '' + HOW; } async function loadRefuelCard() { const card = $('rfCard'); if (!card) return; try { const v = await (await fetch('/api/my/refuel', { cache: 'no-store' })).json(); window.FUEL.refuel = v; if (!v || !v.on) { card.hidden = true; return; } card.innerHTML = cardHtml(v); card.hidden = false; card.querySelectorAll('[data-fuel-buy]').forEach(b => b.addEventListener('click', goBuy)); } catch (e) { card.hidden = true; } } window.FUEL.loadRefuelCard = loadRefuelCard; loadRefuelCard(); setInterval(loadRefuelCard, 300000); // ---- the Refuel Kit (Promo tools): this month's members-only banners, with your @name and a QR to your link ---- const say = (m, k) => { try { IAP.status(m, k); } catch (e) {} }; const IAP_SIZES = ['728x90', '300x250', '468x60', '160x600']; let kitData = null; async function render(month, size, variant) { const r = await (await fetch('/api/my/kits/render', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ month, size, variant }) })).json(); if (r.error) throw new Error(r.error); return r; } // prefill the banner form under Campaigns with the kit image and the member's own link function useInCampaign(r, month) { const m = document.querySelector('.bo-menu [data-pane="campaigns"]'); if (m) m.click(); setTimeout(() => { const set = (id, v, ev) => { const el = $(id); if (!el) return; el.value = v; el.dispatchEvent(new Event(ev || 'input', { bubbles: true })); }; set('cType', 'banner', 'change'); set('cSize', r.size, 'change'); set('cName', 'Refuel Kit ' + month + ' ' + r.size); set('cImage', r.abs); if (kitData && kitData.link) set('cTarget', kitData.link); const el = $('cName'); if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' }); say('Banner form filled with your kit banner and your link. Set a budget and launch.', 'ok'); }, 250); } function kitHtml(k, d) { const head = '

    Refuel Kit: ' + esc(k.label) + (k.theme ? ' · ' + esc(k.theme) : '') + '

    ' + (k.unlocked ? 'yours' : 'locked') + '
    '; if (!k.unlocked) return head + '

    Members-only banners for ' + esc(k.label) + '. Your next counted refuel unlocks them: a package of $20+ here, or $25+ on LinkSpin' + (d.nextRefuel ? ' (your refuel day: ' + esc(d.nextRefuel) + ')' : '') + '.

    '; return head + '

    Five banners with your ' + esc(d.name || 'name') + ' and a QR code to your own link drawn on each one. They stay yours after the month ends.' + (k.gif ? ' Your streak also unlocks the animated version.' : '') + '

    ' + '
    ' + k.sizes.filter(s => s.ready).map(s => '
    ' + '
    ' + s.size + (s.size === '1200x630' ? ' (social posts)' : '') + '
    ' + '
    ' + (k.gif && s.size !== '1200x630' ? '' : '') + '
    ').join('') + '
    '; } function cellReady(cell, r, month) { const box = cell.querySelector('.kit-img'); box.innerHTML = 'Your ' + esc(r.size) + ' Refuel Kit banner' + '
    Download' + '' + (IAP_SIZES.includes(r.size) ? '' : '') + '
    '; box.querySelector('[data-kit="copy"]').addEventListener('click', () => { try { navigator.clipboard.writeText(r.abs); say('Image link copied.', 'ok'); } catch (e) { say(r.abs); } }); const u = box.querySelector('[data-kit="use"]'); if (u) u.addEventListener('click', () => useInCampaign(r, month)); } async function loadKitCard() { const card = $('rkCard'); if (!card) return; try { const d = await (await fetch('/api/my/kits', { cache: 'no-store' })).json(); kitData = d; if (!d || !d.on || !d.kits || !d.kits.length) { card.hidden = true; return; } card.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.

    '; card.hidden = false; card.querySelectorAll('.kit-cell button[data-kit]').forEach(b => b.addEventListener('click', async () => { const cell = b.closest('.kit-cell'); b.disabled = true; const was = b.textContent; b.textContent = 'Drawing your banner...'; try { cellReady(cell, await render(cell.dataset.month, cell.dataset.size, b.dataset.kit === 'gif' ? 'gif' : 'still'), cell.dataset.month); } catch (e) { say(e.message, 'err'); } b.disabled = false; b.textContent = was; })); } catch (e) { card.hidden = true; } } window.FUEL.loadKitCard = loadKitCard; loadKitCard(); })();