Refuel Kit on LinkSpin (Fuel Your Offers stage 3, Marty approved 2026-10-24): kit.js (same file as InstantAdPay) with LinkSpin's own art, entitlement from InstantAdPay's streak record through refuel.status (view.kits: month -> streak month at unlock). Ads screen Refuel Kit panel (fuel.js?v=20261024kit): Make mine, Download, Copy image link, animated at a 3-month streak, and "Load into my Banner Spin" (kitspin.js): each Banner Spin size in the kit goes into one of the member's Banner Spins of that size with room, or a new one while the tier allows (the reason is shown when it does not); the personalized file is copied into uploads like a normal Banner Spin upload, labelled "Refuel Kit <month>", target = the member's own link; loading twice adds nothing twice; files over 150 KB are refused plainly. /kitimg/<hmac> public serving, admin Settings > Refuel Kit (upload, placeholder art, preview, release), raster copies of the LinkSpin placeholder banners (public/banners/linkspin-<size>.png, from the existing SVGs) for the placeholder kit. Behind the refuelStreak switch. Chatbot CANNED + FACTS mention the kit. qa/refuel-kit.test.cjs 5 checks against the real bannerspin.js. Note: qa kb retrieval has 2 pre-existing misses (spin links vs Banner Spin, PropellerAds postback), same before this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-24 05:44:40 -05:00
parent 7bcde25116
commit 4749d711f4
14 changed files with 473 additions and 6 deletions
+45
View File
@@ -38,4 +38,49 @@
}
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 = '<div style="display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap"><b>' + esc(k.label) + (k.theme ? ' &middot; ' + esc(k.theme) : '') + '</b><span class="muted">' + (k.unlocked ? 'yours' : 'locked') + '</span></div>';
if (!k.unlocked) return head + '<p class="muted" style="margin:6px 0 0">Your next counted refuel unlocks it: $25+ here or $20+ on InstantAdPay' + (d.nextRefuel ? ' (refuel day ' + esc(d.nextRefuel) + ')' : '') + '.</p>';
return head + '<p class="muted" style="margin:6px 0">Your ' + esc(d.name || 'name') + ' and a QR to your link on every banner. Yours to keep after the month.</p>'
+ '<div style="display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px"><button class="btn pri" type="button" data-kbs="' + esc(k.month) + '">Load into my Banner Spin</button>'
+ (k.gif ? '<label class="muted" style="display:flex;gap:4px;align-items:center"><input type="checkbox" data-kgif="' + esc(k.month) + '"> animated</label>' : '') + '</div>'
+ '<div class="muted" data-kres="' + esc(k.month) + '" role="status"></div>'
+ '<div style="display:grid;gap:8px">' + k.sizes.filter(s => s.ready).map(s => '<div data-kcell data-month="' + esc(k.month) + '" data-size="' + s.size + '" style="border:1px solid var(--line);border-radius:6px;padding:8px;min-width:0">'
+ '<div style="display:flex;justify-content:space-between;gap:6px;align-items:center"><span class="mono" style="font-size:11px">' + s.size + '</span><button class="btn" type="button" data-kmake>Make mine</button></div><div data-kimg style="margin-top:6px"></div></div>').join('') + '</div>';
}
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 => '<div style="margin-bottom:14px">' + kitHtml(k, d) + '</div>').join('')
+ (d.customNote ? '<p class="muted"><b>Custom banners credit:</b> ' + esc(d.customNote) + '</p>' : '') + '<p class="muted" style="margin:0">Ad credits buy delivery only. No banner may promise income.</p>';
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 = '<img src="' + esc(r.url) + '" alt="Your ' + esc(r.size) + ' Refuel Kit banner" style="max-width:100%;height:auto;display:block"><div style="display:flex;gap:6px;flex-wrap:wrap;margin-top:6px"><a class="btn" href="' + esc(r.url) + '" download>Download</a><button class="btn" type="button" data-kcopy="' + esc(r.abs) + '">Copy image link</button></div>';
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();
})();