// Shared page helpers (VAB namespace, modelled on VBB / Downline Banners common.js): nav, the royal ticker, verified visits, // ad cards, the shared SVG bits of the daylight look (mark, network lines, green checks), footer (legal, company line, the network line from the hub), network ad zones and toasts of real events. window.VAB = (function () { let cfgP = null, vt = 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; } })(); const n = x => Number(x || 0).toLocaleString('en-US'); 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 + ')'; j._status = r.status; return j; } const post = (url, body) => getJSON(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }); // the daylight look's shared SVG bits const MARK = ''; const NETLINES = ''; const CHECK = ''; function renderNav(active) { const nav = document.createElement('nav'); nav.className = 'top'; const links = [['/#board', 'Top ads'], ['/how', 'How it works'], ['/my', 'My page'], ['/boost', 'Boost'], ['/ledger', 'Ledger'], ['/contract', 'Contract'], ['/promote', 'Promote']]; nav.innerHTML = '
' + MARK + 'VIRALADBLITZ' + 'Post my free text ad
'; document.body.prepend(nav); const tk = document.createElement('div'); tk.className = 'ticker'; tk.id = 'ticker'; tk.setAttribute('aria-label', 'Live ticker of the newest text ads'); tk.innerHTML = 'Loading the wire...'; nav.after(tk); if (framed) document.querySelectorAll('a[href="/my"]').forEach(a => { a.target = '_blank'; a.rel = 'noopener'; }); } // a link through the click relay: placement + the visitor's verified token once their visit has verified const goHref = (id, p) => '/go/' + id + '?p=' + encodeURIComponent(p || 'site') + (vt ? '&v=' + vt : ''); function decorate() { document.querySelectorAll('a[data-go]').forEach(a => { a.href = goHref(a.dataset.go, a.dataset.p); }); } function renderTicker(items) { const el = $('ticker'); if (!el) return; if (!items || !items.length) { el.innerHTML = 'The wire is quiet. Post the first text ad.'; return; } const one = items.map(t => '' + (t.boosted ? '★ BOOSTED ' : '▲ LIVE ') + esc(t.headline) + ' · ' + esc(t.owner) + '').join(''); const reps = Math.max(1, Math.ceil(8 / items.length)); el.innerHTML = '
' + one.repeat(reps) + one.repeat(reps) + '
'; } // a white clipped card for a text ad (front board, member page Boosted places); right = a small figure (verified clicks) function paper(t, tag, place, right) { const lab = (t.boosted ? '★ BOOSTED' + (tag ? ' · ' : '') : '') + (tag || ''); return '
' + (lab || right ? '
' + esc(lab) + '' + (right ? '' + esc(right) + '' : '') + '
' : '') + '

' + esc(t.headline) + '

' + esc(t.line1) + (t.line2 ? ' ' + esc(t.line2) : '') + '

' + '
Visit ' + esc(t.host) + '' + esc(t.owner) + '
'; } // the page's data and its verified visit: the ads come with a ticket; after visitSeconds of the page being visible the // visit is sent once, and from then on clicks carry the verified token async function wire(page, u) { const src = document.referrer || ''; // a PolHunter hunter (?ph= / #ph= token, or the token PolHunter's embed keeps for this tab) is paid to visit: never a verified view let hunt = /[?&#]ph=/.test(location.search + location.hash); try { hunt = hunt || !!sessionStorage.getItem('ph.token'); } catch (e) {} const d = await getJSON('/api/wire?page=' + encodeURIComponent(page) + (u ? '&u=' + encodeURIComponent(u) : '') + (src ? '&src=' + encodeURIComponent(src) : '') + (hunt ? '&hunt=1' : '')); renderTicker(d.ticker || []); if (d.ticket) { const need = (d.seconds || 6) * 1000; let seen = 0, last = Date.now(), sent = false; const step = async () => { const now = Date.now(); if (document.visibilityState === 'visible') seen += now - last; last = now; if (!sent && seen >= need) { sent = true; clearInterval(iv); const r = await post('/api/visit/seen', { ticket: d.ticket, visibleMs: seen }).catch(() => ({})); if (r.vt) { vt = r.vt; decorate(); } document.dispatchEvent(new CustomEvent('vab:verified', { detail: r })); } }; const iv = setInterval(step, 500); document.addEventListener('visibilitychange', () => { last = Date.now(); }); } return d; } // network ad zones (LinkSpin zones on Marty's account for viraladblitz.com, the VBB pattern; made 2026-11-15 through the admin // zone route): footer wide 728x90, footer phone 320x50, ledger 468x60, Boost page 300x250, My page 468x60; 404 in server.js. const ZONES = { footWide: 'ls-766b4a', footPhone: 'ls-66e157', ledger: 'ls-a5c68c', boost: 'ls-754307', my: 'ls-f880d2' }; 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 pageZones() { const p = location.pathname.replace(/\/$/, '') || '/'; if (p === '/admin') return; const after = (el, key) => { if (!el || !el.parentNode) return; const d = document.createElement('div'); el.parentNode.insertBefore(d, el.nextSibling); zone(d, key); }; if (p === '/ledger') after($('rows') && $('rows').closest('section'), 'ledger'); if (p === '/boost') after(document.querySelector('main section'), 'boost'); if (p === '/my') after($('dash'), 'my'); const za = document.createElement('div'); za.className = 'wrap'; document.body.appendChild(za); zone(za, window.innerWidth >= 760 ? 'footWide' : 'footPhone'); } 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'], ['viraladblitz', 'ViralAdBlitz', 'https://viraladblitz.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 === 'viraladblitz' || /viraladblitz\.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.some(s => s.id === 'viraladblitz') ? l : l.concat([NET[4]])); }).catch(() => {}); } function renderFooter() { pageZones(); const f = document.createElement('footer'); f.className = 'foot'; f.innerHTML = '

ViralAdBlitz, the network\'s text ad wire

' + '

A Boost buys advertising, not income. Nothing is promised.

' + '

Front page · How it works · My page · Boost · Promote

' + '' + '

TrustClickz · 615 Green Valley Drive, Moody, AL 35004

'; document.body.appendChild(f); netLine(f.querySelector('.netline')); toasts(); } // live toasts: real new ads and Boosts 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 show = c => { const el = document.createElement('a'); el.className = 'toast' + (c.kind === 'boost' ? ' gold' : ''); if (c.kind === 'boost') { el.href = '/ledger'; el.innerHTML = '' + (c.name ? '@' + esc(c.name) : 'A member') + ' just boosted an ad
' + (c.levels ? (c.levels === 1 ? '1 sponsor' : c.levels + ' sponsors') + ' paid in the same transaction' : 'paid on-chain, split by the contract') + ''; } else { el.href = '/'; el.innerHTML = '' + (c.name ? '@' + esc(c.name) : 'A member') + ' posted a new text ad
' + esc(c.headline) + ''; } box.appendChild(el); requestAnimationFrame(() => el.classList.add('in')); setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000); }; const tick = async () => { const d = await getJSON('/api/recent').catch(() => null); const all = (d && d.items) || []; 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); } const polOf = (w, d) => { try { const k = BigInt(w || 0); const v = Number(k / 10n ** 12n) / 1e6; return v.toFixed(d != null ? d : (v >= 100 ? 2 : 4)); } catch (e) { return '0'; } }; const when = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : ''; return { MARK, NETLINES, CHECK, $, esc, getConfig, short, framed, status, getJSON, post, n, renderNav, renderFooter, renderTicker, paper, wire, decorate, goHref, polOf, when }; })();