// Shared page helpers (VBB namespace, modelled on Downline Banners' common.js): nav, footer, toasts, fetch helpers. window.VBB = (function () { let cfgP = null; const $ = id => document.getElementById(id); const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json())); const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : ''; const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })(); function status(msg, cls) { const el = $('status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; } async function getJSON(url, opts) { const r = await fetch(url, opts); let j = {}; try { j = await r.json(); } catch (e) {} if (!r.ok && !j.error) j.error = 'Request failed (' + r.status + ')'; return j; } const post = (url, body) => getJSON(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }); const n = x => Number(x || 0).toLocaleString('en-US'); function renderNav(active) { const nav = document.createElement('nav'); nav.className = 'top'; const links = [['/', 'The loop'], ['/leaders', 'Leaderboards'], ['/how', 'How it works'], ['/packages', 'Packages'], ['/promote', 'Promote'], ['/my', 'My Banners']]; nav.innerHTML = '
Viral Banner Blitz' + 'Part of the Crypto Team Build Network
'; document.body.prepend(nav); // inside a traffic-exchange frame, the member page opens in a new tab if (framed) document.querySelectorAll('nav a[href="/my"]').forEach(a => { a.target = '_blank'; a.rel = 'noopener'; }); } // network ad zones (Marty 2026-11-14, the Downline Banners pattern): LinkSpin zones on Marty's account, one per placement, each // mounted once with a small 'Network' label. Footer (wide / phone), Leaderboards, My Banners, How it works; the 404 zone is in // server.js. NEVER on the loop page (/) or admin. An empty id = that placement stays off. const ZONES = { footWide: '', footPhone: '', leaders: '', my: '', how: '' }; function zone(el, key) { if (!el || el.dataset.zoned || !ZONES[key]) return; el.dataset.zoned = '1'; el.classList.add('net-zone'); const lab = document.createElement('div'); lab.className = 'net-zone-label'; lab.textContent = 'Network'; const s = document.createElement('script'); s.async = true; s.src = 'https://linkspin.app/z.js'; s.setAttribute('data-zone', ZONES[key]); el.appendChild(lab); el.appendChild(s); } function slot(after) { if (!after || !after.parentNode) return null; const d = document.createElement('div'); d.className = 'net-zone-slot'; after.parentNode.insertBefore(d, after.nextSibling); return d; } function pageZones() { const p = location.pathname.replace(/\/$/, '') || '/'; if (p === '/' || p === '/admin') return; const card = id => { const el = $(id); return el ? el.closest('.card') : null; }; if (p === '/leaders') zone(slot(card('lbVisitors')), 'leaders'); if (p === '/my') zone(slot($('stats')), 'my'); if (p === '/how') zone(slot(document.querySelectorAll('main .card')[1]), 'how'); const za = document.createElement('div'); za.className = 'wrap net-zone-foot'; document.body.appendChild(za); zone(za, window.innerWidth >= 760 ? 'footWide' : 'footPhone'); } function renderFooter() { pageZones(); const f = document.createElement('footer'); f.className = 'foot'; f.innerHTML = '

Viral Banner Blitz, part of the Crypto Team Build Network

' + '

A banner that cycles earns advertising across the network, not cash. Nothing here is an income opportunity.

' + '

The loop · Leaderboards · How it works · Packages · Promote · My Banners

' // trust pack (Marty 2026-11-14): legal + proof links, company line, and the network line served by the hub + '' + '

TrustClickz · 615 Green Valley Drive, Moody, AL 35004

'; document.body.appendChild(f); netLine(f.querySelector('.netline')); toasts(); } // "Part of the network": the list comes from the hub through /api/network-sites, the built-in copy if it does not answer const NET = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'], ['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] })); function netLine(el) { if (!el) return; const paint = list => { el.innerHTML = 'Part of the network · One account across the network: ' + list.map(s => (s.id === 'vbb' || /viralbannerblitz\.com/.test(s.url)) ? '' + esc(s.name) + '' : '' + esc(s.name) + '').join(' · '); }; paint(NET); fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) paint(l); }).catch(() => {}); } // live toasts: real cycles, purchases and prize payouts only, bottom-left, one at a time, never older than 30 minutes let toastsOn = false; function toasts() { if (toastsOn) return; toastsOn = true; const seen = new Set(); let first = true; const box = document.createElement('div'); box.className = 'toasts'; box.setAttribute('aria-live', 'polite'); document.body.appendChild(box); const polOf = w => { try { const v = Number(BigInt(w || 0) / 10n ** 14n) / 1e4; return v.toFixed(v >= 100 ? 2 : 4); } catch (e) { return '0'; } }; const whoOf = (a, nm) => nm ? '@' + esc(nm) : esc(short(String(a || ''))); const show = c => { const el = document.createElement('a'); el.className = 'toast'; if (c.kind === 'purchase') { // trust pack 2026-11-14: real purchases from the ledger, with the sponsor paid in the same transaction const sp = (c.pays || []).find(p => p.role === 'sponsor' && !p.failed); el.href = '/ledger'; el.className = 'toast buy'; el.innerHTML = '' + whoOf(c.buyer, c.buyerName) + ' bought ' + esc(c.what) + '
' + (sp ? whoOf(sp.to, sp.name) + ' got ' + polOf(sp.wei) + ' POL, same transaction' : 'paid on-chain, split by the contract') + ''; } else if (c.kind === 'prize') { el.href = '/ledger'; el.className = 'toast prize'; el.innerHTML = '' + esc(c.name) + ' won a weekly prize
' + esc(c.pol) + ' POL paid on-chain'; } else { el.href = '/how'; el.innerHTML = '' + (c.name ? esc(c.name) + '\'s banner' : 'A banner') + ' just cycled
' + n(c.views) + ' network ad views earned for its owner'; } box.appendChild(el); requestAnimationFrame(() => el.classList.add('in')); setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000); }; const tick = async () => { const [d, l] = await Promise.all([getJSON('/api/recent').catch(() => null), getJSON('/api/ledger?n=6').catch(() => null)]); const all = []; ((d && d.cycles) || []).forEach(c => all.push(Object.assign({ key: 'c' + c.id }, c))); ((l && l.items) || []).filter(x => x.at && Date.now() - x.at < 30 * 60000).forEach(x => all.push(Object.assign({ key: x.kind + x.tx + (x.place || '') + (x.board || '') }, x))); all.sort((a, b) => (b.at || 0) - (a.at || 0)); const fresh = all.filter(c => !seen.has(c.key)); all.forEach(c => seen.add(c.key)); const list = first ? fresh.slice(0, 1) : fresh.reverse(); first = false; list.slice(0, 3).forEach((c, i) => setTimeout(() => show(c), 1500 + i * 8000)); }; tick(); setInterval(tick, 25000); } function tile(t, extra) { const a = document.createElement('a'); a.className = 'tile' + (t.look ? ' look' : '') + (t.t === 'spin' ? ' fill' : '') + (extra && extra.cls ? ' ' + extra.cls : ''); if (t.t === 'spin') a.title = (t.owner ? t.owner + ': ' : '') + 'LinkSpin Banner Spin (fills an open place, not in the loop)'; a.href = t.href; a.target = '_blank'; a.rel = 'noopener'; a.innerHTML = '' + esc(t.t === 'spin' ? 'LinkSpin Banner Spin' + (t.owner ? ' by ' + t.owner : '') : t.owner ? 'Banner by ' + t.owner : 'Member banner #' + t.id) + '' + (extra && extra.pos ? '' + esc(extra.pos) + '' : '') + (t.owner ? '' + esc(t.owner) + '' : ''); if (t.look && t.teaser) { const s = document.createElement('span'); s.className = 'teaser'; s.textContent = t.teaser; a.appendChild(s); a.title = t.teaser; } const img = a.querySelector('img'); img.src = t.img; img.onerror = () => { img.onerror = null; img.src = '/art/tile-fallback.svg'; }; return a; } return { $, esc, getConfig, short, framed, status, getJSON, post, n, renderNav, renderFooter, tile }; })();