Compare commits
31 Commits
aee1ccc36a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| afb367cafc | |||
| f3aabd75aa | |||
| 5d34997287 | |||
| 756a25068d | |||
| c4ec646bdf | |||
| 3e0dee517d | |||
| 7b973edcf8 | |||
| b93b66f585 | |||
| 3e59eca250 | |||
| 7c68faded5 | |||
| e5595bdf4a | |||
| fb45fcddca | |||
| 43e8dac257 | |||
| ef79fcc461 | |||
| 8e6d2f9cd0 | |||
| 666cdd9569 | |||
| 4ea6e038e1 | |||
| 484f4a0242 | |||
| 9e5b30c744 | |||
| 5afde38f6f | |||
| d759d1f67d | |||
| 6798503c1f | |||
| 47cb360204 | |||
| 909f4373d8 | |||
| cab68c01dd | |||
| 636ebb56bd | |||
| 86a84b9606 | |||
| 89f79f934b | |||
| 2f58a41af5 | |||
| 2fe3d9e4c0 | |||
| d049c529ac |
@@ -0,0 +1,37 @@
|
|||||||
|
// Live SKU values from the shop contract (Marty 2026-11-17, Network Weekend): every page, pack card and the chatbot show what the
|
||||||
|
// contract will really credit, so a late or early owner setSku never shows a wrong number. skus(sku) is read over CHAIN_RPC every
|
||||||
|
// 60 s in the background (never on a request); until the first read answers, or if the RPC is down, the env values stand.
|
||||||
|
// The crediting itself never depends on this: the watcher credits the Purchase event's own credits (shop.js apply).
|
||||||
|
'use strict';
|
||||||
|
const { Interface } = require('ethers');
|
||||||
|
const IFACE = new Interface(['function skus(uint256) view returns (uint64 usdCents, uint64 units, bool active)']);
|
||||||
|
const TTL = 60 * 1000;
|
||||||
|
let C = null, ids = [], live = new Map(), at = 0, timer = null, inflight = null;
|
||||||
|
async function read(sku) {
|
||||||
|
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 8000); t.unref && t.unref();
|
||||||
|
try {
|
||||||
|
const j = await (await fetch(C.chainRpc, { method: 'POST', headers: { 'Content-Type': 'application/json' }, signal: ac.signal,
|
||||||
|
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'eth_call', params: [{ to: C.contractAddress, data: IFACE.encodeFunctionData('skus', [sku]) }, 'latest'] }) })).json();
|
||||||
|
if (j.error || !j.result || j.result === '0x') throw new Error('skus(' + sku + ') ' + (j.error ? j.error.message : 'empty'));
|
||||||
|
const r = IFACE.decodeFunctionResult('skus', j.result);
|
||||||
|
return { usdCents: Number(r[0]), units: Number(r[1]), active: !!r[2] };
|
||||||
|
} finally { clearTimeout(t); }
|
||||||
|
}
|
||||||
|
function refresh() {
|
||||||
|
if (inflight || !C || !C.contractAddress || !C.chainRpc) return inflight || Promise.resolve();
|
||||||
|
inflight = Promise.all(ids.map(async s => { try { live.set(s, await read(s)); } catch (e) {} })).then(() => { at = Date.now(); }).finally(() => { inflight = null; });
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
function init(cfg, skuIds) {
|
||||||
|
C = cfg; ids = (skuIds || []).filter(n => Number.isSafeInteger(n) && n > 0);
|
||||||
|
if (timer) clearInterval(timer);
|
||||||
|
if (C.contractAddress && C.chainRpc && ids.length) { refresh(); timer = setInterval(refresh, TTL); timer.unref && timer.unref(); }
|
||||||
|
}
|
||||||
|
// { usdCents, units, active } as the contract holds it, or null (not read yet / RPC down)
|
||||||
|
function get(sku) { return live.get(Number(sku)) || null; }
|
||||||
|
// VBB: the credit packs as the contract holds them right now; the env values (CREDIT_PACKS) until the first read answers
|
||||||
|
function packs(C) {
|
||||||
|
return C.packs.map(p => { const l = get(p.sku); return l && l.active && l.units > 0 && l.usdCents > 0 ? { credits: l.units, usd: l.usdCents / 100, sku: p.sku } : p; });
|
||||||
|
}
|
||||||
|
function lookUsd(C) { const l = get(C.lookSku); return l && l.active && l.usdCents > 0 ? l.usdCents / 100 : C.lookUsd; }
|
||||||
|
module.exports = { init, get, packs, lookUsd, refresh, _set: (sku, v) => live.set(Number(sku), v), _clear: () => live.clear(), _state: () => ({ at, n: live.size }) };
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
// Viral Banner Blitz's site assistant (Marty 2026-11-15): what it knows. The engine is chatcore.js (the same on every rebuilt
|
||||||
|
// site); retrieval also covers the other network sites through the hub (netkb.js), this site's entries first.
|
||||||
|
//
|
||||||
|
// Every fact below was checked against this repo on KNOWLEDGE_DATE: config.js (loop 50, 10 verified visitors per shift, 150 network
|
||||||
|
// ad views per cycle recorded but not credited yet, 6 s visit, 3 browsers per connection a day, 1 free post credit a day for network
|
||||||
|
// members, 3 banners waiting per member, packs 10 for $3 and 40 for $10, banner look $2), ../contracts VBBShop (SPONSOR_BPS 3000,
|
||||||
|
// PRIZE_BPS 1000, company the rest, sponsor bound once by voucher, no owner withdraw, failed sends claimable), server.js (100 KB
|
||||||
|
// image, 125x125, Banner Spin posting 125x125 or 250x250, one swap per banner and the admin takedown, 2026-11-15), lsspins.js (SPIN tiles in empty places never shift, cycle or earn),
|
||||||
|
// public/how.html, packages.html, leaders.html, the Guides pages (/guides, 2026-11-17). The prize pot's floor and cap are internal and never shown (Marty's rule).
|
||||||
|
// HOUSE RULE: when a feature changes, update CANNED and FACTS in the same commit and bump KNOWLEDGE_DATE.
|
||||||
|
// Plain words, no em dashes, never a promise of income, "SafePal or any other crypto wallet", never RM Circle.
|
||||||
|
'use strict';
|
||||||
|
const core = require('./chatcore');
|
||||||
|
const C = require('./config').get();
|
||||||
|
|
||||||
|
const KNOWLEDGE_DATE = '2026-11-18';
|
||||||
|
const URL_ = 'https://' + C.site;
|
||||||
|
const SUPPORT = 'https://instantadpay.com/support';
|
||||||
|
const NOT_INCOME = 'You buy advertising for your own banners, not an income opportunity.';
|
||||||
|
const chainskus = require('./chainskus'); // live VBBShop SKU values (2026-11-17)
|
||||||
|
const weekend = require('./weekend'); // Network Weekend date gate (2026-11-17)
|
||||||
|
const packsOf = list => list.map(p => p.credits + ' post credits for $' + p.usd).join(' or ');
|
||||||
|
const packs = packsOf(C.packs); // the normal packs, as the stored instant answers say them; render() swaps in the live ones
|
||||||
|
const livePacksText = () => packsOf(chainskus.packs(C));
|
||||||
|
const freeNow = () => weekend.freePerDay(C.freeCreditsPerDay);
|
||||||
|
const places = C.prizePot.places.join('/');
|
||||||
|
|
||||||
|
const CANNED = [
|
||||||
|
{ id: 'support', title: 'Talk to a person, or a problem with my account', q: ['How do I contact support?', 'My credits did not show up', 'I need a real person'], tags: ['support', 'help', 'ticket', 'problem'],
|
||||||
|
re: core.SUPPORT_RE, handoff: true,
|
||||||
|
a: 'Network support handles every network site, Viral Banner Blitz included: open ' + SUPPORT + ', say it is about Viral Banner Blitz, and include your wallet address (and the transaction link if it is about a purchase). Marty answers there and by email. Tap "Open network support" below and your question goes with you.' },
|
||||||
|
{ id: 'refund', title: 'Refunds', q: ['Can I get a refund?', 'Can I cancel my package?'], tags: ['refund', 'cancel'],
|
||||||
|
re: /\brefund|cancel (my |the |a )?(package|pack|purchase)|money back|reverse (my |a |the )?(payment|transaction)/i, handoff: true,
|
||||||
|
a: 'Purchases are paid on Polygon and are final once confirmed, so they cannot be reversed or refunded. Every package is a one-time purchase that never renews, so there is nothing to cancel. If something went wrong with a payment, open network support at ' + SUPPORT + ' with the transaction link.' },
|
||||||
|
{ id: 'about', title: 'What is Viral Banner Blitz?', q: ['What is Viral Banner Blitz?', 'How does Viral Banner Blitz work?', 'What is VBB?'], tags: ['viral banner blitz', 'vbb', 'loop', 'overview'],
|
||||||
|
re: /(what('s| is) (viral ?banner ?blitz|vbb|the loop|this (site|place))|how does (viral ?banner ?blitz|vbb|the loop|this site|it) work)/i,
|
||||||
|
a: 'Viral Banner Blitz is one public banner loop the whole community moves. Post a 125x125 banner; it waits in line, then enters the loop. Every ' + C.perShift + ' verified visitors shift every banner one place forward, and the banner at the end rides out: it has cycled, and its owner earns ' + C.viewsPerCycle + ' network ad views. Network members get one free post credit each day they sign in. See ' + URL_ + '/how' },
|
||||||
|
{ id: 'cycle', title: 'What a cycle earns', q: ['What do I get when my banner cycles?', 'Are the 150 views added yet?', 'What does riding out mean?'], tags: ['cycle', 'ride out', '150 views', 'network ad views'],
|
||||||
|
re: /(cycle[sd]?|ride[sd]? out|riding out|150 (network )?(ad )?views|what do i (get|earn)|views (added|credited))/i,
|
||||||
|
a: 'When your banner reaches the end of the loop it rides out: it has cycled, and you earn ' + C.viewsPerCycle + ' network ad views, advertising for your own offers across the network. Right now each cycle is recorded on your My Banners page; adding those views to your network advertising is the next step and is not switched on yet. It is advertising, not cash, and nothing here promises income.' },
|
||||||
|
{ id: 'free-credit', title: 'Free post credits', q: ['How do I get a free post credit?', 'Is posting free?', 'Why did I not get my free credit?'], tags: ['free credit', 'post credit', 'daily', 'network member'],
|
||||||
|
re: /(free (post )?credits?|post credits?|is (it|posting) free|daily credit|credit (a|per|each) day)/i,
|
||||||
|
a: 'Network members (anyone with an InstantAdPay or LinkSpin account) get one free post credit each day they sign in, Central time. Each credit posts one banner into the loop. Want to post more? Credit packs are one-time purchases: ' + packs + '. You can have up to ' + C.maxQueuedPerMember + ' banners waiting at once.' },
|
||||||
|
{ id: 'swap', title: 'Changing a banner after posting (one swap)', q: ['Can I change my banner image or link?', 'I posted the wrong link. Can I fix it?', 'Can I remove my banner?', 'Why was my banner taken down?'], tags: ['swap', 'change banner', 'edit', 'wrong link', 'remove', 'taken down'],
|
||||||
|
re: /((swap|change|edit|replace|update|fix|correct)\b.{0,24}\b(banners?|image|picture|link|url)|wrong (link|image|banner|url|picture)|\btypo\b|(remove|delete|withdraw|take down|pull) (my |a |the )?banners?|banners?.{0,20}taken down)/i,
|
||||||
|
a: 'Each banner can be swapped one time. On My Banners (' + URL_ + '/my), a banner that is waiting or in the loop has a "Swap image or link" button: put in a new image, a new link, or both (a Banner Spin can swap to another of your own 125x125 or 250x250 spins). The banner keeps its place, its clicks and its progress through the loop, and the new image and link get the same checks as a new post. After that one swap the button is gone. Members cannot withdraw or remove a posted banner, and post credits are not refunded. A banner that breaks the rules can be taken down by the admin; its owner sees the reason on My Banners.' },
|
||||||
|
{ id: 'post', title: 'Posting a banner', q: ['How do I post a banner?', 'What size is the banner?', 'Can I use a Banner Spin?'], tags: ['post', 'banner', '125x125', 'image', 'link', 'banner spin'],
|
||||||
|
re: /(post (a |my )?banner|banner size|what size|125 ?x ?125|upload|image|banner spin|my banners)/i,
|
||||||
|
a: 'On My Banners (' + URL_ + '/my) upload a 125x125 image (100 KB or less) with your link, or post one of your LinkSpin Banner Spins (125x125 or 250x250). It uses one post credit, waits in line, and enters the loop at the front at the next shift. Your link must be a real page that loads.' },
|
||||||
|
{ id: 'packages', title: 'Packages and prices', q: ['How much are the packages?', 'What is the banner look?', 'Is it a subscription?'], tags: ['packages', 'price', 'credit pack', 'banner look', 'buy'],
|
||||||
|
re: /(packages?|packs?\b|price|how much(?! pol)|cost|\$ ?(2|3|10)\b|banner look|border|teaser|subscription|tokens?)/i,
|
||||||
|
a: 'Post credit packs: ' + packs + '. The banner look is $' + C.lookUsd + ' per banner: a bright border in the loop plus a teaser line that shows when someone points at it (add it on My Banners to a banner that is waiting or in the loop). All one-time purchases in POL at the live price, never a subscription; anything above the price comes back in the same transaction. Tokens (network visits) are coming soon. ' + NOT_INCOME },
|
||||||
|
{ id: 'split', title: 'Where your payment goes', q: ['Where does my payment go?', 'How do payouts work?', 'Do I earn when someone I invite buys?'], tags: ['split', 'payout', 'sponsor', '30%', 'commission'],
|
||||||
|
re: /(split|payouts?|commission|who gets paid|where does (my|the) (money|payment) go|percent|earn|get paid|invite|introduc)/i,
|
||||||
|
a: 'Each purchase is split on Polygon in the same transaction: 30% to the network member who introduced the buyer (to Viral Banner Blitz if nobody did), 10% to the weekly leaderboard prize pot, 60% to Viral Banner Blitz. The introducer is set once, on the buyer\'s first purchase, and never changes. Nothing is held and there is nothing to withdraw. ' + NOT_INCOME },
|
||||||
|
{ id: 'visitors', title: 'What counts as a verified visitor', q: ['What is a verified visitor?', 'Why did my visit not count?', 'How does the loop move?'], tags: ['verified visitor', 'shift', 'visit', 'bots'],
|
||||||
|
re: /(verified visitors?|visit (did ?n.?t|not) count|counts? as a visit|loop (move|shift)|shift|how (does|do) (the loop|banners) move)/i,
|
||||||
|
a: 'A verified visitor is a real browser that keeps the loop page open and visible for about ' + C.visitSeconds + ' seconds. Each visitor counts once every 24 hours; bots, crawlers, repeat visits and more than a few visitors per internet connection a day do not count. Every ' + C.perShift + ' verified visitors shift every banner one place forward.' },
|
||||||
|
{ id: 'leaders', title: 'Weekly leaderboards and prizes', q: ['How do the leaderboards work?', 'How do I win the weekly prize?', 'When are prizes paid?'], tags: ['leaderboard', 'prize', 'weekly', 'ref link', 'traffic sources'],
|
||||||
|
re: /(leader ?boards?|leaders|prizes?|\bpot\b|winners?|top three|weekly|my link|ref link|traffic sources)/i,
|
||||||
|
a: 'Share your link (it ends in ?ref= and your network username). Two weekly leaderboards, Monday to Sunday Central time: most verified visitors sent, and most different websites they came from. The top three on each share the prize pot (10% of the week\'s sales, ' + places + ' percent), paid in POL to the wallet of their Viral Banner Blitz account the following Monday. Ties go to whoever got there first. Past winners and their transactions: ' + URL_ + '/leaders' },
|
||||||
|
{ id: 'spin-tiles', title: 'SPIN tiles in the loop', q: ['What are the SPIN tiles?', 'Why is there a SPIN banner in the loop?'], tags: ['spin', 'banner spin', 'empty space'],
|
||||||
|
re: /(spin tiles?|tiles? marked spin|\bspin\b banner|banners? marked spin)/i,
|
||||||
|
a: 'Tiles marked SPIN are members\' LinkSpin Banner Spins showing in empty places of the loop. They are not in the loop: they never shift it, never cycle and never earn. Post a banner and yours takes a real place.' },
|
||||||
|
{ id: 'withdraw', title: 'Withdrawals', q: ['How do I withdraw?', 'Where is my balance?'], tags: ['withdraw', 'balance', 'cash out'],
|
||||||
|
re: /(withdraw|cash ?out|my balance|pending (pay|commission))/i,
|
||||||
|
a: 'There is nothing to withdraw. The introducer\'s 30% goes straight to their wallet inside the buyer\'s transaction (a payment that fails to send waits in the contract for that wallet to claim). Leaderboard prizes are paid in POL to the winners\' wallets. Every payment is in the ledger at ' + URL_ + '/ledger' },
|
||||||
|
{ id: 'wallet', title: 'Signing in and paying', q: ['How do I sign in?', 'Which wallet should I use?', 'How do I pay?'], tags: ['sign in', 'wallet', 'pol', 'safepal'],
|
||||||
|
re: /(sign ?(in|up)|log ?in|account|which wallet|what wallet|wallet|metamask|safepal|\bpol\b|polygon|crypto|gas|fee|how (do|can) i (pay|buy))/i,
|
||||||
|
a: 'Sign in on My Banners (' + URL_ + '/my) through InstantAdPay, LinkSpin or a wallet signature (free, it cannot move funds). Packages are paid in POL on Polygon with SafePal or any other crypto wallet; keep a little extra POL for the network fee.' },
|
||||||
|
{ id: 'safe', title: 'Is it safe? Is it a scheme?', q: ['Is this a pyramid scheme?', 'Is Viral Banner Blitz legit?', 'Who holds the money?'], tags: ['safe', 'legit', 'pyramid', 'contract'],
|
||||||
|
re: /(pyramid|ponzi|scam|scheme|legit|safe|trust|rug|who holds)/i,
|
||||||
|
a: 'Posting is free for network members every day, and packages buy more banner posts and a better-looking banner. The VBBShop contract on Polygon splits each purchase in the same transaction with fixed shares and no owner withdraw. Check every payment at ' + URL_ + '/ledger and the contract at ' + URL_ + '/contract; the walk-through is at ' + URL_ + '/guides/is-it-legit. ' + NOT_INCOME },
|
||||||
|
{ id: 'promote', title: 'Promote Viral Banner Blitz', q: ['Is there a promo kit?', 'Where are the banners to promote VBB?'], tags: ['promote', 'kit', 'banners'],
|
||||||
|
re: /(promo|promote|creatives?|kit|swipes?)/i,
|
||||||
|
a: 'The promo kit at ' + URL_ + '/promote has creatives in the common sizes and copy, all with your link. Every verified visitor you send moves the loop for everyone and counts on the weekly leaderboards.' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const FAQ = [
|
||||||
|
{ id: 'f-network', title: 'Viral Banner Blitz and the other network sites', source: 'faq', tags: ['network', 'one account', 'instantadpay', 'linkspin'],
|
||||||
|
questions: ['Is Viral Banner Blitz part of InstantAdPay?', 'Do I need a new account?', 'Which network sites are there?'],
|
||||||
|
answer: 'Viral Banner Blitz is part of the network: one account, username and sponsor across InstantAdPay, LinkSpin, Downline Banners, Viral Banner Blitz, ViralAdBlitz, DownlineHydra, 5xYourTeam, Stack POL and Earners Corner. Sign in here through InstantAdPay or LinkSpin.' },
|
||||||
|
{ id: 'f-old-vbb', title: 'The old Viral Banner Blitz', source: 'faq', tags: ['old account', 'old site', 'balance'],
|
||||||
|
questions: ['Where is my old Viral Banner Blitz account?', 'Did my old credits carry over?'],
|
||||||
|
answer: 'Viral Banner Blitz was rebuilt as one shared banner loop. Old members were matched to the network by email; old balances and credits were not carried over. Sign in with InstantAdPay or LinkSpin and you get a free post credit each day you sign in.' },
|
||||||
|
// Guides (Marty 2026-11-17): the evergreen pages the assistant can point people to
|
||||||
|
{ id: 'f-guides', title: 'Viral Banner Blitz guides', source: 'faq', tags: ['guides', 'guide', 'faq', 'legit', 'free account', 'prize boards', 'help pages'],
|
||||||
|
questions: ['Is there a guide or FAQ page?', 'Where can I read how it all works?', 'Is there a page that explains if VBB is legit?'],
|
||||||
|
answer: 'The guides at ' + URL_ + '/guides: how the loop works (' + URL_ + '/how), is Viral Banner Blitz legit (' + URL_ + '/guides/is-it-legit: the contract, the ledger and the 30/10/60 split), getting the most from your free account (' + URL_ + '/guides/free-account), how the weekly prize boards work (' + URL_ + '/guides/prize-boards) and the FAQ (' + URL_ + '/guides/faq).' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const FACTS = () => [
|
||||||
|
'- WHAT IT IS: Viral Banner Blitz (' + URL_ + ') is one public loop of ' + C.loopSize + ' member banners (125x125 tiles). A posted banner waits in line, then enters at the front. Every ' + C.perShift + ' verified visitors shift every banner one place; the banner at the end rides out (has cycled) and its owner earns ' + C.viewsPerCycle + ' network ad views. Cycles are recorded on My Banners now; crediting those views to network advertising is NOT switched on yet.',
|
||||||
|
'- VERIFIED VISITOR: a real browser keeps the loop page open and visible about ' + C.visitSeconds + ' seconds; once per visitor per 24 hours; bots, crawlers, repeats and more than ' + C.perIpDay + ' browsers per connection per day do not count.',
|
||||||
|
'- POSTING: one post credit per banner. Network members (InstantAdPay or LinkSpin, checked with the network hub) get ' + freeNow() + ' free post credit' + (freeNow() === 1 ? '' : 's') + ' each day they sign in (Central day). Up to ' + C.maxQueuedPerMember + ' banners waiting per member. Image 125x125, 100 KB max, or post a LinkSpin Banner Spin (125x125 or 250x250). The link must answer. SPIN tiles in empty places are LinkSpin Banner Spins: they never shift, cycle or earn.',
|
||||||
|
'- ONE SWAP PER BANNER: a banner that is waiting or in the loop can swap its image and/or link ONE time from My Banners (a Banner Spin to another of the member\'s own 125x125/250x250 spins). It keeps its id, place, clicks and loop progress; the new image and link get the same checks as a new post. No second swap. Members cannot withdraw or remove a banner and credits are not refunded. The admin can take a banner down (the owner sees the reason; the admin decides whether the post credit comes back); its place stays as a house tile until it would have ridden out, so nobody else moves, and it never cycles or earns.',
|
||||||
|
'- PACKAGES (one-time, POL at the live price, never a subscription, overpayment returned; read from the VBBShop contract just now): ' + livePacksText() + '; banner look $' + C.lookUsd + ' per banner (border + hover teaser, on a waiting or in-loop banner, one per banner); tokens (network visits at the InstantAdPay visit rate) coming soon.',
|
||||||
|
'- SPLIT (VBBShop constants, no owner withdraw): 30% to the member who introduced the buyer (bound once, by a keeper-signed voucher, on the first purchase; none = company), 10% to the weekly prize pot, 60% company, same transaction. Failed sends wait in the contract for their owner to claim.',
|
||||||
|
'- LEADERBOARDS (Monday to Sunday Central): most verified visitors sent (the member\'s ?ref= link) and most different traffic sources (referring sites). Prize pot = 10% of the week\'s sales, half per board, top three ' + places + ' percent, paid in POL to the winners\' VBB wallets the following Monday at the POL price at payout; ties to whoever got there first. Never state a maximum or a cap.',
|
||||||
|
'- VIDEO (2026-11-18): a short walkthrough video (free daily credit, posting a banner, how visitors move the loop, your link and the weekly leaderboards, packages, where to start) is on ' + URL_ + '/how.',
|
||||||
|
'- PAGES: / (the loop), /how, /packages, /my (My Banners), /leaders, /promote, /ledger, /contract, /terms, /disclaimer, /privacy. GUIDES (point people to them): /guides (index), /guides/is-it-legit (contract, ledger, split), /guides/free-account (free daily credit, network-verified, tips), /guides/prize-boards (weekly leaderboards and prizes), /guides/faq. Sign in through InstantAdPay, LinkSpin or a wallet signature.',
|
||||||
|
weekendFact(),
|
||||||
|
'- NO REFUNDS: blockchain payments are final. SUPPORT for account or payment problems: network support at ' + SUPPORT + ' (InstantAdPay runs the one desk for every network site). ' + NOT_INCOME
|
||||||
|
].filter(Boolean).join('\n');
|
||||||
|
|
||||||
|
// Network Weekend (Black Friday to Cyber Monday, Fri 11-27 00:00 CT to Tue 12-01 00:00 CT): only while it runs, from live values
|
||||||
|
function weekendFact() {
|
||||||
|
if (!weekend.on()) return '';
|
||||||
|
const big = chainskus.packs(C).slice().sort((a, b) => b.usd - a.usd)[0]; const base = C.packs.slice().sort((a, b) => b.usd - a.usd)[0];
|
||||||
|
return '- NETWORK WEEKEND (Black Friday to Cyber Monday, midnight to midnight Central, ends Monday 11-30 at 11:59 PM Central): network members get ' + freeNow() + ' free post credits a day.'
|
||||||
|
+ (big && base && big.credits > base.credits ? ' The $' + big.usd + ' pack carries ' + big.credits + ' credits instead of ' + base.credits + ', same price.' : '')
|
||||||
|
+ ' Other network deals: https://instantadpay.com/weekend';
|
||||||
|
}
|
||||||
|
// instant answers carry the normal numbers; at answer time swap in the live packs and, during Network Weekend, today's free credits
|
||||||
|
function render(t) {
|
||||||
|
let out = String(t).split(packs).join(livePacksText());
|
||||||
|
if (freeNow() > 1) out = out.replace(/\b(get|gets) one free post credit (each|every) day they sign in/g, '$1 ' + freeNow() + ' free post credits each day they sign in during Network Weekend (through Monday 11-30, Central)')
|
||||||
|
.replace(/you get a free post credit each day you sign in/g, 'you get ' + freeNow() + ' free post credits each day you sign in during Network Weekend (through Monday 11-30, Central)');
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SITE = {
|
||||||
|
id: 'vbb', hubSite: 'vbb', netId: 'vbb', name: 'Viral Banner Blitz', url: URL_, supportUrl: SUPPORT, knowledgeDate: KNOWLEDGE_DATE,
|
||||||
|
dataDir: C.dataDir, canned: CANNED, faq: FAQ, facts: FACTS, render,
|
||||||
|
intro: 'You are the assistant on Viral Banner Blitz (' + URL_ + '), one public banner loop the community moves with verified visitors: post a 125x125 banner, ride it out, earn network ad views. Network members post free once a day; credit packs and a banner look are one-time purchases.',
|
||||||
|
quickTopics: ['How does the loop work?', 'Is posting free?', 'How do the leaderboards work?', 'What is ViralAdBlitz?']
|
||||||
|
};
|
||||||
|
|
||||||
|
function init() { return core.init(SITE); }
|
||||||
|
module.exports = { init, handle: core.handle, answer: core.answer, KNOWLEDGE_DATE, CANNED, FAQ, SITE, FACTS, render };
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
// The site assistant's engine (Marty 2026-11-15: a chatbot on every rebuilt network site), ported from LinkSpin's chatbot.js.
|
||||||
|
// The site's own chatbot.js holds what it knows (CANNED instant answers + FACTS, written from that site's code); this file
|
||||||
|
// holds how it answers, the same on every site:
|
||||||
|
// 1. the knowledge base's instant answers (kb.js, seeded from CANNED; first matching pattern wins, no AI call)
|
||||||
|
// (since 2026-11-16 only a hand-off pattern answers outright; any other pattern hit is checked against step 1b)
|
||||||
|
// 1b. the hub's semantic match by meaning (netkb.route, core2 embeddings): answers with this site's entry when it is sure,
|
||||||
|
// keeps or overrules a pattern hit, and picks the prompt context; fails soft to the old path within NETKB_MATCH_MS
|
||||||
|
// 2. retrieval over the merged NETWORK knowledge base (this site's entries boosted, netkb.js), into the system prompt
|
||||||
|
// 3. OpenRouter (deepseek/deepseek-v4-flash:nitro, reasoning OFF, retried once), house rules in the prompt and on the way out
|
||||||
|
// Account problems go to the network support desk on InstantAdPay (handoff: true makes the widget offer it).
|
||||||
|
// Routes: POST /api/chat, GET /api/chat/kb-stamp, admin GET/POST /api/admin/kb, GET/PUT/DELETE /api/admin/kb/<id>,
|
||||||
|
// POST /api/admin/kb/test, GET /api/admin/kb/network (x-admin-token, the site's own isAdmin).
|
||||||
|
// The SAME file ships in ViralAdBlitz, DownlineHydra, 5xYourTeam, Viral Banner Blitz, Downline Banners and Stack POL.
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const https = require('https');
|
||||||
|
const http = require('http');
|
||||||
|
const kb = require('./kb');
|
||||||
|
const netkb = require('./netkb');
|
||||||
|
|
||||||
|
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
|
||||||
|
let S = null; // the site: { id, hubSite, name, url, dataDir, canned, faq, facts(), about, supportUrl, linkFor, quickTopics }
|
||||||
|
|
||||||
|
function key() {
|
||||||
|
if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim();
|
||||||
|
if (!S || !S.dataDir) return '';
|
||||||
|
try { return fs.readFileSync(path.join(S.dataDir, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; }
|
||||||
|
}
|
||||||
|
const enabled = () => !!key();
|
||||||
|
// optional per-site rewrite of an instant answer at answer time (2026-11-17, Network Weekend: live chain numbers and dated deals)
|
||||||
|
const R = t => { try { return S && typeof S.render === 'function' ? S.render(t) : t; } catch (e) { return t; } };
|
||||||
|
|
||||||
|
// CANNED + FAQ in the shape kb.js stores (order keeps the first-match-wins sequence)
|
||||||
|
function seeds() {
|
||||||
|
return S.canned.map((c, i) => ({ id: 'c-' + c.id, title: c.title, questions: c.q || [], answer: c.a, tags: c.tags || [], pattern: c.re ? c.re.source : '',
|
||||||
|
handoff: !!c.handoff, order: (i + 1) * 10, source: 'canned' })).concat(S.faq || []);
|
||||||
|
}
|
||||||
|
|
||||||
|
const supportUrl = () => S.supportUrl || 'https://instantadpay.com/support';
|
||||||
|
// asking for a person, or one person's own account problem: every site's first CANNED entry uses this (handoff: true)
|
||||||
|
const SUPPORT_RE = /((contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|someone|a (human|person|real person))|real person|\bhuman\b|customer (service|support)|open a ticket|support (ticket|desk|team|email)|help ?desk|(my|the) (boost|purchase|payment|payout|order|account|sign.?in|log.?in|pro|upgrade|ad|banner|pick)s? (is |was |has |did |does )?(not|never|n.?t|missing|stuck|wrong|failed|broken|lost|gone)|(did ?n.?t|did not|never|has ?n.?t|have ?n.?t) (show|arriv|appear|receiv|get paid|go through|work|confirm)|i (was|got) (charged|scammed)|charged twice)/i;
|
||||||
|
const HOUSE_RULES = () => `RULES:
|
||||||
|
- 1 to 4 sentences, plain text, no markdown, include full URLs when pointing at a page.
|
||||||
|
- Your main job is ${S.name}. Questions about another network site: answer from that site's knowledge-base entry, say which site it is about, and give that site's link exactly as the entry gives it. Never mix two sites' prices, splits or rules.
|
||||||
|
- NEVER promise or estimate income, and never state a maximum or total anyone can earn. This is advertising with a referral program, never an investment. Nobody earns unless real purchases happen in their line. Crypto payments are final.
|
||||||
|
- Whenever ad credits come up, say: Ad credits buy advertising, not income.
|
||||||
|
- Wallets: say "SafePal or any other crypto wallet". Never recommend MetaMask.
|
||||||
|
- Never mention RM Circle. It is not part of this network.
|
||||||
|
- No em dashes. If you do not know, say so plainly; never guess a price, a percentage or a rule.
|
||||||
|
- Anything about one person's own account (a missing payout, a sign-in that will not work, a purchase that did not show, a bug) you cannot look up: say so and send them to network support at ${supportUrl()}.`;
|
||||||
|
|
||||||
|
function networkLine() {
|
||||||
|
const list = netkb.sites();
|
||||||
|
if (!list.length) return '';
|
||||||
|
return '\nNETWORK SITES (one network account works across them; link to use for each):\n' + list.map(s => '- ' + s.name + ': ' + s.go).join('\n') + '\n';
|
||||||
|
}
|
||||||
|
function systemPrompt(kbBlock) {
|
||||||
|
return S.intro + '\n\nFACTS (checked against this site\'s code on ' + S.knowledgeDate + '):\n' + S.facts() + '\n' + networkLine() + '\n' + HOUSE_RULES() + (kbBlock ? '\n\n' + kbBlock : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function endpoint() {
|
||||||
|
try { return new URL(process.env.OPENROUTER_URL || 'https://openrouter.ai/api/v1/chat/completions'); } catch (e) { return new URL('https://openrouter.ai/api/v1/chat/completions'); }
|
||||||
|
}
|
||||||
|
function askOnce(message, historyText, kbBlock) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const body = JSON.stringify({
|
||||||
|
model: MODEL,
|
||||||
|
reasoning: { enabled: false }, // deepseek-v4-flash reasons by default and can spend the whole max_tokens on it (2026-10-16)
|
||||||
|
max_tokens: 320,
|
||||||
|
messages: [
|
||||||
|
{ role: 'system', content: systemPrompt(kbBlock) },
|
||||||
|
...(historyText ? [{ role: 'user', content: 'Earlier context: ' + String(historyText).slice(0, 800) }] : []),
|
||||||
|
{ role: 'user', content: String(message).slice(0, 600) }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const ep = endpoint();
|
||||||
|
const req = (ep.protocol === 'http:' ? http : https).request({ hostname: ep.hostname, port: ep.port || undefined, path: ep.pathname + ep.search, method: 'POST',
|
||||||
|
headers: { Authorization: 'Bearer ' + key(), 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body),
|
||||||
|
'HTTP-Referer': S.url, 'X-Title': S.name + ' assistant' }, timeout: 30000 },
|
||||||
|
res => {
|
||||||
|
let d = '';
|
||||||
|
res.on('data', c => { d += c; });
|
||||||
|
res.on('end', () => {
|
||||||
|
// OpenRouter can pad a slow upstream with keepalive lines before the JSON (IAP, 2026-09-17): find the object
|
||||||
|
const i = d.indexOf('{'); let txt = '';
|
||||||
|
try { txt = String(JSON.parse(i < 0 ? d : d.slice(i)).choices[0].message.content || '').trim(); }
|
||||||
|
catch (e) { return reject(new Error('openrouter ' + res.statusCode + ': ' + d.slice(0, 150))); }
|
||||||
|
if (!txt) return reject(new Error('openrouter ' + res.statusCode + ': empty content'));
|
||||||
|
resolve(txt);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', reject);
|
||||||
|
req.on('timeout', () => req.destroy(new Error('openrouter timeout')));
|
||||||
|
req.end(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function askAI(message, historyText, kbBlock) {
|
||||||
|
try { return await askOnce(message, historyText, kbBlock); }
|
||||||
|
catch (e) { await new Promise(r => setTimeout(r, 700)); return askOnce(message, historyText, kbBlock); } // one provider dropping it is the usual cause
|
||||||
|
}
|
||||||
|
|
||||||
|
// house rules on the way out, whatever the model wrote
|
||||||
|
const RMC_RE = /\brm ?circle\b|rmcircle/i;
|
||||||
|
function scrub(t) {
|
||||||
|
let s = String(t || '').replace(/\s*[—―]\s*/g, ', ').replace(/(\d)\s*–\s*(\d)/g, '$1-$2').replace(/\s*–\s*/g, ', ');
|
||||||
|
s = s.replace(/\*\*(.+?)\*\*/g, '$1').replace(/^#+\s*/gm, '');
|
||||||
|
s = s.replace(/\bMeta ?Mask\b(\s*(,|or|and)\s*)?/gi, '').replace(/\s{2,}/g, ' ').trim();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
const UNSURE_RE = /(not sure|do not know|don't know|cannot help|can't help|unable to help|no way for me|i (can|could) ?not (see|check|look)|contact support|network support|support desk|\/support\b)/i;
|
||||||
|
|
||||||
|
async function answer(message, historyText) {
|
||||||
|
const r = await answerRaw(message, historyText);
|
||||||
|
if (r && typeof r.reply === 'string') {
|
||||||
|
r.reply = scrub(r.reply);
|
||||||
|
if (RMC_RE.test(r.reply)) r.reply = 'I can only help with ' + S.name + ' and the network sites. For anything else, network support at ' + supportUrl() + ' can point you the right way.';
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
async function answerRaw(message, historyText) {
|
||||||
|
const msg = String(message || '').trim().slice(0, 600);
|
||||||
|
if (!msg) return { error: 'Say something first.' };
|
||||||
|
let hit = null, kbOk = true, other = [];
|
||||||
|
try {
|
||||||
|
await kb.load();
|
||||||
|
// a question about another network site (named, and this site not named) skips this site's instant answers, except a hand-off
|
||||||
|
other = kb.namesOther(msg, S.hubSite);
|
||||||
|
if (other.length && new RegExp('\\b' + S.name.replace(/[^A-Za-z0-9]+/g, '\\s*') + '\\b', 'i').test(msg)) other = [];
|
||||||
|
hit = await kb.fastPath(msg);
|
||||||
|
if (hit && other.length && !hit.handoff) hit = null;
|
||||||
|
} catch (e) { kbOk = false; console.error('kb fast path', e.message); }
|
||||||
|
// a hand-off (support, one person's account problem) always answers from its exact pattern, before anything else
|
||||||
|
if (hit && hit.handoff) return { reply: R(hit.answer), canned: true, kb: hit.id, handoff: true };
|
||||||
|
// then meaning (2026-11-16, netkb.route): the hub's semantic match over the network KB answers, keeps or overrules the
|
||||||
|
// pattern hit, and picks the prompt context. Hub or model slow or down: null, and the pattern + BM25 path below runs as before.
|
||||||
|
let sem = null;
|
||||||
|
if (kbOk) { try { sem = await netkb.route(msg, { fast: hit, own: await kb.own(), prefer: other }); } catch (e) { sem = null; } }
|
||||||
|
if (sem) hit = sem.hit;
|
||||||
|
if (hit) return Object.assign({ reply: R(hit.answer), canned: true, kb: hit.id }, sem ? { via: sem.via } : {}, hit.handoff ? { handoff: true } : {});
|
||||||
|
if (!kbOk) for (const c of S.canned) if (c.re && c.re.test(msg)) return Object.assign({ reply: R(c.a), canned: true }, c.handoff ? { handoff: true } : {});
|
||||||
|
let kbBlock = '', kbIds = [], hits = [];
|
||||||
|
try {
|
||||||
|
const query = msg.split(/\s+/).length < 4 && historyText ? msg + ' ' + String(historyText).slice(-200) : msg;
|
||||||
|
hits = sem && sem.hits.length ? sem.hits : await kb.context(query, 6);
|
||||||
|
kbBlock = kb.promptBlock(hits); kbIds = hits.map(h => h.entry.id);
|
||||||
|
} catch (e) { console.error('kb search', e.message); }
|
||||||
|
if (!enabled()) {
|
||||||
|
// no AI: the best matching entry, if it is a clear match, else the honest fallback
|
||||||
|
if (hits.length) { const e = hits[0].entry; return { reply: e.answer + (e.site ? ' More at ' + e.go : ''), kb: [e.id] }; }
|
||||||
|
return { reply: S.fallback || ('Good question. The quick answers I have cover how ' + S.name + ' works, what it costs and how payouts work. For anything else, network support at ' + supportUrl() + ' will help.'), handoff: true };
|
||||||
|
}
|
||||||
|
try { const reply = await askAI(msg, historyText, kbBlock); return Object.assign({ reply }, kbIds.length ? { kb: kbIds } : {}, UNSURE_RE.test(reply) ? { handoff: true } : {}); }
|
||||||
|
catch (e) {
|
||||||
|
console.error('chat AI failed', e.message);
|
||||||
|
if (hits.length) { const x = hits[0].entry; return { reply: x.answer + (x.site ? ' More at ' + x.go : ''), kb: [x.id] }; }
|
||||||
|
return { reply: 'I hit a snag answering that one, on our side. The live ledger at ' + S.url + '/ledger and the contract page at ' + S.url + '/contract cover most deep questions, or network support at ' + supportUrl() + ' will answer.', handoff: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- rate limit: per visitor, in memory ----
|
||||||
|
const hits = new Map();
|
||||||
|
function limited(ip) {
|
||||||
|
const now = Date.now(); const h = hits.get(ip) || { m: 0, mAt: now, d: 0, dAt: now };
|
||||||
|
if (now - h.mAt > 60000) { h.m = 0; h.mAt = now; }
|
||||||
|
if (now - h.dAt > 86400000) { h.d = 0; h.dAt = now; }
|
||||||
|
h.m++; h.d++; hits.set(ip, h);
|
||||||
|
if (hits.size > 20000) hits.clear();
|
||||||
|
return h.m > 12 || h.d > 300;
|
||||||
|
}
|
||||||
|
const ipOf = req => String(req.headers['cf-connecting-ip'] || String(req.headers['x-forwarded-for'] || '').split(',')[0] || (req.socket && req.socket.remoteAddress) || 'x').trim();
|
||||||
|
|
||||||
|
// h: { json(res, code, obj, extra), readBody(req), isAdmin(req) }; returns true when it answered
|
||||||
|
async function handle(req, res, p, u, h) {
|
||||||
|
if (p === '/api/chat' && req.method === 'POST') {
|
||||||
|
if (limited(ipOf(req))) { h.json(res, 429, { error: 'Give it a minute, then ask again.' }); return true; }
|
||||||
|
const b = await h.readBody(req);
|
||||||
|
const hist = Array.isArray(b.history) ? b.history.map(x => String(x || '')).join(' ').slice(-800) : String(b.history || '').slice(-800);
|
||||||
|
const r = await answer(b.message, hist);
|
||||||
|
if (r.handoff) r.support = supportLink(b.message);
|
||||||
|
h.json(res, r.error ? 400 : 200, r); return true;
|
||||||
|
}
|
||||||
|
if (p === '/api/chat/config' && req.method === 'GET') { h.json(res, 200, { name: S.name, support: supportUrl(), topics: S.quickTopics || [] }, { 'Cache-Control': 'public, max-age=300' }); return true; }
|
||||||
|
if (p === '/api/chat/kb-stamp' && req.method === 'GET') { h.json(res, 200, Object.assign(await kb.stamp(), { knowledgeDate: S.knowledgeDate }), { 'Cache-Control': 'no-store' }); return true; }
|
||||||
|
if (!p.startsWith('/api/admin/kb')) return false;
|
||||||
|
if (!h.isAdmin(req)) { h.json(res, 401, { error: 'no' }); return true; }
|
||||||
|
if (p === '/api/admin/kb') {
|
||||||
|
if (req.method === 'GET') { h.json(res, 200, { entries: await kb.list(u.searchParams.get('q') || ''), stamp: await kb.stamp() }); return true; }
|
||||||
|
if (req.method === 'POST') { const r = await kb.create(await h.readBody(req)); h.json(res, r.error ? 400 : 200, r); return true; }
|
||||||
|
}
|
||||||
|
if (p === '/api/admin/kb/test' && req.method === 'POST') { const b = await h.readBody(req); h.json(res, 200, Object.assign(await kb.test(b.question), b.answer ? { answer: await answer(b.question) } : {})); return true; }
|
||||||
|
if (p === '/api/admin/kb/network' && req.method === 'GET') {
|
||||||
|
if (u.searchParams.get('refresh') === '1') await netkb.refresh();
|
||||||
|
if (u.searchParams.get('publish') === '1') await netkb.publish();
|
||||||
|
h.json(res, 200, Object.assign(netkb.view(), { ai: enabled(), model: MODEL })); return true;
|
||||||
|
}
|
||||||
|
const m = /^\/api\/admin\/kb\/([A-Za-z0-9._:-]{1,80})$/.exec(p);
|
||||||
|
if (m) {
|
||||||
|
if (req.method === 'GET') { const e = await kb.get(m[1]); h.json(res, e ? 200 : 404, e ? { entry: e } : { error: 'Entry not found.' }); return true; }
|
||||||
|
if (req.method === 'PUT') { const r = await kb.update(m[1], await h.readBody(req)); h.json(res, r.error ? (r.error === 'Entry not found.' ? 404 : 400) : 200, r); return true; }
|
||||||
|
if (req.method === 'DELETE') { const r = await kb.remove(m[1]); h.json(res, r.error ? 404 : 200, r); return true; }
|
||||||
|
}
|
||||||
|
h.json(res, 404, { error: 'Not found' }); return true;
|
||||||
|
}
|
||||||
|
// the support desk link the widget offers: InstantAdPay's public form, told which site and question it came from
|
||||||
|
function supportLink(q) {
|
||||||
|
const qs = new URLSearchParams({ from: S.id, subject: (S.name + ': ' + String(q || '').replace(/\s+/g, ' ').trim()).slice(0, 120) });
|
||||||
|
return supportUrl() + '?' + qs.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// the link to another network site: its LinkSpin tracked link with ?src=<this site> (netsites.js), else its plain address
|
||||||
|
const hostOf = x => { try { return new URL(x).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
|
||||||
|
function linkVia(netId) {
|
||||||
|
return url => {
|
||||||
|
try {
|
||||||
|
const ns = require('./netsites'); const h = hostOf(url);
|
||||||
|
const m = ns.list().concat(ns.FALLBACK || []).find(s => hostOf(s.url) === h);
|
||||||
|
return (m && netId && m.id !== netId && ns.tracked(m.id, netId)) || url;
|
||||||
|
} catch (e) { return url; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// site: see S above. Call after docstore.init (kb.json is a MySQL document there).
|
||||||
|
function init(site) {
|
||||||
|
S = site; if (!S.linkFor) S.linkFor = linkVia(S.netId);
|
||||||
|
const ready = kb.init({ dataDir: site.dataDir, seeds: seeds(), siteUrl: site.url, helpText: 'network support at ' + supportUrl() });
|
||||||
|
netkb.init({ dataDir: site.dataDir, site: site.hubSite, name: site.name, url: site.url, entries: () => kb.own(), linkFor: site.linkFor });
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { init, handle, answer, enabled, seeds, systemPrompt, scrub, supportLink, linkVia, SUPPORT_RE, _limited: limited };
|
||||||
@@ -54,6 +54,7 @@ function get() {
|
|||||||
linkProbe: e.LINK_PROBE !== '0', // check the target link answers and allows frames (off in the local smoke test)
|
linkProbe: e.LINK_PROBE !== '0', // check the target link answers and allows frames (off in the local smoke test)
|
||||||
iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''),
|
iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''),
|
||||||
lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''),
|
lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''),
|
||||||
|
lsPartnerBase: String(e.LS_PARTNER_URL || e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''), // Banner Spins partner API (a stand-in in the smoke test)
|
||||||
// network usernames: ?u=<username> / ?a=<wallet> -> {address, username}. '' turns the lookup off (local prototype).
|
// network usernames: ?u=<username> / ?a=<wallet> -> {address, username}. '' turns the lookup off (local prototype).
|
||||||
networkLookupUrl: e.NETWORK_LOOKUP_URL !== undefined ? String(e.NETWORK_LOOKUP_URL).trim()
|
networkLookupUrl: e.NETWORK_LOOKUP_URL !== undefined ? String(e.NETWORK_LOOKUP_URL).trim()
|
||||||
: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '') + '/api/network/member'
|
: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '') + '/api/network/member'
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// Network hub events for a wallet site (Marty 2026-11-16, "Yes do 1 and 2"). Byte-identical in Viral Banner Blitz, Downline Banners,
|
||||||
|
// ViralAdBlitz, DownlineHydra and 5xYourTeam (like networksso.js): copy it whole, never edit one copy alone.
|
||||||
|
//
|
||||||
|
// The hub tells every hooked site what changed (POST /api/hub/events, the same hook InstantAdPay and LinkSpin take): X-Hub-Ts +
|
||||||
|
// X-Hub-Sig = hex HMAC-SHA256(HUB_SECRET, ts + newline + raw body), 5-minute window. The hub only moves its cursor after a 2xx and
|
||||||
|
// may send an event twice. This site acts on three events and ignores every other one:
|
||||||
|
// member.signedout "Sign out everywhere" on any network site
|
||||||
|
// member.blocked the hub blocked the person
|
||||||
|
// member.erased the hub erased the person ({emailHash, walletHashes}: the person is gone from the hub, so no lookup)
|
||||||
|
// Each one ends that person's sessions here. A wallet site keys sessions by wallet, so the person is mapped through the hub:
|
||||||
|
// POST /v1/resolve {id} (signed as HUB_SITE) gives their main wallet and every contract wallet (contractWallets). An erased
|
||||||
|
// person cannot be looked up any more: the event carries the SHA-256 of each of their wallets (and of their email) instead.
|
||||||
|
// Only sessions made BEFORE the event end (a fresh sign-in after it stays), so a replay can never sign anyone out twice.
|
||||||
|
// A failed lookup answers 503 so the hub sends the batch again; after 5 tries an event is set aside in the log.
|
||||||
|
// Nothing here sends mail, posts or touches a banner, a payout or the chain: it only ends sign-in sessions.
|
||||||
|
//
|
||||||
|
// init({ dataDir, site, end }) where end({ type, personId, at, wallets, walletHashes, emailHash, match }) ends the sessions and
|
||||||
|
// answers how many; match(session-like {address?, email?, wallet?, hubId?}) is the shared test (wallet, wallet hash, email
|
||||||
|
// hash, hub id). Off when HUB_HOOK=0, or without HUB_URL and a 32+ character HUB_SECRET (then the route answers 404).
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const WALLET_RE = /^0x[0-9a-f]{40}$/, HASH_RE = /^[0-9a-f]{64}$/;
|
||||||
|
const TRIES = 5, KEEP = 3000, SKEW = 2000;
|
||||||
|
const ACTS = new Set(['member.signedout', 'member.blocked', 'member.erased']);
|
||||||
|
let R = null, st = null, chain_ = Promise.resolve();
|
||||||
|
const SECRET = () => String(process.env.HUB_SECRET || '').trim();
|
||||||
|
const BASE = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||||
|
const SITE = () => String(process.env.HUB_SITE || (R && R.site) || '').trim().toLowerCase();
|
||||||
|
const on = () => !/^(0|false|no|off)$/i.test(String(process.env.HUB_HOOK || '').trim()) && /^https?:\/\/[a-z0-9.:-]+$/i.test(BASE()) && SECRET().length >= 32;
|
||||||
|
const lc = v => String(v == null ? '' : v).trim().toLowerCase();
|
||||||
|
const sha = v => crypto.createHash('sha256').update(lc(v)).digest('hex');
|
||||||
|
const FILE = () => path.join(R.dataDir, 'hubevents.json');
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
if (st) return st;
|
||||||
|
try { st = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { st = null; }
|
||||||
|
if (!st || typeof st !== 'object') st = {};
|
||||||
|
st.done = st.done || {}; st.tries = st.tries || {}; st.log = st.log || [];
|
||||||
|
st.stats = Object.assign({ batches: 0, events: 0, ended: 0, ignored: 0, skipped: 0, gaveUp: 0, refused: 0 }, st.stats || {});
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
function save() { if (!R || !R.dataDir) return; try { const t = FILE() + '.tmp'; fs.writeFileSync(t, JSON.stringify(load())); fs.renameSync(t, FILE()); } catch (e) { console.error('hubevents save', e.message); } }
|
||||||
|
function note(x) { const s = load(); s.log.push(Object.assign({ ts: Date.now() }, x)); if (s.log.length > 200) s.log = s.log.slice(-200); }
|
||||||
|
function init(deps) { R = deps || {}; load(); }
|
||||||
|
|
||||||
|
const sign = (ts, raw) => crypto.createHmac('sha256', SECRET()).update(String(ts) + '\n' + raw).digest('hex');
|
||||||
|
function verify(headers, raw) {
|
||||||
|
if (SECRET().length < 32) return false;
|
||||||
|
const ts = String(headers['x-hub-ts'] || ''), sig = String(headers['x-hub-sig'] || '');
|
||||||
|
if (!/^\d{10,16}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 5 * 60000 || !/^[0-9a-f]{64}$/.test(sig)) return false;
|
||||||
|
const want = sign(ts, raw);
|
||||||
|
return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig));
|
||||||
|
}
|
||||||
|
// the hub person by hub id (null = the hub does not know them); throws when the hub does not answer
|
||||||
|
async function resolveId(id) {
|
||||||
|
const raw = JSON.stringify({ id }); const ts = String(Date.now());
|
||||||
|
const r = await fetch(BASE() + '/v1/resolve', { method: 'POST', body: raw, signal: AbortSignal.timeout(10000),
|
||||||
|
headers: { 'Content-Type': 'application/json', 'X-Hub-Site': SITE(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sign(ts, raw) } });
|
||||||
|
if (r.status !== 200) throw new Error('hub resolve ' + r.status);
|
||||||
|
const j = await r.json(); return j && j.person && typeof j.person === 'object' ? j.person : null;
|
||||||
|
}
|
||||||
|
// every wallet the hub holds for a person: the main wallet and each contract's wallet
|
||||||
|
function walletsOf(p) {
|
||||||
|
const out = new Set(); if (!p) return [];
|
||||||
|
if (WALLET_RE.test(lc(p.wallet))) out.add(lc(p.wallet));
|
||||||
|
for (const w of Object.values(p.contractWallets || {})) if (WALLET_RE.test(lc(w))) out.add(lc(w));
|
||||||
|
return [...out];
|
||||||
|
}
|
||||||
|
// the shared test: does this session / member belong to the person?
|
||||||
|
function matcher(who) {
|
||||||
|
const ws = new Set(who.wallets || []), hs = new Set(who.walletHashes || []), eh = who.emailHash || null, id = who.personId || null;
|
||||||
|
return x => {
|
||||||
|
if (!x) return false;
|
||||||
|
for (const w of [x.address, x.wallet, x.hubWallet]) { const v = lc(w); if (WALLET_RE.test(v) && (ws.has(v) || hs.has(sha(v)))) return true; }
|
||||||
|
if (eh && x.email && sha(x.email) === eh) return true;
|
||||||
|
if (id && (x.hubId === id || x.key === id)) return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async function apply(ev) {
|
||||||
|
if (!ACTS.has(ev.type) || !ev.personId) return 'ignored';
|
||||||
|
const who = { type: ev.type, personId: String(ev.personId), at: Number(ev.at) || Date.now(), wallets: [], walletHashes: [], emailHash: null };
|
||||||
|
if (ev.type === 'member.erased') {
|
||||||
|
const d = ev.data || {};
|
||||||
|
who.walletHashes = (Array.isArray(d.walletHashes) ? d.walletHashes : []).map(lc).filter(h => HASH_RE.test(h)).slice(0, 50);
|
||||||
|
who.emailHash = HASH_RE.test(lc(d.emailHash)) ? lc(d.emailHash) : null;
|
||||||
|
} else {
|
||||||
|
const p = await resolveId(who.personId); // throws: the hub sends it again
|
||||||
|
if (!p) return 'ignored';
|
||||||
|
who.wallets = walletsOf(p);
|
||||||
|
}
|
||||||
|
who.before = who.at + SKEW; // sessions made after the event are fresh sign-ins and stay
|
||||||
|
who.match = matcher(who);
|
||||||
|
const n = Number(await R.end(who)) || 0;
|
||||||
|
note({ type: ev.type, seq: ev.seq, sessions: n });
|
||||||
|
if (n) { load().stats.ended += n; return 'applied'; }
|
||||||
|
return 'none';
|
||||||
|
}
|
||||||
|
function prune() {
|
||||||
|
const s = load(); const seqs = Object.keys(s.done).map(Number).sort((a, b) => a - b);
|
||||||
|
for (const q of seqs.slice(0, Math.max(0, seqs.length - KEEP))) delete s.done[q];
|
||||||
|
}
|
||||||
|
async function handle(events) {
|
||||||
|
const s = load(); s.stats.batches++; let failed = null;
|
||||||
|
for (const ev of Array.isArray(events) ? events : []) {
|
||||||
|
const seq = Number(ev && ev.seq); if (!seq) continue;
|
||||||
|
if (s.done[seq]) { s.stats.skipped++; continue; }
|
||||||
|
s.stats.events++;
|
||||||
|
try {
|
||||||
|
const r = await apply(ev);
|
||||||
|
s.done[seq] = Date.now(); delete s.tries[seq];
|
||||||
|
if (r === 'ignored') s.stats.ignored++;
|
||||||
|
} catch (e) {
|
||||||
|
s.tries[seq] = (s.tries[seq] || 0) + 1;
|
||||||
|
console.error('hubevents', seq, ev.type, e.message);
|
||||||
|
if (s.tries[seq] >= TRIES) { s.done[seq] = Date.now(); delete s.tries[seq]; s.stats.gaveUp++; note({ type: 'gave-up', seq, event: ev.type, error: String(e.message).slice(0, 160) }); continue; }
|
||||||
|
failed = e; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prune(); save();
|
||||||
|
return failed ? { status: 503, body: { error: 'retry' } } : { status: 200, body: { ok: true } };
|
||||||
|
}
|
||||||
|
// the POST /api/hub/events handler -> { status, body }. Batches run one at a time.
|
||||||
|
function receive(headers, raw) {
|
||||||
|
if (!R || !on()) return Promise.resolve({ status: 404, body: { error: 'not found' } });
|
||||||
|
if (!verify(headers || {}, String(raw || ''))) { load().stats.refused++; return Promise.resolve({ status: 401, body: { error: 'unauthorized' } }); }
|
||||||
|
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return Promise.resolve({ status: 400, body: { error: 'bad json' } }); }
|
||||||
|
const run = chain_.then(() => handle(b && b.events)); chain_ = run.catch(() => {}); return run;
|
||||||
|
}
|
||||||
|
function view() { const s = load(); return { on: on(), stats: s.stats, waiting: Object.keys(s.tries).length, log: s.log.slice(-20) }; }
|
||||||
|
|
||||||
|
module.exports = { init, receive, view, on, verify, walletsOf, matcher, sha, _reset: () => { st = null; chain_ = Promise.resolve(); } };
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
// Knowledge base behind the site assistant (Marty's support-desk plan, 2026-10-20).
|
||||||
|
// The chatbot answers from maintained entries, and good support replies become entries.
|
||||||
|
//
|
||||||
|
// An entry: { id, title, questions[], answer, tags[], pattern, handoff, order, source, ticketRef,
|
||||||
|
// updated, created, edited, deleted, seedHash }
|
||||||
|
// pattern optional regex (case-insensitive). Entries with one are the instant CANNED fast path:
|
||||||
|
// the first pattern that matches (lowest order) is the reply, no AI call. The CANNED list
|
||||||
|
// in chatbot.js seeds these, so there is ONE source: edit the answer here and the fast
|
||||||
|
// path serves the new text.
|
||||||
|
// source canned | faq | ticket | admin
|
||||||
|
//
|
||||||
|
// Retrieval: BM25 over title, question variants and tags, plus the answer text at a low weight, with
|
||||||
|
// word bigrams so phrase overlap counts more than scattered words. No embeddings, no external calls.
|
||||||
|
// The top hits go into the AI system prompt as "Knowledge base" context (chatbot.js).
|
||||||
|
//
|
||||||
|
// Seeds stay in step with the code: an entry that came from a seed and was never edited in the admin
|
||||||
|
// pane is refreshed when the seed text changes; an edited one is left alone; a deleted seed stays
|
||||||
|
// deleted (tombstone row), and a seed dropped from the code is retired unless an admin edited it.
|
||||||
|
//
|
||||||
|
// Store: DATA_DIR/kb.json (written to a temp file and renamed), which docstore.js keeps in MySQL when DOCSTORE_URL is set
|
||||||
|
// (Marty's database rule). Ported from LinkSpin's kb.js (2026-11-15); keep the scoring and seed rules in step.
|
||||||
|
//
|
||||||
|
// NETWORK (2026-11-15, netkb.js): the other network sites' entries, read from the hub, sit in the same index. This site's
|
||||||
|
// own entries are boosted first (HOME_BOOST); a question that names another site boosts that site's entries instead
|
||||||
|
// (NAMED_BOOST). Other sites' entries never take the instant-answer fast path: they only ride along as context, labelled
|
||||||
|
// with the site and the link to send people to. This site's own entries are published to the hub (netkb.publish).
|
||||||
|
// The SAME file ships in ViralAdBlitz, DownlineHydra, 5xYourTeam, Viral Banner Blitz, Downline Banners and Stack POL.
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
let netkb = null; try { netkb = require('./netkb'); } catch (e) {}
|
||||||
|
|
||||||
|
let DATA_DIR = null, SEEDS = [], ready = null, SITE_URL = '', HELP_TEXT = '', MEMORY = false;
|
||||||
|
let cache = null, cacheAt = 0, index = null, netVer = '';
|
||||||
|
const TTL = 30000; // two app copies share the volume for about 30 s during a deploy: re-read now and then
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- text + scoring (pure, unit-tested)
|
||||||
|
const STOP = new Set(('a an and are as at be been being but by can could do does did doing for from has have having how i if in into is it its '
|
||||||
|
+ 'me my of on or our ours so than that the their them then there these they this those to too us was we were what when where which who whom why '
|
||||||
|
+ 'will with would you your yours im ive id am just also any about please hi hello hey thanks thank ok okay really very much some there here '
|
||||||
|
+ 'should shall may might must anyone someone something thing things want wanted like know tell').split(' '));
|
||||||
|
const SYN = { paid: 'pay', payment: 'pay', payments: 'pay', paying: 'pay', withdrawal: 'withdraw', withdrawals: 'withdraw', cashout: 'withdraw',
|
||||||
|
signup: 'join', register: 'join', registration: 'join', joining: 'join', joined: 'join', login: 'log', logged: 'log', logout: 'log', signin: 'log',
|
||||||
|
wallets: 'wallet', email: 'email', mail: 'email', pol: 'pol', matic: 'pol', prices: 'price', pricing: 'price', cost: 'price', costs: 'price',
|
||||||
|
ads: 'ad', advert: 'ad', adverts: 'ad', advertising: 'ad', referrals: 'referral', refer: 'referral', referring: 'referral', referred: 'referral' };
|
||||||
|
function stem(w) {
|
||||||
|
if (SYN[w]) return SYN[w];
|
||||||
|
if (w.length > 6 && w.endsWith('able')) return w.slice(0, -4);
|
||||||
|
if (w.length > 5 && w.endsWith('ing')) return w.slice(0, -3);
|
||||||
|
if (w.length > 4 && w.endsWith('ies')) return w.slice(0, -3) + 'y';
|
||||||
|
if (w.length > 4 && w.endsWith('ed') && !w.endsWith('eed')) return w.slice(0, -2);
|
||||||
|
if (w.length > 3 && w.endsWith('s') && !w.endsWith('ss') && !w.endsWith('us')) return w.slice(0, -1);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
function words(text) {
|
||||||
|
return String(text || '').toLowerCase().replace(/['’]/g, '').replace(/[^a-z0-9$]+/g, ' ').split(' ')
|
||||||
|
.filter(w => w && !STOP.has(w) && (w.length > 1 || /\d/.test(w))).map(stem);
|
||||||
|
}
|
||||||
|
// unigrams + bigrams of the content words: "coinbase account" scores as a phrase, not two loose words
|
||||||
|
function terms(text) {
|
||||||
|
const w = words(text), out = w.slice();
|
||||||
|
for (let i = 0; i + 1 < w.length; i++) out.push(w[i] + '_' + w[i + 1]);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
const FIELDS = { title: 2.0, questions: 2.5, tags: 2.0, answer: 0.35 };
|
||||||
|
const K1 = 1.2, B = 0.75;
|
||||||
|
function fieldText(e, f) {
|
||||||
|
if (f === 'questions') return (e.questions || []).join(' . ');
|
||||||
|
if (f === 'tags') return (e.tags || []).join(' . ');
|
||||||
|
return e[f] || '';
|
||||||
|
}
|
||||||
|
function buildIndex(entries) {
|
||||||
|
const docs = entries.map(e => {
|
||||||
|
const d = { e, f: {} };
|
||||||
|
for (const f of Object.keys(FIELDS)) {
|
||||||
|
const t = terms(fieldText(e, f)), tf = new Map();
|
||||||
|
for (const x of t) tf.set(x, (tf.get(x) || 0) + 1);
|
||||||
|
d.f[f] = { tf, len: t.length };
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
const df = new Map(), avg = {};
|
||||||
|
for (const f of Object.keys(FIELDS)) avg[f] = docs.reduce((s, d) => s + d.f[f].len, 0) / Math.max(1, docs.length) || 1;
|
||||||
|
for (const d of docs) {
|
||||||
|
const seen = new Set();
|
||||||
|
for (const f of Object.keys(FIELDS)) for (const t of d.f[f].tf.keys()) seen.add(t);
|
||||||
|
for (const t of seen) df.set(t, (df.get(t) || 0) + 1);
|
||||||
|
}
|
||||||
|
return { docs, df, avg, n: docs.length };
|
||||||
|
}
|
||||||
|
const HOME_BOOST = 2, NAMED_BOOST = 3;
|
||||||
|
// which network sites a question names, by the site name or a short alias ("dlb", "vbb", "iap", ...)
|
||||||
|
const ALIASES = { iap: ['iap', 'instant ad pay'], linkspin: ['link spin'], bannerline: ['dlb', 'downline banner', 'downline banners'], vbb: ['vbb', 'viral banner'],
|
||||||
|
viraladblitz: ['vab', 'viral ad blitz'], downlinehydra: ['hydra', 'dh'], fivex: ['5x', '5x your team', 'five x', 'the draft'], stackpol: ['stack pol', 'stackpol'] };
|
||||||
|
const norm = s => ' ' + String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim() + ' ';
|
||||||
|
function namedSites(query, idx) {
|
||||||
|
const q = norm(query); const out = new Set();
|
||||||
|
for (const s of (idx && idx.sites) || []) {
|
||||||
|
const names = [s.name, s.site].concat(ALIASES[s.site] || []).map(norm);
|
||||||
|
if (names.some(n => n.trim() && q.includes(n))) out.add(s.site);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// does the question name a network site other than this one (hub site id `self`)? Then the home fast path stands aside and the
|
||||||
|
// answer comes from retrieval over the whole network (a "how much" about another site must not get this site's price).
|
||||||
|
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz',
|
||||||
|
downlinehydra: 'DownlineHydra', fivex: '5xYourTeam', stackpol: 'Stack POL', earnerscorner: 'Earners Corner' };
|
||||||
|
function namesOther(query, self) {
|
||||||
|
const q = norm(query); const out = [];
|
||||||
|
const ids = new Set(Object.keys(NAMES).concat(((index && index.sites) || []).map(s => s.site)));
|
||||||
|
for (const id of ids) {
|
||||||
|
if (id === self) continue;
|
||||||
|
const s = ((index && index.sites) || []).find(x => x.site === id) || {};
|
||||||
|
const names = [s.name, NAMES[id], id.length > 3 ? id : ''].concat(ALIASES[id] || []).filter(Boolean).map(norm);
|
||||||
|
if (names.some(n => n.trim() && q.includes(n))) out.push(id);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
function rank(idx, query, k) {
|
||||||
|
if (!idx || !idx.n) return [];
|
||||||
|
const qt = [...new Set(terms(query))];
|
||||||
|
if (!qt.length) return [];
|
||||||
|
const named = namedSites(query, idx);
|
||||||
|
const out = [];
|
||||||
|
for (const d of idx.docs) {
|
||||||
|
let s = 0;
|
||||||
|
for (const t of qt) {
|
||||||
|
const n = idx.df.get(t); if (!n) continue;
|
||||||
|
const idf = Math.log(1 + (idx.n - n + 0.5) / (n + 0.5)) * (t.includes('_') ? 1.5 : 1);
|
||||||
|
for (const f of Object.keys(FIELDS)) {
|
||||||
|
const tf = d.f[f].tf.get(t); if (!tf) continue;
|
||||||
|
s += FIELDS[f] * idf * (tf * (K1 + 1)) / (tf + K1 * (1 - B + B * d.f[f].len / idx.avg[f]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (s > 0 && d.e.site) s *= named.has(d.e.site) ? NAMED_BOOST : 1;
|
||||||
|
else if (s > 0) s *= named.size ? 1 : HOME_BOOST;
|
||||||
|
if (s > 0) out.push({ entry: d.e, score: Math.round(s * 100) / 100 });
|
||||||
|
}
|
||||||
|
out.sort((a, b) => b.score - a.score);
|
||||||
|
return out.slice(0, k || 5);
|
||||||
|
}
|
||||||
|
// keep hits that are close to the best one, and only when the best is a real match
|
||||||
|
const MIN_SCORE = 3;
|
||||||
|
function relevant(hits) {
|
||||||
|
if (!hits.length || hits[0].score < MIN_SCORE) return [];
|
||||||
|
const floor = Math.max(MIN_SCORE, hits[0].score * 0.3);
|
||||||
|
return hits.filter(h => h.score >= floor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- store
|
||||||
|
const mem = { entries: [] }; // a site with no data volume (Stack POL): seeds in memory only
|
||||||
|
const J = {
|
||||||
|
file: () => path.join(DATA_DIR, 'kb.json'),
|
||||||
|
async ensure() {},
|
||||||
|
async all() { if (MEMORY) return mem.entries.slice(); try { const d = JSON.parse(fs.readFileSync(J.file(), 'utf8')); return Array.isArray(d.entries) ? d.entries : []; } catch (e) { return []; } },
|
||||||
|
async put(e) {
|
||||||
|
const all = await J.all(), i = all.findIndex(x => x.id === e.id);
|
||||||
|
if (i >= 0) all[i] = e; else all.push(e);
|
||||||
|
if (MEMORY) { mem.entries = all; return; }
|
||||||
|
const tmp = J.file() + '.tmp';
|
||||||
|
fs.writeFileSync(tmp, JSON.stringify({ entries: all }));
|
||||||
|
fs.renameSync(tmp, J.file());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const store = () => J;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- seeds
|
||||||
|
const SEED_FIELDS = ['title', 'questions', 'answer', 'tags', 'pattern', 'handoff', 'order', 'source'];
|
||||||
|
const seedHash = s => crypto.createHash('sha1').update(JSON.stringify(SEED_FIELDS.map(f => s[f] == null ? null : s[f]))).digest('hex');
|
||||||
|
function seedEntry(s) {
|
||||||
|
return { id: s.id, title: s.title, questions: s.questions || [], answer: s.answer, tags: s.tags || [], pattern: s.pattern || '', handoff: !!s.handoff,
|
||||||
|
order: s.order == null ? null : s.order, source: s.source || 'faq' };
|
||||||
|
}
|
||||||
|
async function syncSeeds() {
|
||||||
|
const all = await store().all(), byId = new Map(all.map(e => [e.id, e])), now = Date.now();
|
||||||
|
const seedIds = new Set(SEEDS.map(s => s.id));
|
||||||
|
let added = 0, refreshed = 0, retired = 0;
|
||||||
|
for (const s of SEEDS) {
|
||||||
|
const h = seedHash(seedEntry(s)), cur = byId.get(s.id);
|
||||||
|
if (!cur) { await store().put(Object.assign(seedEntry(s), { ticketRef: '', seedHash: h, edited: false, deleted: false, created: now, updated: now })); added++; }
|
||||||
|
else if (!cur.deleted && !cur.edited && cur.seedHash !== h) { await store().put(Object.assign({}, cur, seedEntry(s), { seedHash: h, updated: now })); refreshed++; }
|
||||||
|
}
|
||||||
|
// a seed taken out of the code goes with it, unless an admin has made the entry their own (guard: a broken seed list retires nothing)
|
||||||
|
if (SEEDS.length >= 10) for (const e of all) if (e.seedHash && !e.edited && !e.deleted && !seedIds.has(e.id)) { await store().put(Object.assign({}, e, { deleted: true, updated: now })); retired++; }
|
||||||
|
if (added || refreshed || retired) console.log('kb: seeds synced, ' + added + ' added, ' + refreshed + ' refreshed, ' + retired + ' retired');
|
||||||
|
}
|
||||||
|
|
||||||
|
// opts: { dataDir (null = memory only), seeds, siteUrl, helpText (where a member gets a person) }
|
||||||
|
function init(opts) {
|
||||||
|
DATA_DIR = opts.dataDir || null; MEMORY = !DATA_DIR; SEEDS = opts.seeds || []; cache = null; index = null; mem.entries = [];
|
||||||
|
SITE_URL = String(opts.siteUrl || '').replace(/\/+$/, ''); HELP_TEXT = opts.helpText || 'network support at https://instantadpay.com/support';
|
||||||
|
ready = (async () => { await store().ensure(); await syncSeeds(); })().catch(e => { console.error('kb init', e.message); });
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
// this site's own entries, for netkb.publish
|
||||||
|
async function own() { await load(); return cache.slice(); }
|
||||||
|
async function load(force) {
|
||||||
|
if (ready) await ready;
|
||||||
|
if (!force && cache && Date.now() - cacheAt < TTL && (!netkb || netkb.version() === netVer)) return cache; // a new network set rebuilds at once
|
||||||
|
const all = await store().all();
|
||||||
|
cache = all.filter(e => !e.deleted); cacheAt = Date.now(); rx.clear(); netVer = netkb ? netkb.version() : '';
|
||||||
|
index = buildIndex(cache.concat(netkb ? netkb.remote() : [])); index.sites = netkb ? netkb.sites() : [];
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
const rx = new Map();
|
||||||
|
function compiled(src) {
|
||||||
|
if (!rx.has(src)) { let r = null; try { r = new RegExp(src, 'i'); } catch (e) {} rx.set(src, r); }
|
||||||
|
return rx.get(src);
|
||||||
|
}
|
||||||
|
const byOrder = (a, b) => (a.order == null ? 1e9 : a.order) - (b.order == null ? 1e9 : b.order) || a.updated - b.updated;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- the chatbot side
|
||||||
|
async function fastPath(msg) {
|
||||||
|
const list = (await load()).filter(e => e.pattern).sort(byOrder);
|
||||||
|
for (const e of list) { const r = compiled(e.pattern); if (r && r.test(msg)) return e; }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
async function search(query, k) { await load(); return rank(index, query, k || 5); }
|
||||||
|
async function context(query, k) { return relevant(await search(query, k || 6)); }
|
||||||
|
const label = e => e.site ? ' (about ' + e.siteName + ', another network site; send people to ' + e.go + ')' : '';
|
||||||
|
function promptBlock(hits) {
|
||||||
|
const unsure = 'say "I\'m not sure, ask support" and point to ' + HELP_TEXT + '.';
|
||||||
|
if (!hits.length) return 'KNOWLEDGE BASE: no entry matches this question. If the FACTS above do not answer it either, ' + unsure + ' Do not guess.';
|
||||||
|
return 'KNOWLEDGE BASE (maintained answers, most relevant first). Answer from these when one fits: keep its facts, numbers and links exactly, in your own short words. '
|
||||||
|
+ 'If none of them and none of the FACTS answer the question, ' + unsure + ' Never guess.\n'
|
||||||
|
+ hits.map((h, i) => '[' + (i + 1) + '] ' + h.entry.title + label(h.entry) + '\nAsked as: ' + (h.entry.questions || []).slice(0, 4).join(' | ') + '\nAnswer: ' + h.entry.answer).join('\n\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- the admin side
|
||||||
|
const clean = s => String(s == null ? '' : s).replace(/\s*[—―]\s*/g, ', ').replace(/(\d)\s*–\s*(\d)/g, '$1-$2').replace(/\s*–\s*/g, ', ').replace(/\r\n/g, '\n').trim(); // house rule: no em dashes in member-facing text
|
||||||
|
function validate(o, cur) {
|
||||||
|
o = o || {};
|
||||||
|
const questions = (Array.isArray(o.questions) ? o.questions : String(o.questions || '').split('\n')).map(clean).filter(Boolean).map(q => q.slice(0, 300)).slice(0, 15);
|
||||||
|
const tags = (Array.isArray(o.tags) ? o.tags : String(o.tags || '').split(',')).map(t => clean(t).toLowerCase().slice(0, 40)).filter(Boolean).slice(0, 15);
|
||||||
|
const answer = clean(o.answer).slice(0, 4000);
|
||||||
|
const title = (clean(o.title) || questions[0] || '').slice(0, 200);
|
||||||
|
const pattern = String(o.pattern == null ? (cur ? cur.pattern : '') : o.pattern).trim().slice(0, 2000);
|
||||||
|
if (!title) return { error: 'Give the entry a title or at least one question.' };
|
||||||
|
if (!answer) return { error: 'The answer is empty.' };
|
||||||
|
if (pattern) { try { new RegExp(pattern, 'i'); } catch (e) { return { error: 'The instant-answer pattern is not a valid regular expression: ' + e.message }; } }
|
||||||
|
const order = o.order === '' || o.order == null ? (cur ? cur.order : null) : Number(o.order);
|
||||||
|
return { title, questions, tags, answer, pattern, handoff: o.handoff == null ? !!(cur && cur.handoff) : !!o.handoff, order: Number.isFinite(order) ? Math.round(order) : null };
|
||||||
|
}
|
||||||
|
async function list(q) {
|
||||||
|
const all = (await load(true)).slice();
|
||||||
|
if (!q) return all.sort((a, b) => b.updated - a.updated);
|
||||||
|
const ranked = rank(index, q, 50).filter(h => !h.entry.site).map(h => Object.assign({ score: h.score }, h.entry));
|
||||||
|
const lc = String(q).toLowerCase(), seen = new Set(ranked.map(e => e.id));
|
||||||
|
const plain = all.filter(e => !seen.has(e.id) && (e.id.includes(lc) || (e.title + ' ' + e.answer + ' ' + (e.ticketRef || '')).toLowerCase().includes(lc)));
|
||||||
|
return ranked.concat(plain);
|
||||||
|
}
|
||||||
|
async function get(id) { return (await load(true)).find(e => e.id === String(id)) || null; }
|
||||||
|
async function create(o) {
|
||||||
|
const v = validate(o); if (v.error) return v;
|
||||||
|
const now = Date.now(), id = 'kb-' + now.toString(36) + crypto.randomBytes(2).toString('hex');
|
||||||
|
const src = ['ticket', 'admin'].includes(o.source) ? o.source : 'admin';
|
||||||
|
const e = Object.assign(v, { id, source: src, ticketRef: String(o.ticketRef || '').slice(0, 20), seedHash: '', edited: true, deleted: false, created: now, updated: now });
|
||||||
|
await store().put(e); await load(true); if (netkb) netkb.publishSoon();
|
||||||
|
return { ok: true, entry: e };
|
||||||
|
}
|
||||||
|
async function update(id, o) {
|
||||||
|
const cur = await get(id); if (!cur) return { error: 'Entry not found.' };
|
||||||
|
const v = validate(o, cur); if (v.error) return v;
|
||||||
|
const e = Object.assign({}, cur, v, { edited: true, updated: Date.now() });
|
||||||
|
await store().put(e); await load(true); if (netkb) netkb.publishSoon();
|
||||||
|
return { ok: true, entry: e };
|
||||||
|
}
|
||||||
|
async function remove(id) {
|
||||||
|
const cur = await get(id); if (!cur) return { error: 'Entry not found.' };
|
||||||
|
await store().put(Object.assign({}, cur, { deleted: true, updated: Date.now() })); await load(true); if (netkb) netkb.publishSoon();
|
||||||
|
return { ok: true };
|
||||||
|
}
|
||||||
|
// newest change made by a person (admin pane or a saved ticket reply), as a Central-time day. The chatbot-sync
|
||||||
|
// guard compares it with release-note dates. Seed refreshes do not count: those follow chatbot.js, whose
|
||||||
|
// KNOWLEDGE_DATE already speaks for the code.
|
||||||
|
const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||||
|
async function stamp() {
|
||||||
|
const all = await load();
|
||||||
|
const max = all.reduce((m, e) => e.edited ? Math.max(m, e.updated || 0) : m, 0);
|
||||||
|
return { updated: max ? ctDay(max) : '', count: all.length };
|
||||||
|
}
|
||||||
|
async function test(question) {
|
||||||
|
const fast = await fastPath(String(question || ''));
|
||||||
|
const hits = await search(String(question || ''), 8), used = new Set(relevant(hits).map(h => h.entry.id));
|
||||||
|
return { fast: fast ? { id: fast.id, title: fast.title } : null, ranked: hits.map(h => ({ id: h.entry.id, site: h.entry.site || '', title: h.entry.title, score: h.score, used: used.has(h.entry.id) })) };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { init, load, own, namesOther, fastPath, search, context, promptBlock, list, get, create, update, remove, stamp, test,
|
||||||
|
_pure: { words, terms, buildIndex, rank, relevant, validate, seedHash, namedSites, MIN_SCORE, HOME_BOOST, NAMED_BOOST } };
|
||||||
@@ -23,10 +23,16 @@ function enter(id) {
|
|||||||
}
|
}
|
||||||
function cycleOut(id) {
|
function cycleOut(id) {
|
||||||
const b = store.banner(id); if (!b) return null;
|
const b = store.banner(id); if (!b) return null;
|
||||||
|
// taken down by the admin (Marty 2026-11-15): its place rode out on time, but it never cycles and never earns
|
||||||
|
if (b.down) { b.state = 'ended'; b.endedAt = Date.now(); store.saveBanner(b); return null; }
|
||||||
b.state = 'cycled'; b.cycledAt = Date.now(); store.saveBanner(b);
|
b.state = 'cycled'; b.cycledAt = Date.now(); store.saveBanner(b);
|
||||||
|
return recordCycle(b);
|
||||||
|
}
|
||||||
|
// the cycle reward: one ledger row (also used when the admin restores a banner whose place rode out while it was taken down)
|
||||||
|
function recordCycle(b, extra) {
|
||||||
const S = store.state(); S.totals.cycles++; S.totals.views += C().viewsPerCycle; store.bump('cycles');
|
const S = store.state(); S.totals.cycles++; S.totals.views += C().viewsPerCycle; store.bump('cycles');
|
||||||
const m = store.member(b.owner);
|
const m = store.member(b.owner);
|
||||||
const e = store.addLedger({ bannerId: b.id, owner: b.owner, username: (m && m.username) || null, views: C().viewsPerCycle, day: store.ctDay(), status: 'recorded' });
|
const e = store.addLedger(Object.assign({ bannerId: b.id, owner: b.owner, username: (m && m.username) || null, views: C().viewsPerCycle, day: store.ctDay(), status: 'recorded' }, extra || {}));
|
||||||
if (onCycle) try { onCycle(b, e); } catch (x) {}
|
if (onCycle) try { onCycle(b, e); } catch (x) {}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -42,9 +48,10 @@ function shift() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// a new banner (already checked and paid for with a credit)
|
// a new banner (already checked and paid for with a credit)
|
||||||
function post(owner, img, link, via) {
|
// spin: a LinkSpin Banner Spin { id, name, size } when the banner is one (the image rotates on LinkSpin, the link is its click link)
|
||||||
|
function post(owner, img, link, via, spin) {
|
||||||
const S = store.state();
|
const S = store.state();
|
||||||
const b = store.addBanner({ owner: String(owner).toLowerCase(), img, link, via: via || 'credit', state: 'queued', clicks: 0 });
|
const b = store.addBanner(Object.assign({ owner: String(owner).toLowerCase(), img, link, via: via || 'credit', state: 'queued', clicks: 0 }, spin ? { spin } : {}));
|
||||||
S.totals.posts++; store.bump('posts');
|
S.totals.posts++; store.bump('posts');
|
||||||
if (!S.queue.length && S.loop.length < C().loopSize) enter(b.id);
|
if (!S.queue.length && S.loop.length < C().loopSize) enter(b.id);
|
||||||
else { S.queue.push(b.id); if (S.progress >= C().perShift) { S.progress = 0; shift(); } }
|
else { S.queue.push(b.id); if (S.progress >= C().perShift) { S.progress = 0; shift(); } }
|
||||||
@@ -117,8 +124,11 @@ function memberWeek(addr) {
|
|||||||
// ---- views for pages ----
|
// ---- views for pages ----
|
||||||
// the banner look (bought per banner, SKU 3): a highlighted border and a hover teaser (the member's line, else the link's site)
|
// the banner look (bought per banner, SKU 3): a highlighted border and a hover teaser (the member's line, else the link's site)
|
||||||
const hostOf = l => { try { return new URL(l).hostname.replace(/^www\./, ''); } catch (e) { return ''; } };
|
const hostOf = l => { try { return new URL(l).hostname.replace(/^www\./, ''); } catch (e) { return ''; } };
|
||||||
function tile(b) { const m = store.member(b.owner); const t = { id: b.id, img: b.img, href: '/go/' + b.id, owner: (m && m.username) ? '@' + m.username : null };
|
// a banner the admin took down keeps its place (nobody else moves) but shows as a house tile: no image, owner, link or id of its own
|
||||||
if (b.look) { t.look = true; t.teaser = b.teaser || hostOf(b.link); } return t; }
|
const houseTile = b => ({ id: 'h' + b.id, house: true, img: '/art/tile-house.svg', href: '/my', owner: null });
|
||||||
|
function tile(b) { if (b.down) return houseTile(b); const m = store.member(b.owner); const t = { id: b.id, img: b.img, href: '/go/' + b.id, owner: (m && m.username) ? '@' + m.username : null };
|
||||||
|
if (b.spin) t.spin = true;
|
||||||
|
if (b.look) { t.look = true; t.teaser = b.teaser || (b.spin && b.spin.name) || hostOf(b.link); } return t; }
|
||||||
function view(queueShow) {
|
function view(queueShow) {
|
||||||
const S = store.state();
|
const S = store.state();
|
||||||
return { loopSize: C().loopSize, perShift: C().perShift, progress: S.progress, waiting: S.queue.length,
|
return { loopSize: C().loopSize, perShift: C().perShift, progress: S.progress, waiting: S.queue.length,
|
||||||
@@ -133,5 +143,11 @@ function placeOf(b) {
|
|||||||
if (b.state === 'loop') { const i = S.loop.indexOf(b.id); return { state: 'loop', place: i + 1, of: C().loopSize, shiftsToRideOut: Math.max(1, C().loopSize - i) }; }
|
if (b.state === 'loop') { const i = S.loop.indexOf(b.id); return { state: 'loop', place: i + 1, of: C().loopSize, shiftsToRideOut: Math.max(1, C().loopSize - i) }; }
|
||||||
return { state: b.state };
|
return { state: b.state };
|
||||||
}
|
}
|
||||||
|
// a member-facing place: a taken-down banner says so (with the admin's reason), whatever its slot is doing
|
||||||
|
function memberPlace(b) {
|
||||||
|
const p = placeOf(b);
|
||||||
|
if (!b.down) return p;
|
||||||
|
return { state: 'down', slot: p.state, downAt: b.down.at, downReason: b.down.reason, creditBack: !!b.down.creditBack };
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = { hostOf, init, post, shift, verifiedVisit, canCount, rebuildIndex, leaders, memberWeek, view, placeOf, normalize };
|
module.exports = { hostOf, init, post, shift, verifiedVisit, canCount, rebuildIndex, leaders, memberWeek, view, placeOf, memberPlace, recordCycle, normalize };
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// LinkSpin Banner Spins in Viral Banner Blitz (Marty 2026-11-14: "make sure Viral Banner Blitz incorporates banner spins that could
|
||||||
|
// be pulled in just like downline banners"). The Downline Banners pattern:
|
||||||
|
// 1. My Banners: "Use my LinkSpin Banner Spin" lists the member's 125x125 (or 250x250) Banner Spins and posts one as a banner (one
|
||||||
|
// credit, like any post). The banner's image is the spin's rotating image on LinkSpin and its link is the spin's click link,
|
||||||
|
// so clicks count in LinkSpin Reports under the member's "Viral Banner Blitz" source.
|
||||||
|
// 2. Fill: the splash shows members' Banner Spins in the loop's open places, and in the waiting line while nobody waits. Fill tiles
|
||||||
|
// are never loop banners: they are not in the loop list, never shift it, never cycle and never earn. One spin per member, no
|
||||||
|
// member who already has a banner on the page, no image twice (the board dedupe from Downline Banners).
|
||||||
|
// LinkSpin's partner endpoint /api/partner/bl/spins, called with { site: 'vbb' }, signed with NETWORK_SSO_SECRET:
|
||||||
|
// X-Net-Ts + X-Net-Sig = hex HMAC-SHA256('net.v1.' + ts + newline + raw body). LinkSpin answers for the account holding the wallet
|
||||||
|
// (else the account with the member's network username) only.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
let base = () => 'https://linkspin.app';
|
||||||
|
let members = () => [];
|
||||||
|
const HOST_RE = /^[a-z0-9.-]+\.[a-z]{2,}$/i;
|
||||||
|
|
||||||
|
async function call(body) {
|
||||||
|
const sec = String(process.env.NETWORK_SSO_SECRET || '').trim(); if (sec.length < 32) return { error: 'The LinkSpin link is not set up yet.' };
|
||||||
|
const raw = JSON.stringify(Object.assign({ site: 'vbb' }, body)); const ts = String(Date.now());
|
||||||
|
const sig = crypto.createHmac('sha256', sec).update('net.v1.' + ts + '\n' + raw).digest('hex');
|
||||||
|
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 8000);
|
||||||
|
try {
|
||||||
|
const r = await fetch(base() + '/api/partner/bl/spins', { method: 'POST', body: raw, signal: ac.signal, headers: { 'Content-Type': 'application/json', 'X-Net-Ts': ts, 'X-Net-Sig': sig } });
|
||||||
|
const j = await r.json().catch(() => ({})); return r.ok ? j : { error: j.error || 'LinkSpin did not answer. Try again in a minute.' };
|
||||||
|
} catch (e) { return { error: 'LinkSpin did not answer. Try again in a minute.' }; } finally { clearTimeout(t); }
|
||||||
|
}
|
||||||
|
// a member's spins: { account, username, host, spins: [{ id, name, code, size, paused, banners }] } or { error }
|
||||||
|
function list(addr, username) { return call({ wallet: String(addr).toLowerCase(), username: username || undefined }); }
|
||||||
|
// connect one spin: { use: { spinId, name, size, img, link, otherSource } } or { error }
|
||||||
|
function use(addr, username, spinId) { return call({ wallet: String(addr).toLowerCase(), username: username || undefined, spinId: Number(spinId) || 0 }); }
|
||||||
|
const showable = sp => !sp.paused && sp.banners > 0;
|
||||||
|
const imgUrl = (host, code) => 'https://' + host + '/i/' + code + '.gif';
|
||||||
|
|
||||||
|
// ---- fill: one showable spin per member, refreshed every 10 minutes ----
|
||||||
|
let SPINS = []; let lastRefresh = null;
|
||||||
|
async function refresh() {
|
||||||
|
const out = [];
|
||||||
|
for (const m of members()) {
|
||||||
|
const r = await list(m.address, m.username).catch(() => null);
|
||||||
|
if (!r || !r.account || !HOST_RE.test(String(r.host || ''))) continue;
|
||||||
|
const sp = (r.spins || []).find(showable); if (!sp || !/^[a-z0-9]+$/i.test(sp.code)) continue;
|
||||||
|
out.push({ owner: m.address, code: sp.code, img: imgUrl(r.host, sp.code), link: 'https://' + r.host + '/c/' + sp.code + '?placement=fill&s1=fill',
|
||||||
|
owner_name: r.username || m.username || null, title: sp.name });
|
||||||
|
}
|
||||||
|
SPINS = out; lastRefresh = { at: Date.now(), spins: out.length };
|
||||||
|
return out.length;
|
||||||
|
}
|
||||||
|
function set(list) { SPINS = Array.isArray(list) ? list : []; }
|
||||||
|
const codeOf = u => (String(u || '').match(/\/[ic]\/([a-z0-9]+)/i) || [])[1] || String(u || '');
|
||||||
|
function shuffled() { const a = SPINS.slice(); for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; }
|
||||||
|
// fill tiles for one splash view. pageOwners: addresses with a banner on the page (loop or waiting line); pageImgs: their images.
|
||||||
|
// -> { loop: tiles for the open loop places, queue: tiles for the empty waiting line }
|
||||||
|
function fill(o) {
|
||||||
|
const owners = new Set(o.pageOwners || []); const used = new Set((o.pageImgs || []).map(codeOf));
|
||||||
|
const pick = []; const want = Math.max(0, o.openPlaces || 0) + Math.max(0, o.queueSlots || 0);
|
||||||
|
for (const sp of shuffled()) {
|
||||||
|
if (pick.length >= want) break;
|
||||||
|
if ((sp.owner && owners.has(sp.owner)) || used.has(codeOf(sp.img))) continue;
|
||||||
|
used.add(codeOf(sp.img)); if (sp.owner) owners.add(sp.owner);
|
||||||
|
pick.push({ t: 'spin', img: sp.img, href: sp.link, owner: sp.owner_name ? '@' + sp.owner_name : null, title: sp.title || 'LinkSpin Banner Spin' });
|
||||||
|
}
|
||||||
|
const nLoop = Math.min(pick.length, Math.max(0, o.openPlaces || 0));
|
||||||
|
return { loop: pick.slice(0, nLoop), queue: pick.slice(nLoop) };
|
||||||
|
}
|
||||||
|
function init(o) {
|
||||||
|
base = o.base || base; members = o.members || members;
|
||||||
|
const first = Number(process.env.LS_SPINS_FIRST_MS || 20000), every = Number(process.env.LS_SPINS_EVERY_MS || 10 * 60000);
|
||||||
|
setTimeout(() => refresh().catch(() => {}), first).unref(); setInterval(() => refresh().catch(() => {}), every).unref();
|
||||||
|
}
|
||||||
|
function view() { return { fill: SPINS.length, at: lastRefresh ? lastRefresh.at : 0, lastRefresh }; }
|
||||||
|
|
||||||
|
module.exports = { init, list, use, refresh, set, fill, codeOf, showable, view };
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Network deals for this site's "Network Weekend" ribbon (Marty 2026-11-17). One source: the hub's public GET /v1/network-deals
|
||||||
|
// (HUB_URL). Cached 2 minutes, refreshed in the background, never waits on a slow hub (2.5 s timeout); hub down = no ribbon.
|
||||||
|
// The same file lives in every network site. Never RM Circle, never the games (the hub list never names them).
|
||||||
|
// The page (/assets/netweekend.js) switches the ribbon on and off by its own clock at startsAt / endsAt, so a cached copy never
|
||||||
|
// shows early or late. setLocal(fn) lets a site rewrite its own deal line from live data (for example a price read from chain),
|
||||||
|
// so the ribbon never shows a number the contract does not charge: fn(deal) returns the deal, a changed copy, or null to drop it.
|
||||||
|
const TTL = 2 * 60 * 1000;
|
||||||
|
let cache = { at: 0, body: { events: [] } };
|
||||||
|
let inflight = null;
|
||||||
|
let local = null;
|
||||||
|
|
||||||
|
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
|
||||||
|
const safeUrl = u => (/^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(u || '')) ? String(u) : '');
|
||||||
|
const str = (v, n) => String(v == null ? '' : v).slice(0, n || 300);
|
||||||
|
function clean(j) {
|
||||||
|
if (!j || !Array.isArray(j.events)) return null;
|
||||||
|
return { events: j.events.slice(0, 5).filter(e => e && e.id && !Number.isNaN(Date.parse(e.startsAt)) && !Number.isNaN(Date.parse(e.endsAt))).map(e => ({
|
||||||
|
id: str(e.id, 60), name: str(e.name, 60), tagline: str(e.tagline, 160), url: safeUrl(e.url), startsAt: e.startsAt, endsAt: e.endsAt,
|
||||||
|
days: e.days && typeof e.days === 'object' ? Object.fromEntries(Object.entries(e.days).slice(0, 20).map(([k, v]) => [str(k, 10), str(v, 40)])) : {},
|
||||||
|
deals: (Array.isArray(e.deals) ? e.deals : []).slice(0, 40).map(d => {
|
||||||
|
const x = { site: str(d.site, 30), name: str(d.name, 80), url: safeUrl(d.url), text: str(d.text), endsAt: Number.isNaN(Date.parse(d.endsAt)) ? e.endsAt : d.endsAt };
|
||||||
|
if (d.note) x.note = str(d.note, 120);
|
||||||
|
if (d.byDay && typeof d.byDay === 'object') x.byDay = Object.fromEntries(Object.entries(d.byDay).slice(0, 20).map(([k, v]) => [str(k, 10), str(v)]));
|
||||||
|
return x;
|
||||||
|
})
|
||||||
|
})) };
|
||||||
|
}
|
||||||
|
function refresh() {
|
||||||
|
if (inflight || process.env.NETWORK_DEALS_HUB === '0') return inflight;
|
||||||
|
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
|
||||||
|
inflight = fetch(hubUrl() + '/v1/network-deals', { signal: ac.signal })
|
||||||
|
.then(r => (r.ok ? r.json() : null))
|
||||||
|
.then(j => { const b = clean(j); if (b) cache = { at: Date.now(), body: b }; else cache.at = Date.now(); })
|
||||||
|
.catch(() => { cache.at = Date.now() - TTL + 30 * 1000; }) // hub down: try again in 30 s, keep the last good copy
|
||||||
|
.finally(() => { clearTimeout(t); inflight = null; });
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
function current() { if (Date.now() - cache.at > TTL) refresh(); return cache.body; }
|
||||||
|
function setLocal(fn) { local = typeof fn === 'function' ? fn : null; }
|
||||||
|
function withLocal(body, self) {
|
||||||
|
if (!local) return body;
|
||||||
|
return { events: body.events.map(e => Object.assign({}, e, { deals: e.deals.map(d => {
|
||||||
|
if (d.site !== self) return d;
|
||||||
|
try { const r = local(Object.assign({}, d)); return r === undefined ? d : r; } catch (err) { return d; }
|
||||||
|
}).filter(Boolean) })) };
|
||||||
|
}
|
||||||
|
// GET /api/network-deals: public, short cache, the same answer on every page. self = this site's network id (NETWORK_SITE_ID).
|
||||||
|
async function handle(req, res, self) {
|
||||||
|
if (!cache.at) { try { await refresh(); } catch (e) {} } // first ask after a boot waits for the hub once (2.5 s cap)
|
||||||
|
const me = String(self || process.env.NETWORK_SITE_ID || '').trim().toLowerCase();
|
||||||
|
const body = Object.assign({ self: me }, withLocal(current(), me));
|
||||||
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=60', 'X-Content-Type-Options': 'nosniff' });
|
||||||
|
res.end(JSON.stringify(body));
|
||||||
|
}
|
||||||
|
module.exports = { current, handle, refresh, setLocal, clean, _set: b => { cache = { at: Date.now(), body: clean(b) || { events: [] } }; } };
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
// Shared network knowledge, site side (Marty 2026-11-15: every network site's chatbot answers about the whole network, with its
|
||||||
|
// own site first). This site publishes its own knowledge-base entries to the network hub and reads the merged set back:
|
||||||
|
// PUT HUB_URL/v1/kb {name, url, entries} replaces this site's set (the hub skips a set it already holds)
|
||||||
|
// GET HUB_URL/v1/kb signed over an empty body, If-None-Match: the last version -> 304 when nothing changed
|
||||||
|
// Signed as HUB_SITE with HUB_SECRET (X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + "\n" + raw body)), like hubreport.js.
|
||||||
|
// The merged set is kept in memory and in DATA_DIR/netkb-cache.json (a MySQL document through docstore where the site has
|
||||||
|
// DOCSTORE_URL; written only when the version changes), so a hub outage at boot still answers about the other sites.
|
||||||
|
// Off when HUB_URL or a 32+ character HUB_SECRET is missing, or NETKB=0: the chatbot then answers about this site only.
|
||||||
|
//
|
||||||
|
// SEMANTIC MATCHING (Marty 2026-11-16): the hub matches a question by meaning against the whole network KB with the free core2
|
||||||
|
// embeddings model (POST HUB_URL/v1/kb/match). match() asks it with a strict timeout (NETKB_MATCH_MS, default 1500) and fails
|
||||||
|
// soft: an error or a timeout answers null and the next MATCH_PAUSE_MS skip the hub, so the chat never waits on a slow model and
|
||||||
|
// the site's own BM25 retrieval (kb.js) answers as before. route() turns a match into the chatbot's decision:
|
||||||
|
// - this site's own entry, raw score >= SEM.answer with a clear lead (or the instant-answer pattern agrees): the answer itself
|
||||||
|
// - the instant-answer pattern hit kept when the match agrees (its entry within SEM.agree of the top), or when the match has
|
||||||
|
// no idea (top below SEM.unsure); this site's own entries rank first unless another site is named or clearly closer
|
||||||
|
// - otherwise no instant answer (the regex is overruled by meaning); the entries >= SEM.context feed the AI prompt
|
||||||
|
// suggest() gives the support desk's new-ticket form the closest help answers (KB entries only) the same way, BM25 as the fallback.
|
||||||
|
// Off with NETKB_MATCH=0. Thresholds measured on bge-large-en-v1.5 over the network KB (2026-11-16). Tests: qa/netkb-semantic.test.mjs
|
||||||
|
// The SAME file ships in every network site (InstantAdPay, LinkSpin, ViralAdBlitz, DownlineHydra, 5xYourTeam, VBB, Downline
|
||||||
|
// Banners, Stack POL). Keep them identical.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const REFRESH_MS = 10 * 60 * 1000;
|
||||||
|
let O = null; // { dataDir, site, name, url, netId, entries: async () => [...], linkFor: (url) => link }
|
||||||
|
let merged = { version: '', sites: {}, entries: [] }, loadedAt = 0, publishedHash = '', pubTimer = null, timer = null;
|
||||||
|
const stats = { published: 0, publishErrors: 0, reads: 0, notModified: 0, readErrors: 0, lastError: null, lastPublishAt: 0, lastReadAt: 0 };
|
||||||
|
|
||||||
|
const hubUrl = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||||
|
const secret = () => String(process.env.HUB_SECRET || '').trim();
|
||||||
|
const siteName = () => String(process.env.HUB_SITE || (O && O.site) || '').trim();
|
||||||
|
const enabled = () => process.env.NETKB !== '0' && !!hubUrl() && secret().length >= 32 && !!siteName();
|
||||||
|
const cacheFile = () => (O && O.dataDir ? path.join(O.dataDir, 'netkb-cache.json') : null);
|
||||||
|
|
||||||
|
async function call(method, route, body, headers, timeoutMs) {
|
||||||
|
const raw = body === undefined ? '' : JSON.stringify(body); const ts = String(Date.now());
|
||||||
|
const sig = crypto.createHmac('sha256', secret()).update(ts + '\n' + raw).digest('hex');
|
||||||
|
const r = await fetch(hubUrl() + route, { method, body: method === 'GET' ? undefined : raw, signal: AbortSignal.timeout(timeoutMs || 15000),
|
||||||
|
headers: Object.assign({ 'Content-Type': 'application/json', 'X-Hub-Site': siteName(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig }, headers || {}) });
|
||||||
|
let j = null; if (r.status !== 304) { try { j = await r.json(); } catch (e) {} }
|
||||||
|
return { status: r.status, body: j };
|
||||||
|
}
|
||||||
|
|
||||||
|
// the entries this site shares: what the chatbot's knowledge base holds, minus the instant-answer patterns (those stay home)
|
||||||
|
const shape = e => ({ id: String(e.id), title: e.title, questions: (e.questions || []).slice(0, 15), answer: e.answer, tags: (e.tags || []).slice(0, 15), link: e.link || (O && O.url) || undefined });
|
||||||
|
async function publish() {
|
||||||
|
if (!enabled() || !O || typeof O.entries !== 'function') return { skipped: true };
|
||||||
|
const entries = (await O.entries()).filter(e => e && e.id && e.answer && !e.deleted).map(shape);
|
||||||
|
const body = { name: O.name, url: O.url, entries };
|
||||||
|
const h = crypto.createHash('sha1').update(JSON.stringify(body)).digest('hex');
|
||||||
|
if (h === publishedHash) return { same: true };
|
||||||
|
try {
|
||||||
|
const r = await call('PUT', '/v1/kb', body);
|
||||||
|
if (r.status !== 200) { stats.publishErrors++; stats.lastError = 'publish ' + r.status + ' ' + ((r.body && r.body.error) || ''); return { error: stats.lastError }; }
|
||||||
|
publishedHash = h; stats.published++; stats.lastPublishAt = Date.now();
|
||||||
|
return r.body;
|
||||||
|
} catch (e) { stats.publishErrors++; stats.lastError = 'publish ' + e.message; return { error: e.message }; }
|
||||||
|
}
|
||||||
|
// an admin edit: publish a few seconds later (several quick edits go as one)
|
||||||
|
function publishSoon() { if (pubTimer) return; pubTimer = setTimeout(() => { pubTimer = null; publish().catch(() => {}); }, 5000); if (pubTimer.unref) pubTimer.unref(); }
|
||||||
|
|
||||||
|
function readCache() {
|
||||||
|
const f = cacheFile(); if (!f) return;
|
||||||
|
try { const d = JSON.parse(fs.readFileSync(f, 'utf8')); if (d && Array.isArray(d.entries)) { merged = d; loadedAt = 0; } } catch (e) {}
|
||||||
|
}
|
||||||
|
function writeCache() {
|
||||||
|
const f = cacheFile(); if (!f) return;
|
||||||
|
try { fs.writeFileSync(f + '.tmp', JSON.stringify(merged)); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('netkb cache', e.message); }
|
||||||
|
}
|
||||||
|
async function refresh() {
|
||||||
|
if (!enabled()) return { skipped: true };
|
||||||
|
try {
|
||||||
|
const r = await call('GET', '/v1/kb', undefined, merged.version ? { 'If-None-Match': '"' + merged.version + '"' } : {});
|
||||||
|
stats.lastReadAt = Date.now();
|
||||||
|
if (r.status === 304) { stats.notModified++; loadedAt = Date.now(); return { same: true }; }
|
||||||
|
if (r.status !== 200 || !r.body || !Array.isArray(r.body.entries)) { stats.readErrors++; stats.lastError = 'read ' + r.status; return { error: stats.lastError }; }
|
||||||
|
merged = { version: String(r.body.version || ''), sites: r.body.sites || {}, entries: r.body.entries }; loadedAt = Date.now(); stats.reads++;
|
||||||
|
writeCache();
|
||||||
|
return { version: merged.version, count: merged.entries.length };
|
||||||
|
} catch (e) { stats.readErrors++; stats.lastError = 'read ' + e.message; return { error: e.message }; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// other sites' entries, ready for the chatbot's index: id "<site>:<id>", plus where they come from and the link to send people to
|
||||||
|
function remote() {
|
||||||
|
const me = siteName(); const out = [];
|
||||||
|
for (const e of merged.entries || []) {
|
||||||
|
if (!e || e.site === me) continue;
|
||||||
|
const s = (merged.sites || {})[e.site] || {};
|
||||||
|
const url = s.url || e.link || '';
|
||||||
|
out.push({ id: e.site + ':' + e.id, title: e.title, questions: e.questions || [], answer: e.answer, tags: e.tags || [],
|
||||||
|
site: e.site, siteName: s.name || e.site, siteUrl: url, go: (O && typeof O.linkFor === 'function' && url ? O.linkFor(url) : '') || url });
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// the network's sites as the hub knows them (name, link), this one left out
|
||||||
|
function sites() {
|
||||||
|
const me = siteName();
|
||||||
|
return Object.entries(merged.sites || {}).filter(([k]) => k !== me).map(([k, s]) => ({ site: k, name: s.name || k, url: s.url || '', go: (O && typeof O.linkFor === 'function' && s.url ? O.linkFor(s.url) : '') || s.url || '', count: s.count || 0 }));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- semantic matching (2026-11-16)
|
||||||
|
const SEM = { answer: Number(process.env.NETKB_SEM_ANSWER) || 0.84, margin: 0.02, context: Number(process.env.NETKB_SEM_CONTEXT) || 0.68, unsure: 0.70, band: 0.08, away: 0.06, agree: 0.10, floor: 0.60 };
|
||||||
|
const MATCH_PAUSE_MS = 30000;
|
||||||
|
let matchDownUntil = 0;
|
||||||
|
const mstats = { matches: 0, matchErrors: 0, matchSkipped: 0, matchLastMs: 0, matchLastError: null, semAnswer: 0, semAgree: 0, semRegex: 0, semVeto: 0, semContext: 0 };
|
||||||
|
const matchOn = () => enabled() && process.env.NETKB_MATCH !== '0';
|
||||||
|
// -> the hub's answer {confidence, margin, hits: [{site, id, title, answer, score, boosted, home}]} or null (off, down, slow)
|
||||||
|
async function match(q, o) {
|
||||||
|
o = o || {};
|
||||||
|
if (!matchOn()) return null;
|
||||||
|
if (Date.now() < matchDownUntil) { mstats.matchSkipped++; return null; }
|
||||||
|
const t0 = Date.now();
|
||||||
|
try {
|
||||||
|
const body = { q: String(q || '').slice(0, 600), k: o.k || 6 };
|
||||||
|
if (o.prefer && o.prefer.length) body.prefer = o.prefer;
|
||||||
|
if (o.only && o.only.length) body.only = o.only;
|
||||||
|
const r = await call('POST', '/v1/kb/match', body, undefined, o.timeoutMs || Number(process.env.NETKB_MATCH_MS) || 1500);
|
||||||
|
mstats.matchLastMs = Date.now() - t0;
|
||||||
|
if (r.status !== 200 || !r.body || !Array.isArray(r.body.hits)) throw new Error('match ' + r.status + ' ' + ((r.body && r.body.error) || ''));
|
||||||
|
mstats.matches++;
|
||||||
|
return r.body;
|
||||||
|
} catch (e) { mstats.matchErrors++; mstats.matchLastError = e.message; matchDownUntil = Date.now() + MATCH_PAUSE_MS; return null; }
|
||||||
|
}
|
||||||
|
// msg + { fast: the instant-answer pattern hit (or null), own: this site's entries, prefer: [site ids the question names] }
|
||||||
|
// -> null (no match: the caller keeps its old path) or { via, hit: own entry to answer with | null, hits: [{entry, score}] for the prompt }
|
||||||
|
async function route(msg, o) {
|
||||||
|
o = o || {};
|
||||||
|
// a question that names another site but asks about "here" is about this site (e.g. "I am on InstantAdPay, does my team carry over here?")
|
||||||
|
const prefer = (o.prefer || []).length && !/\b(here|this site|this one)\b/i.test(msg) ? o.prefer : [];
|
||||||
|
const m = await match(msg, { k: 8, prefer });
|
||||||
|
if (!m) return null;
|
||||||
|
const me = siteName();
|
||||||
|
const own = new Map((o.own || []).map(e => [String(e.id), e]));
|
||||||
|
const rem = new Map(remote().map(e => [e.id, e]));
|
||||||
|
const all = m.hits.map(h => ({ entry: h.site === me ? own.get(String(h.id)) : rem.get(h.site + ':' + h.id), score: Number(h.score) || 0, home: h.site === me })).filter(h => h.entry);
|
||||||
|
let hits = all;
|
||||||
|
const named = prefer.length > 0, fast = o.fast || null;
|
||||||
|
if (!named) { // home-site first: this site's own entries lead; another site's ride behind them only when clearly closer (a thing only that site has)
|
||||||
|
const mine = hits.filter(h => h.home && h.score >= SEM.context);
|
||||||
|
const homeTop = mine.length ? mine[0].score : 0;
|
||||||
|
hits = mine.concat(hits.filter(h => !h.home && h.score >= homeTop + SEM.away));
|
||||||
|
}
|
||||||
|
const top = hits[0];
|
||||||
|
const ctx = top ? hits.filter(h => h.score >= SEM.context && (h.score >= top.score - SEM.band || !h.home)).map(h => ({ entry: h.entry, score: Math.round(h.score * 1000) / 1000 })) : [];
|
||||||
|
const out = (via, hit) => { mstats['sem' + via[0].toUpperCase() + via.slice(1)]++; return { via, hit, hits: ctx, confidence: top ? top.score : 0 }; };
|
||||||
|
if (top && top.home && !named && top.score >= SEM.answer && (Number(m.margin) >= SEM.margin || (fast && String(fast.id) === String(top.entry.id)))) return out('answer', top.entry);
|
||||||
|
if (fast) {
|
||||||
|
const best = all.length ? all[0].score : 0;
|
||||||
|
if (all.some(h => h.home && String(h.entry.id) === String(fast.id) && h.score >= SEM.floor && h.score >= best - SEM.agree)) return out('agree', fast);
|
||||||
|
if (!top || top.score < SEM.unsure) return out('regex', fast);
|
||||||
|
return out('veto', null);
|
||||||
|
}
|
||||||
|
return out('context', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// support desk suggestions (2026-11-16): the help answers closest to what a signed-in member is typing into a new ticket.
|
||||||
|
// Knowledge-base entries only (published answers, including the ones written from past tickets), never anyone's ticket text.
|
||||||
|
// text + { own: this site's entries, fallback: async q => [{entry}] (BM25) when the hub is slow or down, max }
|
||||||
|
const SUGGEST_MIN = Number(process.env.NETKB_SUGGEST_MIN) || 0.70;
|
||||||
|
const NOT_SUGGESTED = /(^|[-:])support$|^c-refund$/; // the "contact support" entry is no help on the support form itself
|
||||||
|
function suggestItem(e, home, score) {
|
||||||
|
return { id: String(e.id), title: e.title, answer: String(e.answer || '').slice(0, 900), site: home ? '' : (e.siteName || e.site || ''),
|
||||||
|
link: home ? (e.link || '') : (e.go || e.siteUrl || ''), fromTicket: !!(home && e.source === 'ticket'), score: score == null ? null : Math.round(score * 1000) / 1000 };
|
||||||
|
}
|
||||||
|
async function suggest(text, o) {
|
||||||
|
o = o || {};
|
||||||
|
const q = String(text || '').replace(/\s+/g, ' ').trim().slice(0, 600);
|
||||||
|
if (q.replace(/[^A-Za-z0-9]/g, '').length < 10) return { items: [], via: 'short' };
|
||||||
|
const me = siteName(); const own = new Map((o.own || []).map(e => [String(e.id), e]));
|
||||||
|
const keep = (e, home) => e && !(home && e.handoff) && !NOT_SUGGESTED.test(String(e.id));
|
||||||
|
let items = [], via = 'none';
|
||||||
|
const m = await match(q, { k: 8, timeoutMs: o.timeoutMs || 2000 });
|
||||||
|
if (m) {
|
||||||
|
via = 'semantic'; const top = m.hits.length ? Number(m.hits[0].score) : 0; const rem = new Map(remote().map(e => [e.id, e]));
|
||||||
|
for (const h of m.hits) {
|
||||||
|
if (h.score < SUGGEST_MIN || h.score < top - 0.08) continue;
|
||||||
|
const home = h.site === me; const e = home ? own.get(String(h.id)) : rem.get(h.site + ':' + h.id);
|
||||||
|
if (keep(e, home)) items.push(suggestItem(e, home, h.score));
|
||||||
|
}
|
||||||
|
} else if (typeof o.fallback === 'function') {
|
||||||
|
via = 'bm25';
|
||||||
|
try { for (const x of (await o.fallback(q)) || []) { const e = x && x.entry; const home = !!e && !e.site; if (keep(e, home)) items.push(suggestItem(e, home, null)); } } catch (e) {}
|
||||||
|
}
|
||||||
|
return { items: items.slice(0, o.max || 3), via };
|
||||||
|
}
|
||||||
|
|
||||||
|
// opts: { dataDir, site (hub site id), name, url, entries: async () => [...], linkFor: url => tracked link }
|
||||||
|
function init(opts) {
|
||||||
|
O = opts || {}; readCache();
|
||||||
|
if (!enabled()) return;
|
||||||
|
const first = setTimeout(async () => { await publish().catch(() => {}); await refresh().catch(() => {}); }, Math.max(0, Number(process.env.NETKB_FIRST_MS) || 8000));
|
||||||
|
if (first.unref) first.unref();
|
||||||
|
timer = setInterval(async () => { await refresh().catch(() => {}); if (!publishedHash) await publish().catch(() => {}); }, Math.max(1000, Number(process.env.NETKB_REFRESH_MS) || REFRESH_MS));
|
||||||
|
if (timer.unref) timer.unref();
|
||||||
|
}
|
||||||
|
function view() { return Object.assign({ enabled: enabled(), site: siteName(), version: merged.version, sites: Object.keys(merged.sites || {}), entries: (merged.entries || []).length, remote: remote().length, loadedAt, semantic: matchOn(), sem: SEM }, stats, mstats); }
|
||||||
|
function _set(m) { merged = m; } // tests
|
||||||
|
|
||||||
|
const version = () => merged.version || '';
|
||||||
|
function _matchReset() { matchDownUntil = 0; } // tests
|
||||||
|
module.exports = { init, publish, publishSoon, refresh, remote, sites, view, enabled, version, match, route, suggest, SEM, _set, _matchReset };
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// The network sites list for the footer's "Part of the network" line (Marty 2026-11-14 trust pack).
|
||||||
|
// One source: the hub's public GET /v1/network-sites (HUB_URL). Cached 10 minutes, refreshed in the background, never waits on a
|
||||||
|
// slow hub (2.5 s timeout), and falls back to the same built-in list. Never RM Circle, never the games.
|
||||||
|
// The same file lives in every network site (InstantAdPay, LinkSpin, Downline Banners, VBB, Stack POL).
|
||||||
|
const FALLBACK = [
|
||||||
|
{ id: 'iap', name: 'InstantAdPay', url: 'https://instantadpay.com' },
|
||||||
|
{ id: 'linkspin', name: 'LinkSpin', url: 'https://linkspin.app' },
|
||||||
|
{ id: 'dlb', name: 'Downline Banners', url: 'https://downlinebanners.com' },
|
||||||
|
{ id: 'vbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com' },
|
||||||
|
{ id: 'stackpol', name: 'Stack POL', url: 'https://stackpol.com' },
|
||||||
|
{ id: 'earnerscorner', name: 'Earners Corner', url: 'https://earnerscorner.com' }
|
||||||
|
];
|
||||||
|
const TTL = 10 * 60 * 1000;
|
||||||
|
let cache = { at: 0, list: FALLBACK, from: 'fallback' };
|
||||||
|
let inflight = null;
|
||||||
|
|
||||||
|
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
|
||||||
|
function clean(list) {
|
||||||
|
if (!Array.isArray(list)) return null;
|
||||||
|
const ok = list.filter(s => s && typeof s.name === 'string' && /^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(s.url || '')))
|
||||||
|
.slice(0, 30).map(s => ({ id: String(s.id || s.name).toLowerCase().replace(/[^a-z0-9]+/g, '').slice(0, 30), name: String(s.name).slice(0, 60), url: String(s.url).replace(/\/+$/, '') }));
|
||||||
|
return ok.length ? ok : null;
|
||||||
|
}
|
||||||
|
function refresh() {
|
||||||
|
if (inflight || process.env.NETWORK_SITES_HUB === '0') return inflight;
|
||||||
|
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
|
||||||
|
inflight = fetch(hubUrl() + '/v1/network-sites', { signal: ac.signal })
|
||||||
|
.then(r => (r.ok ? r.json() : null))
|
||||||
|
.then(j => { const l = clean(j); if (l) cache = { at: Date.now(), list: l, from: 'hub' }; else cache.at = Date.now(); })
|
||||||
|
.catch(() => { cache.at = Date.now() - TTL + 60 * 1000; }) // hub down: try again in a minute, keep the last good list
|
||||||
|
.finally(() => { clearTimeout(t); inflight = null; });
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; }
|
||||||
|
// Tracked links (Marty 2026-11-14: "make sure each of these sites is its own traffic source and link spun so we can track it"): each
|
||||||
|
// entry also gets go = the LinkSpin network link for that site with ?src=<this site>, so a click shows in LinkSpin Reports under the
|
||||||
|
// site that sent it (LinkSpin netlinks.js: fixed codes on the admin account). This site = NETWORK_SITE_ID, else the request host.
|
||||||
|
// No go for this site itself, or when this site cannot be told (a test host): the page then uses the plain url.
|
||||||
|
const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', viraladblitz: 'nwvab', viraladsource: 'nwvas', yourprogrambuilder: 'nwypb', fivex: 'nw5x', downlinehydra: 'nwdh', stackpol: 'nwsp', earnerscorner: 'nwec' };
|
||||||
|
const linksBase = () => String(process.env.NETWORK_LINKS_BASE || 'https://linkspin.app').trim().replace(/\/+$/, '');
|
||||||
|
const hostOf = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
|
||||||
|
function selfId(req, l) {
|
||||||
|
const env = String(process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); if (env) return env;
|
||||||
|
const h = String((req && req.headers && (req.headers['x-forwarded-host'] || req.headers.host)) || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
|
||||||
|
const m = h && (l || list()).find(s => hostOf(s.url) === h); return m ? m.id : '';
|
||||||
|
}
|
||||||
|
// the LinkSpin-tracked link to site `id` sent from site `from` (from = id: the site's own promo kit); extra = { s1: member username, s2: one path segment }
|
||||||
|
function tracked(id, from, extra) {
|
||||||
|
const code = CODES[id]; if (!code || !from) return '';
|
||||||
|
const q = new URLSearchParams({ src: from }); for (const [k, v] of Object.entries(extra || {})) if (v) q.set(k, String(v));
|
||||||
|
return linksBase() + '/r/' + code + '?' + q.toString();
|
||||||
|
}
|
||||||
|
function withGo(l, me) { return l.map(s => { const go = me && s.id !== me ? tracked(s.id, me) : ''; return go ? Object.assign({}, s, { go }) : s; }); }
|
||||||
|
// GET /api/network-sites: public, cacheable, the same answer on every page
|
||||||
|
function handle(req, res) {
|
||||||
|
const l = list();
|
||||||
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' });
|
||||||
|
res.end(JSON.stringify(withGo(l, selfId(req, l))));
|
||||||
|
}
|
||||||
|
module.exports = { list, handle, refresh, tracked, selfId, withGo, CODES, FALLBACK, _state: () => cache };
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// One flow, used two ways. R = the site the member is going TO (receiver), P = the site they are signed in on (provider).
|
// One flow, used two ways. R = the site the member is going TO (receiver), P = the site they are signed in on (provider).
|
||||||
// 1. R GET /sso/start?mode=go|check&to=/path R makes a random state, keeps it in a 5-minute HttpOnly cookie (nsso.st),
|
// 1. R GET /sso/start?mode=go|check&to=/path R makes a random state, keeps it in a 5-minute HttpOnly cookie (nsso.st),
|
||||||
// sets the loop guard (nsso.tried, 30 minutes) and sends the browser to P.
|
// sets the loop guard (nsso.tried, 2 minutes) and sends the browser to P.
|
||||||
// 2. P GET /sso/check?st=<state>&to=/path P looks at its OWN member session (never the admin portal). Signed in:
|
// 2. P GET /sso/check?st=<state>&to=/path P looks at its OWN member session (never the admin portal). Signed in:
|
||||||
// P mints a token bound to R, the state and the email, and sends the browser
|
// P mints a token bound to R, the state and the email, and sends the browser
|
||||||
// to R /sso/in?t=<token>. Not signed in: R /sso/in?none=1&to=/path.
|
// to R /sso/in?t=<token>. Not signed in: R /sso/in?none=1&to=/path.
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
// Outbound links: P GET /go/<peer>?to=/path is the hop a signed-in member's cross-site link points at. Signed out (or the
|
// Outbound links: P GET /go/<peer>?to=/path is the hop a signed-in member's cross-site link points at. Signed out (or the
|
||||||
// secret not set), it is a plain redirect to the other site, so it is always safe to link through.
|
// secret not set), it is a plain redirect to the other site, so it is always safe to link through.
|
||||||
// Silent check: R's sign-in page calls GET /api/sso/status; { check: true } means "bounce once through P". The guard cookie
|
// Silent check: R's sign-in page calls GET /api/sso/status; { check: true } means "bounce once through P". The guard cookie
|
||||||
// stops a second bounce for 30 minutes, signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
|
// stops a second bounce for 2 minutes (30 until 2026-11-15, when it blocked Marty's silent sign-in on LinkSpin), signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
|
||||||
// bots and non-page fetches never bounce.
|
// bots and non-page fetches never bounce.
|
||||||
// Token: "v1.<base64url JSON>.<base64url HMAC-SHA256(NETWORK_SSO_SECRET, 'nsso.v1.' + JSON part)>", JSON = { iss, aud, email,
|
// Token: "v1.<base64url JSON>.<base64url HMAC-SHA256(NETWORK_SSO_SECRET, 'nsso.v1.' + JSON part)>", JSON = { iss, aud, email,
|
||||||
// st, to, iat, exp, n[, wallet, name] }. The token grants a plain member session and nothing else: no wallet action, payout or purchase rides on it.
|
// st, to, iat, exp, n[, wallet, name] }. The token grants a plain member session and nothing else: no wallet action, payout or purchase rides on it.
|
||||||
@@ -24,6 +24,30 @@
|
|||||||
// and /sso/check?r=bannerline mint a token that also carries the member's wallet (the one they signed in with, else the main wallet
|
// and /sso/check?r=bannerline mint a token that also carries the member's wallet (the one they signed in with, else the main wallet
|
||||||
// their account linked by signature) and username. Downline Banners runs this file with `from: { iap, linkspin }`, accepts a token from
|
// their account linked by signature) and username. Downline Banners runs this file with `from: { iap, linkspin }`, accepts a token from
|
||||||
// either, and makes a session for that wallet. /sso/start?via=<site> picks which site to ask; old copies ignore the new parameters.
|
// either, and makes a session for that wallet. /sso/start?via=<site> picks which site to ask; old copies ignore the new parameters.
|
||||||
|
//
|
||||||
|
// THE HUB AS THE PROVIDER (Marty approved 2026-11-15; off unless HUB_SSO=on, with HUB_URL, HUB_SECRET (32+) and HUB_SITE or C.hubSite).
|
||||||
|
// The network hub keeps one network sign-in per browser in its own cookie (7 days, renewed on use). With it on:
|
||||||
|
// /sso/start asks the hub (GET <hub>/sso/check?site=<HUB_SITE>&st&to&m) instead of one other site; the hub answers
|
||||||
|
// /sso/in?h=<token> ("h1." token, HMAC-SHA256 with this site's HUB_SECRET under 'hubsso.v1.', iss 'hub', aud = this site,
|
||||||
|
// 60 s, single use, bound to the state cookie) or /sso/in?none=1&hub=1, and then the old pairwise path is tried once as the
|
||||||
|
// fallback (until every site is switched).
|
||||||
|
// Push: a signed-in member's page load (a real top-level navigation only) with no matching nsso.hp cookie goes once through
|
||||||
|
// <hub>/sso/set?site&t=<this site's token for the member> and straight back, so signing in on any site signs in the hub.
|
||||||
|
// Only when the hub answered /health in the last 2 minutes: a hub that is down never takes a page with it.
|
||||||
|
// Activity (Marty 2026-11-15, DownlineHydra "Wake it", the CRM score): a signed-in member's page load pings POST <hub>/v1/activity
|
||||||
|
// {email|wallet, kind 'visit'} at most once per member per day, fire and forget (HUB_URL + HUB_SECRET; HUB_ACTIVITY=0 turns it off).
|
||||||
|
// signOutEverywhere(session): POST <hub>/v1/sso/signout; the hub ends every hub sign-in of that person and tells hooked sites.
|
||||||
|
//
|
||||||
|
// ONE SITES LIST + THE WAY BACK (Marty 2026-11-17: "I logged in to Instant Ad Pay from Viral Ad Source, and it never had a return
|
||||||
|
// path back"). Before, each provider (IAP, LinkSpin) kept its own hand-written `wallets` list; a site missing from it (5xYourTeam
|
||||||
|
// 11-15, ViralAdSource 11-17) was refused at /sso/check and the member was dropped on the provider's dashboard with no way back.
|
||||||
|
// Sites list: a provider also knows every site in the hub's public GET <hub>/v1/sso-sites (HUB_SSO_SITES there; the same list the
|
||||||
|
// hub signs in for). Read at start, every 5 minutes, and once more (2 s at most) when an unknown site asks. Hand-written entries win.
|
||||||
|
// Return links: any provider page with ?return=<site>&to=/path (a known site only, never an open redirect) remembers the way back
|
||||||
|
// in nsso.ret (1 day) and reloads without the two parameters. Signed in already: straight back. After the email-code sign-in (and
|
||||||
|
// after the username step for a new account) the provider's dashboard goes to /sso/resume, which finishes it: /go/<site>?to=/path.
|
||||||
|
// No wallet yet (a wallet site needs one): with C.walletPath the member goes to the provider's wallet step first (nsso.wait), and
|
||||||
|
// afterWallet(req) gives the wallet-link answer its next hop, /sso/resume. The same holds for a deliberate tap (nsso.back).
|
||||||
'use strict';
|
'use strict';
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@@ -34,14 +58,53 @@ const enabled = () => SECRET().length >= 32;
|
|||||||
const TTL = 60 * 1000; // token life
|
const TTL = 60 * 1000; // token life
|
||||||
const SKEW = 30 * 1000; // clock skew allowed between the two servers
|
const SKEW = 30 * 1000; // clock skew allowed between the two servers
|
||||||
const STATE_AGE = 300; // seconds: the state cookie
|
const STATE_AGE = 300; // seconds: the state cookie
|
||||||
const TRIED_AGE = 1800; // seconds: one silent check per browser per 30 minutes
|
const GO_STATE_AGE = 3600; // seconds: the state cookie on a deliberate tap (time to sign in, pick a username and link a wallet on the provider first; 20 minutes until 2026-11-17)
|
||||||
|
const BACK_AGE = 3600; // seconds: the provider remembers an unfinished deliberate check while the member signs in (20 minutes until 2026-11-17)
|
||||||
|
const RET_AGE = 86400; // seconds: a ?return=<site> link remembers the way back (2026-11-17)
|
||||||
|
const TRIED_AGE = 120; // seconds: one silent check per browser per 2 minutes (loop guard only; 30 minutes until 2026-11-15)
|
||||||
const OFF_AGE = 12 * 3600; // seconds: no silent check after a sign-out on this site
|
const OFF_AGE = 12 * 3600; // seconds: no silent check after a sign-out on this site
|
||||||
const HINT_AGE = 300; // seconds: the email prefill when the member is not here yet
|
const HINT_AGE = 300; // seconds: the email prefill when the member is not here yet
|
||||||
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14)
|
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz', downlinehydra: 'DownlineHydra', fivex: '5xYourTeam' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15); downlinehydra = DownlineHydra (2026-11-15); fivex = 5xYourTeam (2026-11-15)
|
||||||
const WALLET_RE = /^0x[0-9a-f]{40}$/;
|
const WALLET_RE = /^0x[0-9a-f]{40}$/;
|
||||||
|
const PUSH_AGE = 6 * 86400; // seconds: this browser's member is signed in on the hub (the hub's own sign-in lasts 7 days)
|
||||||
|
const HUB_BASE = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||||
|
const HUB_KEY = () => String(process.env.HUB_SECRET || '').trim();
|
||||||
|
const HUB_NAME = () => String(process.env.HUB_SITE || (C && (C.hubSite || C.self)) || '').trim().toLowerCase();
|
||||||
|
const hubCreds = () => /^https?:\/\/[a-z0-9.:-]+$/i.test(HUB_BASE()) && HUB_KEY().length >= 32 && /^[a-z0-9_-]{1,64}$/.test(HUB_NAME());
|
||||||
|
const hubOn = () => String(process.env.HUB_SSO || '').trim().toLowerCase() === 'on' && hubCreds();
|
||||||
|
let hubSeen = 0, hubChecked = 0, hubAsking = null; // last good /health answer, last time we asked
|
||||||
|
// true when the hub answered /health in the last 2 minutes. Asked at most once a minute; while the answer is unknown (first use, or
|
||||||
|
// the last good answer is old) the caller waits for that one question (2 s at most), so a hub that is down costs one page 2 s a minute.
|
||||||
|
async function hubUp() {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - hubChecked >= 60000 && !hubAsking && typeof fetch === 'function') {
|
||||||
|
hubChecked = now;
|
||||||
|
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, 2000);
|
||||||
|
hubAsking = fetch(HUB_BASE() + '/health', { signal: ac ? ac.signal : undefined }).then(r => { if (r.ok) hubSeen = Date.now(); }).catch(() => {}).finally(() => { clearTimeout(tm); hubAsking = null; });
|
||||||
|
}
|
||||||
|
if (hubAsking && Date.now() - hubSeen >= 120000) await hubAsking;
|
||||||
|
return Date.now() - hubSeen < 120000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the hub's sign-in sites {site: base} (2026-11-17): providers answer every site the hub knows, not only their hand-written list
|
||||||
|
let hubSites = {}, hubSitesAt = 0, hubSitesAsking = null;
|
||||||
|
const SITE_RE = /^[a-z0-9_-]{1,64}$/, BASE_RE = /^https?:\/\/[a-z0-9.:-]+$/i;
|
||||||
|
function loadHubSites() {
|
||||||
|
if (hubSitesAsking) return hubSitesAsking;
|
||||||
|
if (!BASE_RE.test(HUB_BASE()) || typeof fetch !== 'function' || String(process.env.NSSO_HUB_SITES || '') === '0') return Promise.resolve();
|
||||||
|
hubSitesAt = Date.now();
|
||||||
|
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, 2000);
|
||||||
|
hubSitesAsking = fetch(HUB_BASE() + '/v1/sso-sites', { signal: ac ? ac.signal : undefined }).then(r => (r.ok ? r.json() : null)).then(j => {
|
||||||
|
if (!j || !j.sites || typeof j.sites !== 'object') return;
|
||||||
|
const out = {}; for (const [k, v] of Object.entries(j.sites)) { const b = String(v || '').replace(/\/+$/, ''); if (SITE_RE.test(k) && BASE_RE.test(b)) out[k] = b; }
|
||||||
|
hubSites = out;
|
||||||
|
}).catch(() => {}).finally(() => { clearTimeout(tm); hubSitesAsking = null; });
|
||||||
|
return hubSitesAsking;
|
||||||
|
}
|
||||||
|
const freshSites = () => { if (C && C.wallet && Date.now() - hubSitesAt > 5 * 60 * 1000) loadHubSites(); };
|
||||||
|
|
||||||
let C = null; // { self, peer, peerBase(), isProd, dataDir, db, member(req), accept(email, req, v), signIn(email, req, v), landing(to), signinPath(to), defaultPath,
|
let C = null; // { self, peer, peerBase(), isProd, dataDir, db, member(req), accept(email, req, v), signIn(email, req, v), landing(to), signinPath(to), defaultPath,
|
||||||
// wallets?: { site: base() } + wallet(session) -> { address, name }, from?: { site: base() } }
|
// wallets?: { site: base() } + wallet(session) -> { address, name }, from?: { site: base() }, walletPath?: the provider's wallet step }
|
||||||
|
|
||||||
const b64u = buf => Buffer.from(buf).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
const b64u = buf => Buffer.from(buf).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||||
const unb64u = s => Buffer.from(String(s).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
const unb64u = s => Buffer.from(String(s).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
||||||
@@ -86,6 +149,77 @@ function verify(tok, o) {
|
|||||||
return { ok: true, iss: p.iss, email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
|
return { ok: true, iss: p.iss, email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hub tokens ("h1.", the hub's format): mint for the hub (push), verify from the hub (sign-in)
|
||||||
|
const hmacHub = x => crypto.createHmac('sha256', HUB_KEY()).update('hubsso.v1.' + x).digest();
|
||||||
|
function mintHub(o) {
|
||||||
|
const now = o.now || Date.now();
|
||||||
|
const t = { iss: HUB_NAME(), aud: 'hub', to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
|
||||||
|
if (o.email) t.email = String(o.email).trim().toLowerCase(); else if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
|
||||||
|
const body = b64u(JSON.stringify(t));
|
||||||
|
return 'h1.' + body + '.' + b64u(hmacHub(body));
|
||||||
|
}
|
||||||
|
function verifyHub(tok, o) {
|
||||||
|
if (!hubCreds()) return { error: 'off' };
|
||||||
|
const m = /^h1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
|
||||||
|
if (!m) return { error: 'malformed' };
|
||||||
|
const want = hmacHub(m[1]), got = unb64u(m[2]);
|
||||||
|
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
|
||||||
|
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
|
||||||
|
const now = (o && o.now) || Date.now();
|
||||||
|
if (!p || p.iss !== 'hub' || p.aud !== HUB_NAME()) return { error: 'audience' };
|
||||||
|
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
|
||||||
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
|
||||||
|
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
|
||||||
|
const st = String((o && o.st) || '');
|
||||||
|
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
|
||||||
|
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
|
||||||
|
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
|
||||||
|
return { ok: true, iss: 'hub', email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
|
||||||
|
}
|
||||||
|
// a signed /v1 call to the hub (the scheme every site already uses): hex HMAC-SHA256(HUB_SECRET, ts + newline + body)
|
||||||
|
async function hubCall(route, body, ms) {
|
||||||
|
const raw = JSON.stringify(body || {}); const ts = String(Date.now());
|
||||||
|
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, ms || 5000);
|
||||||
|
try {
|
||||||
|
const r = await fetch(HUB_BASE() + route, { method: 'POST', body: raw, signal: ac ? ac.signal : undefined, headers: { 'Content-Type': 'application/json', 'X-Hub-Site': HUB_NAME(), 'X-Hub-Ts': ts, 'X-Hub-Sig': crypto.createHmac('sha256', HUB_KEY()).update(ts + '\n' + raw).digest('hex') } });
|
||||||
|
let j = null; try { j = await r.json(); } catch (e) {}
|
||||||
|
return { status: r.status, json: j };
|
||||||
|
} finally { clearTimeout(tm); }
|
||||||
|
}
|
||||||
|
const who = s => (s && s.email ? { email: String(s.email).toLowerCase() } : s && s.address && WALLET_RE.test(String(s.address).toLowerCase()) ? { wallet: String(s.address).toLowerCase() } : null);
|
||||||
|
const pushTag = w => b64u(crypto.createHmac('sha256', HUB_KEY()).update('push.' + (w.email || w.wallet)).digest()).slice(0, 22);
|
||||||
|
// once per member per day (memory; a restart may ping once more, the hub counts a visit once per 10 minutes anyway)
|
||||||
|
const pinged = new Map(); let pingDay = '';
|
||||||
|
function activity(w) {
|
||||||
|
if (String(process.env.HUB_ACTIVITY || '') === '0' || !hubCreds() || typeof fetch !== 'function') return;
|
||||||
|
const day = new Date().toISOString().slice(0, 10); if (day !== pingDay) { pinged.clear(); pingDay = day; }
|
||||||
|
const k = w.email || w.wallet; if (pinged.has(k)) return; pinged.set(k, 1);
|
||||||
|
hubCall('/v1/activity', Object.assign({ kind: 'visit' }, w), 5000).then(r => { if (r.status >= 500) pinged.delete(k); }).catch(() => { pinged.delete(k); });
|
||||||
|
}
|
||||||
|
// a signed-in request the site already answers (2026-11-16, Marty: "LinkSpin never reports activity"): /api/me, the dashboard
|
||||||
|
// heartbeat (/api/my/ping) and the admin portal call this, so a Control Room tab kept open for days, a browser that sends no
|
||||||
|
// Sec-Fetch headers and a wallet-only session still count the day's visit. The page-load ping in page() only sees full navigations.
|
||||||
|
// s = {email} and/or {address}. Same once-a-day rule as page(). -> true when a ping was due or already sent today.
|
||||||
|
function seen(s) {
|
||||||
|
try {
|
||||||
|
if (!C || !hubCreds()) return false;
|
||||||
|
const w = who(s && s.email ? s : s && s.address ? { address: s.address } : null); if (!w) return false;
|
||||||
|
activity(w); return true;
|
||||||
|
} catch (e) { return false; }
|
||||||
|
}
|
||||||
|
// a real top-level page load of a page (never an API call, an asset, a fetch, a bot or one of our own hops)
|
||||||
|
function pageLoad(req, p) {
|
||||||
|
if (req.method !== 'GET' || isBot(req)) return false;
|
||||||
|
if (req.headers['sec-fetch-dest'] !== 'document' || (req.headers['sec-fetch-mode'] && req.headers['sec-fetch-mode'] !== 'navigate')) return false;
|
||||||
|
if (/^\/(sso|api|go|assets|art|img|fonts|uploads|admin)(\/|$)/.test(p)) return false;
|
||||||
|
return !/\.[a-z0-9]{1,5}$/i.test(p);
|
||||||
|
}
|
||||||
|
async function signOutEverywhere(s) {
|
||||||
|
const w = who(s); if (!w || !hubCreds()) return { ok: false, reason: !w ? 'signed out' : 'hub off' };
|
||||||
|
try { const r = await hubCall('/v1/sso/signout', w, 8000); return r.status === 200 ? Object.assign({ ok: true }, r.json || {}) : { ok: false, reason: 'hub ' + r.status }; }
|
||||||
|
catch (e) { return { ok: false, reason: 'hub unreachable' }; }
|
||||||
|
}
|
||||||
|
|
||||||
// single use: true the first time a nonce is spent. MySQL when the site runs on it (two app copies during a deploy share it),
|
// single use: true the first time a nonce is spent. MySQL when the site runs on it (two app copies during a deploy share it),
|
||||||
// else memory + a small file in DATA_DIR (survives a restart inside the 60-second window).
|
// else memory + a small file in DATA_DIR (survives a restart inside the 60-second window).
|
||||||
const used = new Map(); let fileLoaded = false, tableReady = null;
|
const used = new Map(); let fileLoaded = false, tableReady = null;
|
||||||
@@ -127,7 +261,25 @@ const ck = (k, v, age, httpOnly) => k + '=' + encodeURIComponent(v) + '; Path=/;
|
|||||||
const go = (res, loc, set) => { const h = { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Robots-Tag': 'noindex' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(302, h); res.end(); return true; };
|
const go = (res, loc, set) => { const h = { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Robots-Tag': 'noindex' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(302, h); res.end(); return true; };
|
||||||
const sendJson = (res, obj, set) => { const h = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(200, h); res.end(JSON.stringify(obj)); return true; };
|
const sendJson = (res, obj, set) => { const h = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(200, h); res.end(JSON.stringify(obj)); return true; };
|
||||||
|
|
||||||
function init(opts) { C = Object.assign({ defaultPath: '/' }, opts); fileLoaded = false; used.clear(); }
|
function init(opts) { C = Object.assign({ defaultPath: '/' }, opts); fileLoaded = false; used.clear(); if (hubOn()) { hubSeen = 0; hubChecked = 0; hubUp().catch(() => {}); } hubSites = {}; hubSitesAt = 0; if (C.wallet) loadHubSites(); }
|
||||||
|
|
||||||
|
// a site this provider answers for: its own list first, then the hub's (never itself, never the peer, which has its own path)
|
||||||
|
function siteBase(x) {
|
||||||
|
if (!C || !C.wallet || !SITE_RE.test(String(x || '')) || x === C.self || x === C.peer) return null;
|
||||||
|
if (C.wallets && Object.prototype.hasOwnProperty.call(C.wallets, x)) return C.wallets[x];
|
||||||
|
if (Object.prototype.hasOwnProperty.call(hubSites, x)) { const b = hubSites[x]; return () => b; }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// an unknown site asking: ask the hub once more (at most every 30 s, 2 s at most) before refusing
|
||||||
|
async function siteBaseFresh(x) { let b = siteBase(x); if (!b && C && C.wallet && SITE_RE.test(String(x || '')) && Date.now() - hubSitesAt > 30000) { await loadHubSites(); b = siteBase(x); } return b; }
|
||||||
|
const siteName = x => NAMES[x] || ({ viraladsource: 'ViralAdSource', webworthit: 'WebWorthIt', stackpol: 'Stack POL' })[x] || x;
|
||||||
|
const retOf = req => { const m = /^([a-z0-9_-]{1,64})\|(\/.*)$/.exec(cookies(req)['nsso.ret'] || ''); return m ? { site: m[1], to: safePath(m[2], '/') } : null; };
|
||||||
|
// signed in here, on the way back to a site: its wallet step first when the site needs a wallet this account does not have yet
|
||||||
|
async function backHop(s, site, to, set) {
|
||||||
|
let w = null; try { w = await C.wallet(s); } catch (e) {}
|
||||||
|
if ((!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) && C.walletPath) { set.push(ck('nsso.wait', '1', BACK_AGE, true)); log('back: wallet step first', s.email, 'for ' + siteName(site)); return C.walletPath; }
|
||||||
|
return '/go/' + site + '?to=' + encodeURIComponent(to);
|
||||||
|
}
|
||||||
|
|
||||||
// the cookie a sign-out adds: no silent check on this site for 12 hours (a deliberate cross-site link still signs in)
|
// the cookie a sign-out adds: no silent check on this site for 12 hours (a deliberate cross-site link still signs in)
|
||||||
const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
|
const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
|
||||||
@@ -136,9 +288,24 @@ const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
|
|||||||
async function handle(req, res, u) {
|
async function handle(req, res, u) {
|
||||||
if (!C || req.method !== 'GET') return false;
|
if (!C || req.method !== 'GET') return false;
|
||||||
const p = u.pathname;
|
const p = u.pathname;
|
||||||
|
if (C.wallet && u.searchParams.has('return') && !/^\/(sso|api|go)(\/|$)/.test(p)) { // a site's "sign in / join on <provider>" link: remember the way back (2026-11-17)
|
||||||
|
const site = String(u.searchParams.get('return') || '').toLowerCase(); const to = safePath(u.searchParams.get('to'), '/');
|
||||||
|
const clean = new URL(u.pathname + u.search, 'http://x.invalid'); clean.searchParams.delete('return'); clean.searchParams.delete('to');
|
||||||
|
const here = safePath(clean.pathname + clean.search, '/');
|
||||||
|
const base = isBot(req) ? null : await siteBaseFresh(site);
|
||||||
|
if (!base) return go(res, here); // unknown site (or a bot): the page itself, nothing remembered
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
if (s && s.email) { // signed in here already: straight back (wallet step first when the site needs one)
|
||||||
|
const set = []; const hop = await backHop(s, site, to, set);
|
||||||
|
set.push(hop === C.walletPath ? ck('nsso.ret', site + '|' + to, RET_AGE, true) : ck('nsso.ret', '', 0, true));
|
||||||
|
return go(res, hop, set);
|
||||||
|
}
|
||||||
|
log('return link remembered', null, 'for ' + siteName(site));
|
||||||
|
return go(res, here, [ck('nsso.ret', site + '|' + to, RET_AGE, true), ck('nsso.wait', '', 0, true)]);
|
||||||
|
}
|
||||||
const peerName = NAMES[C.peer] || C.peer;
|
const peerName = NAMES[C.peer] || C.peer;
|
||||||
const goTo = p.startsWith('/go/') ? p.slice(4) : '';
|
const goTo = p.startsWith('/go/') ? p.slice(4) : '';
|
||||||
const walletBase = x => (C.wallets && Object.prototype.hasOwnProperty.call(C.wallets, x) ? C.wallets[x] : null);
|
const walletBase = siteBase; freshSites(); // the hand-written list, then the hub's sign-in sites (2026-11-17)
|
||||||
if (goTo && (goTo === C.peer || walletBase(goTo))) {
|
if (goTo && (goTo === C.peer || walletBase(goTo))) {
|
||||||
const base = goTo === C.peer ? C.peerBase() : walletBase(goTo)();
|
const base = goTo === C.peer ? C.peerBase() : walletBase(goTo)();
|
||||||
const to = safePath(u.searchParams.get('to'), '/');
|
const to = safePath(u.searchParams.get('to'), '/');
|
||||||
@@ -154,36 +321,79 @@ async function handle(req, res, u) {
|
|||||||
const mode = u.searchParams.get('mode') === 'go' ? 'go' : 'check';
|
const mode = u.searchParams.get('mode') === 'go' ? 'go' : 'check';
|
||||||
const via = String(u.searchParams.get('via') || '');
|
const via = String(u.searchParams.get('via') || '');
|
||||||
const from = C.from && Object.prototype.hasOwnProperty.call(C.from, via) ? C.from[via] : null; // a wallet site may ask either provider
|
const from = C.from && Object.prototype.hasOwnProperty.call(C.from, via) ? C.from[via] : null; // a wallet site may ask either provider
|
||||||
if (!enabled() || isBot(req) || notPage(req)) return go(res, to);
|
const viaHub = hubOn() && !u.searchParams.get('nohub') && (await hubUp());
|
||||||
|
if (!(enabled() || viaHub) || isBot(req) || notPage(req)) return go(res, to);
|
||||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
if (s && (s.email || s.address)) return go(res, to); // already signed in here
|
if (s && (s.email || s.address)) return go(res, to); // already signed in here
|
||||||
const c = cookies(req);
|
const c = cookies(req);
|
||||||
if (mode === 'check' && (c['nsso.tried'] || c['nsso.off'])) return go(res, to);
|
if (mode === 'check' && (c['nsso.tried'] || c['nsso.off']) && !u.searchParams.get('nohub')) return go(res, to);
|
||||||
const st = crypto.randomBytes(16).toString('hex');
|
const st = crypto.randomBytes(16).toString('hex');
|
||||||
const set = [ck('nsso.st', st, STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)];
|
if (viaHub) { // the hub answers for the whole network; the pairwise provider is the fallback when it has nobody (nsso.via)
|
||||||
|
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true), ck('nsso.via', via || '-', STATE_AGE, true)];
|
||||||
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||||
return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to), set);
|
return go(res, HUB_BASE() + '/sso/check?site=' + encodeURIComponent(HUB_NAME()) + '&st=' + st + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
|
||||||
|
}
|
||||||
|
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)];
|
||||||
|
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||||
|
return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
|
||||||
|
}
|
||||||
|
if (p === '/sso/resume') { // signed in on the provider after a deliberate tap: finish the check it was asked for (2026-11-14)
|
||||||
|
const q = new URLSearchParams(cookies(req)['nsso.back'] || '');
|
||||||
|
const clear = [ck('nsso.back', '', 0, true), ck('nsso.wait', '', 0, true)];
|
||||||
|
if (!/^[a-f0-9]{32}$/.test(q.get('st') || '')) { // no deliberate tap waiting: a ?return=<site> link may be (2026-11-17)
|
||||||
|
const ret = retOf(req);
|
||||||
|
if (!ret || !siteBase(ret.site)) return go(res, C.defaultPath, clear.concat(ck('nsso.ret', '', 0, true)));
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
if (!s || !s.email) return go(res, C.signinPath(C.defaultPath)); // not signed in yet: keep it for after the sign-in
|
||||||
|
const set = clear.slice(); const hop = await backHop(s, ret.site, ret.to, set);
|
||||||
|
set.push(hop === C.walletPath ? ck('nsso.ret', ret.site + '|' + ret.to, RET_AGE, true) : ck('nsso.ret', '', 0, true));
|
||||||
|
log('back to ' + siteName(ret.site), s.email); return go(res, hop, set);
|
||||||
|
}
|
||||||
|
return go(res, '/sso/check?st=' + q.get('st') + (q.get('r') ? '&r=' + encodeURIComponent(q.get('r')) : '') + '&to=' + encodeURIComponent(safePath(q.get('to'), '/')) + '&m=go', clear); // m=go: still a deliberate tap (the wallet step when one is missing)
|
||||||
}
|
}
|
||||||
if (p === '/sso/check') {
|
if (p === '/sso/check') {
|
||||||
const st = String(u.searchParams.get('st') || '');
|
const st = String(u.searchParams.get('st') || '');
|
||||||
const to = safePath(u.searchParams.get('to'), '/');
|
const to = safePath(u.searchParams.get('to'), '/');
|
||||||
const r = String(u.searchParams.get('r') || '');
|
const r = String(u.searchParams.get('r') || '');
|
||||||
const wb = r && r !== C.peer ? walletBase(r) : null; // a wallet site asking: the token carries the wallet
|
const wb = r && r !== C.peer ? await siteBaseFresh(r) : null; // a wallet site asking: the token carries the wallet (the hub's sign-in sites too, 2026-11-17)
|
||||||
const base = wb ? wb() : C.peerBase(), aud = wb ? r : C.peer, forName = NAMES[aud] || aud;
|
if (r && r !== C.peer && !wb) { log('check: unknown site asking, nothing sent', null, r.slice(0, 20)); return go(res, C.defaultPath); } // never answer an unknown site as if the peer asked (2026-11-15: 5xYourTeam was sent to LinkSpin)
|
||||||
|
const base = wb ? wb() : C.peerBase(), aud = wb ? r : C.peer, forName = siteName(aud);
|
||||||
const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to);
|
const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to);
|
||||||
if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none);
|
if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none);
|
||||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
if (!s || !s.email) { log('check: not signed in here', null, 'for ' + forName); return go(res, none); }
|
if (!s || !s.email) {
|
||||||
|
if (u.searchParams.get('m') === 'go' && !isBot(req)) { // a deliberate tap: sign in here first, then /sso/resume finishes the trip
|
||||||
|
log('check: not signed in here, asking to sign in', null, 'for ' + forName);
|
||||||
|
const back = new URLSearchParams({ st, to }); if (r) back.set('r', r);
|
||||||
|
return go(res, C.signinPath(C.defaultPath), [ck('nsso.back', back.toString(), BACK_AGE, true)]);
|
||||||
|
}
|
||||||
|
log('check: not signed in here', null, 'for ' + forName); return go(res, none);
|
||||||
|
}
|
||||||
let w = null;
|
let w = null;
|
||||||
if (wb) { try { w = await C.wallet(s); } catch (e) {} if (!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) { log('check: no wallet on the account', s.email, 'for ' + forName); return go(res, none); } }
|
if (wb) { try { w = await C.wallet(s); } catch (e) {} if (!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) {
|
||||||
|
if (u.searchParams.get('m') === 'go' && C.walletPath && !isBot(req)) { // a deliberate tap: link a wallet here first, then /sso/resume finishes the trip (2026-11-17)
|
||||||
|
log('check: no wallet on the account, wallet step first', s.email, 'for ' + forName);
|
||||||
|
const back = new URLSearchParams({ st, to, m: 'go' }); if (r) back.set('r', r);
|
||||||
|
return go(res, C.walletPath, [ck('nsso.back', back.toString(), BACK_AGE, true), ck('nsso.wait', '1', BACK_AGE, true)]);
|
||||||
|
}
|
||||||
|
log('check: no wallet on the account', s.email, 'for ' + forName); return go(res, none); } }
|
||||||
log('token issued', s.email, 'for ' + forName);
|
log('token issued', s.email, 'for ' + forName);
|
||||||
return go(res, base + '/sso/in?t=' + mint({ iss: C.self, aud, email: s.email, wallet: w && w.address, name: w && w.name, st, to }));
|
return go(res, base + '/sso/in?t=' + mint({ iss: C.self, aud, email: s.email, wallet: w && w.address, name: w && w.name, st, to }));
|
||||||
}
|
}
|
||||||
if (p === '/sso/in') {
|
if (p === '/sso/in') {
|
||||||
const c = cookies(req);
|
const c = cookies(req);
|
||||||
const set = [ck('nsso.st', '', 0, true)];
|
const set = [ck('nsso.st', '', 0, true)];
|
||||||
if (u.searchParams.get('none')) { log('none: not signed in on ' + peerName); return go(res, C.signinPath(safePath(u.searchParams.get('to'), C.defaultPath)), set); }
|
if (u.searchParams.get('none')) {
|
||||||
const v = verify(u.searchParams.get('t'), { iss: [C.peer].concat(Object.keys(C.from || {})), aud: C.self, st: c['nsso.st'] });
|
const nto = safePath(u.searchParams.get('to'), C.defaultPath);
|
||||||
|
if (u.searchParams.get('hub') && enabled()) { // nobody on the hub: ask the old pairwise provider once (until every site is switched)
|
||||||
|
const via = String(c['nsso.via'] || ''); set.push(ck('nsso.via', '', 0, true));
|
||||||
|
log('none on the hub, trying ' + (NAMES[via] || peerName));
|
||||||
|
return go(res, '/sso/start?nohub=1&mode=' + (u.searchParams.get('m') === 'go' ? 'go' : 'check') + (via && via !== '-' ? '&via=' + encodeURIComponent(via) : '') + '&to=' + encodeURIComponent(nto), set);
|
||||||
|
}
|
||||||
|
log('none: not signed in on ' + (u.searchParams.get('hub') ? 'the hub' : peerName)); return go(res, C.signinPath(nto), set);
|
||||||
|
}
|
||||||
|
const fromHub = !!u.searchParams.get('h');
|
||||||
|
const v = fromHub ? verifyHub(u.searchParams.get('h'), { st: c['nsso.st'] }) : verify(u.searchParams.get('t'), { iss: [C.peer].concat(Object.keys(C.from || {})), aud: C.self, st: c['nsso.st'] });
|
||||||
if (v.error) { log('refused: ' + v.error); return go(res, C.signinPath(C.defaultPath), set); }
|
if (v.error) { log('refused: ' + v.error); return go(res, C.signinPath(C.defaultPath), set); }
|
||||||
if (!(await spend(v.n, v.exp))) { log('refused: token already used', v.email); return go(res, C.signinPath(v.to), set); }
|
if (!(await spend(v.n, v.exp))) { log('refused: token already used', v.email); return go(res, C.signinPath(v.to), set); }
|
||||||
let a = null; try { a = await C.accept(v.email, req, v); } catch (e) { a = { fallback: 'error ' + e.message }; }
|
let a = null; try { a = await C.accept(v.email, req, v); } catch (e) { a = { fallback: 'error ' + e.message }; }
|
||||||
@@ -195,18 +405,48 @@ async function handle(req, res, u) {
|
|||||||
let cookie = null; try { cookie = await C.signIn(v.email, req, v); } catch (e) { console.error('network-sso sign-in', e.message); }
|
let cookie = null; try { cookie = await C.signIn(v.email, req, v); } catch (e) { console.error('network-sso sign-in', e.message); }
|
||||||
if (!cookie) { log('fallback to email code: session not made', v.email); return go(res, C.signinPath(v.to), set); }
|
if (!cookie) { log('fallback to email code: session not made', v.email); return go(res, C.signinPath(v.to), set); }
|
||||||
set.push(cookie); if (c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
set.push(cookie); if (c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||||
log('signed in from ' + (NAMES[v.iss] || peerName), v.email);
|
if (fromHub) { const w2 = v.wallet && C.from ? { wallet: v.wallet } : { email: v.email }; set.push(ck('nsso.hp', pushTag(w2), PUSH_AGE, true)); } // the hub already has this sign-in
|
||||||
|
log('signed in from ' + (fromHub ? 'the network hub' : (NAMES[v.iss] || peerName)), v.email);
|
||||||
return go(res, C.landing(v.to === '/' ? C.defaultPath : v.to), set); // no page named: the dashboard, not the public home page (2026-11-13)
|
return go(res, C.landing(v.to === '/' ? C.defaultPath : v.to), set); // no page named: the dashboard, not the public home page (2026-11-13)
|
||||||
}
|
}
|
||||||
if (p === '/api/sso/status') {
|
if (p === '/api/sso/status') {
|
||||||
const c = cookies(req); const set = [];
|
const c = cookies(req); const set = [];
|
||||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
const signedIn = !!(s && (s.email || s.address));
|
const signedIn = !!(s && (s.email || s.address));
|
||||||
const out = { peer: peerName, check: enabled() && !signedIn && !isBot(req) && !c['nsso.tried'] && !c['nsso.off'] };
|
const out = { peer: hubOn() ? 'the network' : peerName, check: (enabled() || (hubOn() && (await hubUp()))) && !signedIn && !isBot(req) && !c['nsso.tried'] && !c['nsso.off'] };
|
||||||
if (c['nsso.hint']) { if (!signedIn) out.hint = c['nsso.hint']; set.push(ck('nsso.hint', '', 0, true)); }
|
if (c['nsso.hint']) { if (!signedIn) out.hint = c['nsso.hint']; set.push(ck('nsso.hint', '', 0, true)); }
|
||||||
return sendJson(res, out, set);
|
return sendJson(res, out, set);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, handle, enabled, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES };
|
// every GET a site serves passes here first (2026-11-15): a signed-in member's real page load pings the hub's activity once a day and,
|
||||||
|
// with the hub on, tells the hub about this sign-in once (nsso.hp). -> true when it answered (the redirect through the hub).
|
||||||
|
async function page(req, res, u) {
|
||||||
|
if (!C || !hubCreds()) return false;
|
||||||
|
const p = u.pathname;
|
||||||
|
if (!pageLoad(req, p)) return false;
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
const w = who(s); if (!w) return false;
|
||||||
|
activity(w);
|
||||||
|
if (hubOn() && cookies(req)['nsso.hp'] !== pushTag(w) && (await hubUp())) {
|
||||||
|
log('hub: telling the hub about this sign-in', w.email || null);
|
||||||
|
return go(res, HUB_BASE() + '/sso/set?site=' + encodeURIComponent(HUB_NAME()) + '&t=' + mintHub(Object.assign({ to: p + u.search }, w)), [ck('nsso.hp', pushTag(w), PUSH_AGE, true)]);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// true when this browser came here from a deliberate network tap (nsso.back) or a ?return=<site> link (nsso.ret) and still has to
|
||||||
|
// finish it after signing in. False while it waits on the wallet step (nsso.wait): the dashboard must not bounce it back and forth.
|
||||||
|
const pendingBack = req => { const c = cookies(req); return !!(c['nsso.back'] || retOf(req)) && !c['nsso.wait']; };
|
||||||
|
// the wallet was just linked: the next hop when a way back is waiting (2026-11-17), else null
|
||||||
|
const afterWallet = req => { const c = cookies(req); return c['nsso.back'] || retOf(req) ? '/sso/resume' : null; };
|
||||||
|
// the name of the site a member is on the way back to, for a line on the provider's dashboard; null when none
|
||||||
|
function backName(req) {
|
||||||
|
const c = cookies(req); const ret = retOf(req);
|
||||||
|
if (ret) return siteName(ret.site);
|
||||||
|
if (!c['nsso.back']) return null;
|
||||||
|
const r = new URLSearchParams(c['nsso.back']).get('r'); return siteName(r || (C && C.peer) || '') || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { init, handle, page, seen, enabled, pendingBack, afterWallet, backName, siteBase, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES, hubOn, hubCreds, signOutEverywhere, mintHub, verifyHub, _hubSeen: t => { hubSeen = t == null ? Date.now() : t; hubChecked = Date.now(); }, _pinged: pinged, _hubSites: o => { if (o) { hubSites = o; hubSitesAt = Date.now(); } return hubSites; } };
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
|||||||
const BOARDS = ['visitors', 'sources'];
|
const BOARDS = ['visitors', 'sources'];
|
||||||
const COMPANY = '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70';
|
const COMPANY = '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70';
|
||||||
let C = null, key = null, D = null, busy = false, timer = null;
|
let C = null, key = null, D = null, busy = false, timer = null;
|
||||||
|
let onConfirmed = null; // proof.js: one Telegram line per confirmed prize transfer (2026-11-14); this module still posts nothing itself
|
||||||
|
function setHook(fn) { onConfirmed = typeof fn === 'function' ? fn : null; }
|
||||||
const st = { prepared: 0, paid: 0, lastError: null };
|
const st = { prepared: 0, paid: 0, lastError: null };
|
||||||
const FILE = () => path.join(C.dataDir, 'prizes.json');
|
const FILE = () => path.join(C.dataDir, 'prizes.json');
|
||||||
|
|
||||||
@@ -166,7 +168,7 @@ function watchReceipts(week) {
|
|||||||
const plan = D.weeks[week]; if (!plan) { watching.delete(week); return; }
|
const plan = D.weeks[week]; if (!plan) { watching.delete(week); return; }
|
||||||
for (const t of plan.transfers) {
|
for (const t of plan.transfers) {
|
||||||
if (t.status !== 'sent' || !t.tx) continue;
|
if (t.status !== 'sent' || !t.tx) continue;
|
||||||
try { const r = await shop.receipt(t.tx); if (r.found) { t.status = r.status === '0x1' ? 'confirmed' : 'reverted'; t.block = parseInt(r.blockNumber, 16); save(); } } catch (e) {}
|
try { const r = await shop.receipt(t.tx); if (r.found) { t.status = r.status === '0x1' ? 'confirmed' : 'reverted'; t.block = parseInt(r.blockNumber, 16); save(); if (t.status === 'confirmed' && onConfirmed) { try { onConfirmed(plan, t); } catch (e) {} } } } catch (e) {}
|
||||||
}
|
}
|
||||||
const open = plan.transfers.some(t => t.status === 'sent');
|
const open = plan.transfers.some(t => t.status === 'sent');
|
||||||
if (!open && (plan.status === 'sent' || plan.status === 'paying')) { plan.status = plan.transfers.every(t => t.status === 'confirmed') ? 'paid' : 'partial'; plan.payment.doneAt = Date.now(); save(); }
|
if (!open && (plan.status === 'sent' || plan.status === 'paying')) { plan.status = plan.transfers.every(t => t.status === 'confirmed') ? 'paid' : 'partial'; plan.payment.doneAt = Date.now(); save(); }
|
||||||
@@ -184,4 +186,4 @@ function history(n) {
|
|||||||
function plans() { return Object.values(D.weeks).sort((a, b) => b.week.localeCompare(a.week)); }
|
function plans() { return Object.values(D.weeks).sort((a, b) => b.week.localeCompare(a.week)); }
|
||||||
function view() { return Object.assign({ keyOn: !!key, keyAddress: key ? key.address.toLowerCase() : null, prizeWallet: C.prizePot.wallet, weeks: Object.keys(D.weeks).length }, st); }
|
function view() { return Object.assign({ keyOn: !!key, keyAddress: key ? key.address.toLowerCase() : null, prizeWallet: C.prizePot.wallet, weeks: Object.keys(D.weeks).length }, st); }
|
||||||
|
|
||||||
module.exports = { init, pot, prepare, pay, quotePlan, history, plans, view, prevWeek, auto };
|
module.exports = { setHook, init, pot, prepare, pay, quotePlan, history, plans, view, prevWeek, auto };
|
||||||
|
|||||||
@@ -9,10 +9,12 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const C = require('./config').get();
|
const C = require('./config').get();
|
||||||
|
const netsites = require('./netsites'); // tracked links: LinkSpin network link for this site, ?src=<this site> (2026-11-14)
|
||||||
|
|
||||||
const KIT_DIR = path.join(__dirname, 'public', 'art', 'kit');
|
const KIT_DIR = path.join(__dirname, 'public', 'art', 'kit');
|
||||||
const SHAPES = { tile: [125, 125, 'Square button (loop size)'], strip: [468, 60, 'Strip'], leader: [728, 90, 'Leaderboard'], box: [300, 250, 'Box'],
|
const SHAPES = { tile: [125, 125, 'Square button (loop size)'], strip: [468, 60, 'Strip'], leader: [728, 90, 'Leaderboard'], box: [300, 250, 'Box'], panel: [336, 280, 'Large box'],
|
||||||
tower: [160, 600, 'Skyscraper'], social: [1200, 630, 'Social share'], square: [1080, 1080, 'Square post'] };
|
tower: [160, 600, 'Skyscraper'], social: [1200, 630, 'Social share'], square: [1080, 1080, 'Square post'],
|
||||||
|
wide: [600, 300, 'Wide card'], small: [250, 250, 'Small square'] };
|
||||||
const ANGLES = { free: 'Free daily banner post', loop: 'Every visitor pushes the loop', prize: 'Weekly leaderboard prizes' };
|
const ANGLES = { free: 'Free daily banner post', loop: 'Every visitor pushes the loop', prize: 'Weekly leaderboard prizes' };
|
||||||
|
|
||||||
function copy() {
|
function copy() {
|
||||||
@@ -75,16 +77,18 @@ function kit(u) {
|
|||||||
const q = ref ? '?ref=' + encodeURIComponent(ref) : '';
|
const q = ref ? '?ref=' + encodeURIComponent(ref) : '';
|
||||||
const link = base() + '/' + q;
|
const link = base() + '/' + q;
|
||||||
const fill = s => s.split('{{LINK}}').join(link);
|
const fill = s => s.split('{{LINK}}').join(link);
|
||||||
|
// the same page through LinkSpin (Marty 2026-11-14: each network site its own traffic source): counted under this site, lands with ?ref=
|
||||||
|
const track = seg => netsites.tracked('vbb', 'vbb', { s1: ref, s2: seg });
|
||||||
const t = copy();
|
const t = copy();
|
||||||
return {
|
return {
|
||||||
v: 1, site: C.site, name: C.siteName, updated: '2026-11-14', username: ref || null,
|
v: 1, site: C.site, name: C.siteName, updated: '2026-11-16', username: ref || null,
|
||||||
tagline: 'One shared loop of 125x125 banners. Real visitors push it.',
|
tagline: 'One shared loop of 125x125 banners. Real visitors push it.',
|
||||||
links: [
|
links: [
|
||||||
{ key: 'home', label: 'Your link (the loop)', url: link },
|
{ key: 'home', label: 'Your link (the loop)', url: link, tracked: track('') },
|
||||||
{ key: 'how', label: 'How it works', url: base() + '/how' + q },
|
{ key: 'how', label: 'How it works', url: base() + '/how' + q, tracked: track('how') },
|
||||||
{ key: 'leaders', label: 'Weekly leaderboards', url: base() + '/leaders' + q }
|
{ key: 'leaders', label: 'Weekly leaderboards', url: base() + '/leaders' + q, tracked: track('leaders') }
|
||||||
],
|
],
|
||||||
linkTemplate: base() + '/?ref={username}',
|
linkTemplate: base() + '/?ref={username}', trackedTemplate: netsites.tracked('vbb', 'vbb') + '&s1={username}',
|
||||||
creatives: creatives().map(c => Object.assign({}, c, { html: '<a href="' + link + '" target="_blank" rel="noopener"><img src="' + c.url + '" width="' + c.w + '" height="' + c.h + '" alt="Viral Banner Blitz"></a>' })),
|
creatives: creatives().map(c => Object.assign({}, c, { html: '<a href="' + link + '" target="_blank" rel="noopener"><img src="' + c.url + '" width="' + c.w + '" height="' + c.h + '" alt="Viral Banner Blitz"></a>' })),
|
||||||
lines: t.lines.map(fill), headlines: t.headlines, email: { subject: t.email.subject, body: fill(t.email.body) }, posts: t.posts.map(fill),
|
lines: t.lines.map(fill), headlines: t.headlines, email: { subject: t.email.subject, body: fill(t.email.body) }, posts: t.posts.map(fill),
|
||||||
note: NOTE, promotePage: base() + '/promote'
|
note: NOTE, promotePage: base() + '/promote'
|
||||||
|
|||||||
@@ -0,0 +1,184 @@
|
|||||||
|
// Trust pack (Marty 2026-11-14: "all these sites need to show their live ledger and the contract for proof and trust, and toast
|
||||||
|
// notifications ... post a Telegram with some kind of image and stats, and payment notifications"). The Downline Banners pattern.
|
||||||
|
// - ledger(): every VBBShop purchase (from the Purchase events shop.js credited) with its split, and every weekly prize transfer,
|
||||||
|
// newest first, each with its transaction. Public, read by /ledger and the toasts.
|
||||||
|
// - contract(): the live contract facts for /contract (owner, prize wallet, company, keeper, paused, what it holds), read from the
|
||||||
|
// chain and cached 5 minutes; the split constants are the contract's own (30 / 10 / 60).
|
||||||
|
// - Telegram: one photo card per purchase (a prebuilt VBB proof image, rotated, + who bought what, the split paid in that same
|
||||||
|
// transaction, this week's numbers and the verify link) and one line per confirmed prize payout, in the group's payments topic
|
||||||
|
// (TG_CHAT / TG_PAY_TOPIC, the CTB Rewards bot TG_TOKEN, same as Downline Banners and the games). Sent once per transaction
|
||||||
|
// across app copies (docstore.claim). Never posts anything older than 2 hours (a re-index after downtime must not flood the
|
||||||
|
// topic). Off unless TG_TOKEN and TG_CHAT are set. TG_API (tests only) points at a stand-in.
|
||||||
|
'use strict';
|
||||||
|
const store = require('./store');
|
||||||
|
const docstore = require('./docstore');
|
||||||
|
|
||||||
|
const SPLIT = { sponsorBps: 3000, prizeBps: 1000, denom: 10000 }; // VBBShop SPONSOR_BPS / PRIZE_BPS (constants in the contract)
|
||||||
|
const ZERO = '0x0000000000000000000000000000000000000000';
|
||||||
|
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
||||||
|
// Paid(uint256 indexed id, address indexed to, uint256 amount, uint8 role) / PaymentFailed(same): read from the purchase receipt
|
||||||
|
const { Interface } = require('ethers');
|
||||||
|
const EV = new Interface(['event Paid(uint256 indexed id, address indexed to, uint256 amount, uint8 role)', 'event PaymentFailed(uint256 indexed id, address indexed to, uint256 amount, uint8 role)']);
|
||||||
|
const T_PAID = EV.getEvent('Paid').topicHash, T_FAIL = EV.getEvent('PaymentFailed').topicHash;
|
||||||
|
const ROLE = ['sponsor', 'prize', 'company'];
|
||||||
|
const CARDS = ['/art/proof/vbb-proof-pink.png', '/art/proof/vbb-proof-blue.png', '/art/proof/vbb-proof-yellow.png']; // rotated per post
|
||||||
|
const st = { posted: 0, prizeLines: 0, skipped: 0, failed: 0, lastError: null };
|
||||||
|
let C = null, shop = null, prize = null, names = null;
|
||||||
|
const sent = new Set(); // this copy's own guard (docstore.claim covers app copies; without MySQL it always says yes)
|
||||||
|
const once = k => { if (sent.has(k)) return false; sent.add(k); if (sent.size > 5000) sent.clear(); return true; };
|
||||||
|
|
||||||
|
function init(cfg, deps) { C = cfg; shop = deps.shop; prize = deps.prize; names = deps.nameOf || null; }
|
||||||
|
const on = () => !!(process.env.TG_TOKEN && process.env.TG_CHAT);
|
||||||
|
const lc = a => String(a || '').toLowerCase();
|
||||||
|
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
||||||
|
function nameLocal(addr) { const m = store.member(lc(addr)); return m && m.username ? m.username : null; }
|
||||||
|
async function nameOf(addr) {
|
||||||
|
const a = lc(addr); const local = nameLocal(a); if (local) return local;
|
||||||
|
if (names) { try { const n = await names(a); if (n) return n; } catch (e) {} }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const who = (addr, name) => name ? '@' + name : short(lc(addr));
|
||||||
|
const pol = wei => { const v = Number(BigInt(wei || 0) / 10n ** 12n) / 1e6; return v >= 100 ? v.toFixed(2) : v.toFixed(4); };
|
||||||
|
const usd = cents => '$' + (Number(cents || 0) / 100).toFixed(2);
|
||||||
|
const esc = s => String(s == null ? '' : s).replace(/[&<>]/g, c => ({ '&': '&', '<': '<', '>': '>' }[c]));
|
||||||
|
|
||||||
|
// what a purchase bought, in words (SKUs from config: packs and the banner look)
|
||||||
|
function what(x) {
|
||||||
|
if (x.credits > 0) return x.credits + ' post credits';
|
||||||
|
if (Number(x.sku) === Number(C.lookSku)) return 'the banner look';
|
||||||
|
return 'package #' + x.sku;
|
||||||
|
}
|
||||||
|
// the split of one purchase. From the receipt's Paid / PaymentFailed events when read, else from the contract's fixed math
|
||||||
|
// (sponsorPaid from the Purchase event, prize = 10% of the price paid, company = the rest).
|
||||||
|
function split(x) {
|
||||||
|
if (Array.isArray(x.pays) && x.pays.length) return x.pays;
|
||||||
|
let paid = 0n, sp = 0n; try { paid = BigInt(x.weiPaid || 0); sp = BigInt(x.sponsorPaid || 0); } catch (e) {}
|
||||||
|
const prizeWei = paid * BigInt(SPLIT.prizeBps) / BigInt(SPLIT.denom);
|
||||||
|
const out = [];
|
||||||
|
if (x.sponsor && x.sponsor !== ZERO && sp > 0n) out.push({ role: 'sponsor', to: lc(x.sponsor), wei: sp.toString() });
|
||||||
|
out.push({ role: 'prize', to: lc(C.prizePot.wallet), wei: prizeWei.toString() });
|
||||||
|
out.push({ role: 'company', to: null, wei: (paid - sp - prizeWei).toString() });
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// the Paid / PaymentFailed events of one purchase, from its receipt (null if the RPC does not answer)
|
||||||
|
async function readPays(tx, orderId) {
|
||||||
|
const r = await shop.rpc('eth_getTransactionReceipt', [tx]); if (!r || !Array.isArray(r.logs)) return null;
|
||||||
|
const out = [];
|
||||||
|
for (const l of r.logs) {
|
||||||
|
if (lc(l.address) !== lc(C.contractAddress) || (l.topics[0] !== T_PAID && l.topics[0] !== T_FAIL)) continue;
|
||||||
|
const d = EV.parseLog({ topics: l.topics, data: l.data }).args; if (Number(d.id) !== Number(orderId)) continue;
|
||||||
|
out.push({ role: ROLE[Number(d.role)] || 'role' + Number(d.role), to: lc(d.to), wei: d.amount.toString(), failed: l.topics[0] === T_FAIL || undefined });
|
||||||
|
}
|
||||||
|
return out.length ? out : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- public ledger ----
|
||||||
|
function purchases() {
|
||||||
|
const P = (store.state() && store.state().purchases) || {};
|
||||||
|
return Object.entries(P).map(([k, x]) => Object.assign({ tx: k.split(':')[0] }, x));
|
||||||
|
}
|
||||||
|
function ledger(n) {
|
||||||
|
const lim = Math.min(200, Math.max(1, Number(n) || 50));
|
||||||
|
const rows = purchases().map(x => {
|
||||||
|
const s = split(x);
|
||||||
|
return { kind: 'purchase', tx: x.tx, at: (x.blockAt ? x.blockAt * 1000 : x.at) || null, orderId: x.orderId, buyer: x.buyer, buyerName: nameLocal(x.buyer), what: what(x),
|
||||||
|
usdCents: x.usdCents, weiPaid: x.weiPaid, pays: s.map(p => ({ role: p.role, to: p.to, name: p.to ? nameLocal(p.to) : null, wei: p.wei, failed: p.failed || undefined })) };
|
||||||
|
});
|
||||||
|
for (const wk of (prize && prize.history ? prize.history(52) : [])) for (const w of wk.winners) {
|
||||||
|
if (!w.tx) continue;
|
||||||
|
rows.push({ kind: 'prize', tx: w.tx, at: wk.paidAt || null, week: wk.week, board: w.board, place: w.place, name: w.name, usd: w.usd, pol: w.pol, confirmed: !!w.confirmed });
|
||||||
|
}
|
||||||
|
rows.sort((a, b) => (b.at || 0) - (a.at || 0));
|
||||||
|
const P = purchases(); let wei = 0n, cents = 0, sponsors = 0n;
|
||||||
|
for (const x of P) { try { wei += BigInt(x.weiPaid || 0); sponsors += BigInt(x.sponsorPaid || 0); } catch (e) {} cents += Number(x.usdCents) || 0; }
|
||||||
|
const prizesPaid = rows.filter(r => r.kind === 'prize' && r.confirmed).length;
|
||||||
|
return { contract: C.contractAddress || null, explorer: C.explorer, items: rows.slice(0, lim),
|
||||||
|
totals: { purchases: P.length, usdCents: cents, weiPaid: wei.toString(), sponsorWei: sponsors.toString(), prizePayouts: prizesPaid } };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- contract facts (cached 5 minutes) ----
|
||||||
|
let cCache = null;
|
||||||
|
async function contract() {
|
||||||
|
if (cCache && Date.now() - cCache.at < 300000) return cCache.v;
|
||||||
|
const v = { address: C.contractAddress || null, chainId: C.chainId, explorer: C.explorer, split: { sponsorPct: 30, prizePct: 10, companyPct: 60 },
|
||||||
|
// Sourcify exact match 2026-11-13; Polygonscan verified 2026-11-16 (env VERIFIED_POLYGONSCAN=1 shows it as done)
|
||||||
|
verified: { sourcify: true, polygonscan: process.env.VERIFIED_POLYGONSCAN === '1' ? 'done' : 'pending', sourcifyUrl: C.contractAddress ? 'https://repo.sourcify.dev/' + C.chainId + '/' + C.contractAddress : null },
|
||||||
|
ownerNote: "Marty's Tangem hardware wallet", live: false };
|
||||||
|
if (shop && shop.watching()) {
|
||||||
|
const I = new Interface(['function owner() view returns (address)', 'function company() view returns (address)', 'function keeper() view returns (address)',
|
||||||
|
'function prizeWallet() view returns (address)', 'function paused() view returns (bool)', 'function totalOwed() view returns (uint256)', 'function orderCount() view returns (uint256)']);
|
||||||
|
const read = async fn => I.decodeFunctionResult(fn, await shop.rpc('eth_call', [{ to: C.contractAddress, data: I.encodeFunctionData(fn, []) }, 'latest']))[0];
|
||||||
|
try {
|
||||||
|
const [owner, company, keeper, prizeWallet, paused, totalOwed, orderCount, bal] = await Promise.all(['owner', 'company', 'keeper', 'prizeWallet', 'paused', 'totalOwed', 'orderCount'].map(read)
|
||||||
|
.concat([shop.rpc('eth_getBalance', [C.contractAddress, 'latest'])]));
|
||||||
|
Object.assign(v, { owner: lc(owner), company: lc(company), keeper: lc(keeper), prizeWallet: lc(prizeWallet), paused: !!paused, totalOwedWei: totalOwed.toString(),
|
||||||
|
orderCount: Number(orderCount), balanceWei: BigInt(bal).toString(), live: true, readAt: Date.now() });
|
||||||
|
} catch (e) { v.error = 'The chain did not answer just now. Try again in a minute.'; }
|
||||||
|
}
|
||||||
|
cCache = { at: Date.now(), v: v };
|
||||||
|
if (v.error) cCache.at = Date.now() - 240000; // retry sooner
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Telegram ----
|
||||||
|
async function tg(method, body) {
|
||||||
|
const base = String(process.env.TG_API || 'https://api.telegram.org').replace(/\/+$/, '');
|
||||||
|
const b = Object.assign({ chat_id: process.env.TG_CHAT, parse_mode: 'HTML' }, body);
|
||||||
|
if (process.env.TG_PAY_TOPIC) b.message_thread_id = Number(process.env.TG_PAY_TOPIC);
|
||||||
|
const r = await fetch(base + '/bot' + process.env.TG_TOKEN + '/' + method, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(b), signal: AbortSignal.timeout(15000) });
|
||||||
|
const j = await r.json().catch(() => ({}));
|
||||||
|
if (!j.ok) { st.failed++; st.lastError = String(j.description || r.status).slice(0, 160); console.error('proof: telegram', method, 'failed', r.status, st.lastError); return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// this week's numbers (Central-time week): purchases and dollars from the credited events, the prize pot the site already shows
|
||||||
|
function weekLine() {
|
||||||
|
const wk = store.ctWeek(); const s = shop.weekSales(wk, store.ctWeek); let potUsd = null;
|
||||||
|
try { potUsd = prize.pot(wk).potUsd; } catch (e) {}
|
||||||
|
return '\u{1F4CA} This week: ' + s.purchases + ' purchase' + (s.purchases === 1 ? '' : 's') + ', ' + usd(s.cents) + (potUsd != null ? ' · prize pot $' + Number(potUsd).toFixed(2) : '');
|
||||||
|
}
|
||||||
|
async function caption(x) {
|
||||||
|
const lines = ['\u{1F4A5} <b>Viral Banner Blitz</b>', '\u{1F9FE} ' + esc(who(x.buyer, await nameOf(x.buyer))) + ' bought ' + esc(what(x)) + ' · ' + usd(x.usdCents) + ' (' + pol(x.weiPaid) + ' POL)'];
|
||||||
|
for (const p of split(x)) {
|
||||||
|
if (p.failed) { lines.push('⚠️ ' + (p.role === 'sponsor' ? 'Sponsor' : p.role) + ' payment to ' + esc(who(p.to, await nameOf(p.to))) + ' bounced; it waits in the contract for them to claim'); continue; }
|
||||||
|
if (p.role === 'sponsor') lines.push('\u{1F4B8} Sponsor 30%: ' + pol(p.wei) + ' POL → ' + esc(who(p.to, await nameOf(p.to))));
|
||||||
|
else if (p.role === 'prize') lines.push('\u{1F3C6} Weekly prize pot 10%: ' + pol(p.wei) + ' POL');
|
||||||
|
else if (p.role === 'company') lines.push('\u{1F3E6} Viral Banner Blitz: ' + pol(p.wei) + ' POL');
|
||||||
|
}
|
||||||
|
lines.push('Split by the contract in this same transaction. The contract keeps nothing and there is nothing to withdraw.');
|
||||||
|
lines.push(weekLine());
|
||||||
|
lines.push('· <a href="' + esc(C.explorer) + '/tx/' + esc(x.tx) + '">Verify on Polygonscan</a> · <a href="https://' + esc(C.site) + '/ledger">Live ledger</a>');
|
||||||
|
return lines.join('\n');
|
||||||
|
}
|
||||||
|
let card = 0;
|
||||||
|
// shop.js calls this once per newly credited purchase (rec = the stored purchase, tx = its transaction)
|
||||||
|
function onPurchase(rec, tx) {
|
||||||
|
const x = Object.assign({ tx }, rec);
|
||||||
|
(async () => {
|
||||||
|
// the real split from the receipt (a bounced push shows as owed), kept on the purchase for the ledger
|
||||||
|
try { const pays = await readPays(tx, rec.orderId); if (pays) { const S = store.state(); const k = Object.keys(S.purchases || {}).find(k2 => k2.startsWith(lc(tx) + ':') && S.purchases[k2].orderId === rec.orderId); if (k) { S.purchases[k].pays = pays; store.save(); } x.pays = pays; } } catch (e) {}
|
||||||
|
if (!on()) return;
|
||||||
|
const at = (rec.blockAt ? rec.blockAt * 1000 : rec.at) || Date.now();
|
||||||
|
if (Date.now() - at > 2 * 3600000) { st.skipped++; return; }
|
||||||
|
const text = await caption(x);
|
||||||
|
if (!once('p:' + lc(tx) + ':' + rec.orderId) || !(await docstore.claim('vbbtg:' + lc(tx) + ':' + rec.orderId))) return; // another app copy already posted this purchase
|
||||||
|
const photo = 'https://' + C.site + CARDS[card++ % CARDS.length];
|
||||||
|
let ok = await tg('sendPhoto', { photo: process.env.TG_PHOTO_BASE ? String(process.env.TG_PHOTO_BASE).replace(/\/+$/, '') + CARDS[(card - 1) % CARDS.length] : photo, caption: text });
|
||||||
|
if (!ok) ok = await tg('sendMessage', { text, disable_web_page_preview: true }); // a photo the API cannot fetch still gets its proof line
|
||||||
|
if (ok) { st.posted++; console.log('proof: posted purchase', String(tx).slice(0, 12)); }
|
||||||
|
})().catch(e => { st.failed++; st.lastError = String(e.message).slice(0, 160); });
|
||||||
|
}
|
||||||
|
// prize.js calls this when a prize transfer confirms on chain
|
||||||
|
function onPrize(plan, t) {
|
||||||
|
if (!on() || !t || !t.tx) return;
|
||||||
|
(async () => {
|
||||||
|
if (t.sentAt && Date.now() - t.sentAt > 2 * 3600000) { st.skipped++; return; }
|
||||||
|
if (!once('z:' + lc(t.tx)) || !(await docstore.claim('vbbtg-prize:' + lc(t.tx)))) return;
|
||||||
|
const board = t.board === 'sources' ? 'most traffic sources' : 'most verified visitors';
|
||||||
|
const place = ['1st', '2nd', '3rd'][t.place - 1] || ('#' + t.place);
|
||||||
|
const text = '\u{1F3C6} <b>Viral Banner Blitz weekly prize</b>\n' + esc(t.name || short(t.address)) + ' · ' + place + ' place, ' + board + ' (week of ' + esc(plan.week) + '): '
|
||||||
|
+ esc(t.pol) + ' POL ($' + Number(t.usd).toFixed(2) + ')\n· <a href="' + esc(C.explorer) + '/tx/' + esc(t.tx) + '">Verify on Polygonscan</a> · <a href="https://' + esc(C.site) + '/ledger">Live ledger</a>';
|
||||||
|
if (await tg('sendMessage', { text, disable_web_page_preview: true })) { st.prizeLines++; console.log('proof: posted prize', String(t.tx).slice(0, 12)); }
|
||||||
|
})().catch(e => { st.failed++; st.lastError = String(e.message).slice(0, 160); });
|
||||||
|
}
|
||||||
|
function view() { return Object.assign({ telegram: on(), topic: process.env.TG_PAY_TOPIC || null }, st); }
|
||||||
|
module.exports = { init, ledger, contract, onPurchase, onPrize, caption, split, view, on, CARDS };
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="wrap">
|
<main class="wrap">
|
||||||
@@ -31,12 +31,16 @@
|
|||||||
<div id="adm" hidden>
|
<div id="adm" hidden>
|
||||||
<div class="card"><h2>Status</h2><div class="stats" id="aStats"></div><pre class="mono small scroll" id="aRaw" style="white-space:pre-wrap;max-height:320px"></pre></div>
|
<div class="card"><h2>Status</h2><div class="stats" id="aStats"></div><pre class="mono small scroll" id="aRaw" style="white-space:pre-wrap;max-height:320px"></pre></div>
|
||||||
<div class="card" id="pzCard"><h2>Weekly prize payouts</h2><p class="muted small">Each Monday after midnight (Central) the app prepares last week's payout. Nothing is sent until you approve it here, and a week is paid once. Amounts in POL are quoted live and fixed when you approve.</p><div id="pzNow"></div><div id="pzWeeks"></div><div class="row"><button class="btn sec small" id="pzPrep">Prepare last week again</button></div></div>
|
<div class="card" id="pzCard"><h2>Weekly prize payouts</h2><p class="muted small">Each Monday after midnight (Central) the app prepares last week's payout. Nothing is sent until you approve it here, and a week is paid once. Amounts in POL are quoted live and fixed when you approve.</p><div id="pzNow"></div><div id="pzWeeks"></div><div class="row"><button class="btn sec small" id="pzPrep">Prepare last week again</button></div></div>
|
||||||
|
<div class="card" id="bnCard"><h2>Banners: take down or restore</h2><p class="muted small">Find a banner by #id, wallet or username. A takedown hides it everywhere at once; its loop place stays (a house tile shows there) until it would have ridden out, so nobody else moves. It never cycles, never earns network views and never counts for prizes. The reason is shown to the owner. Every takedown and restore goes in the admin ledger below.</p>
|
||||||
|
<div class="share"><input id="bnQ" placeholder="#12, 0x... or username" autocomplete="off" aria-label="Find a banner"><button class="btn sec small" id="bnFind">Find</button></div><div id="bnList"></div></div>
|
||||||
|
<div class="card"><h2>Admin ledger (takedowns and restores)</h2><div class="scroll" id="aActions"></div></div>
|
||||||
<div class="card"><h2>Rewards by member</h2><div class="scroll" id="aMembers"></div></div>
|
<div class="card"><h2>Rewards by member</h2><div class="scroll" id="aMembers"></div></div>
|
||||||
<div class="card"><h2>Ledger (newest first)</h2><div class="scroll" id="aLedger"></div></div>
|
<div class="card"><h2>Ledger (newest first)</h2><div class="scroll" id="aLedger"></div></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/admin.js?v=2"></script>
|
<script src="/assets/admin.js?v=3"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 112 KiB |
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 125 125" width="125" height="125">
|
||||||
|
<rect width="125" height="125" fill="#ffd400"/>
|
||||||
|
<g fill="#ff2d87" opacity=".18"><circle cx="15" cy="15" r="5"/><circle cx="45" cy="15" r="5"/><circle cx="75" cy="15" r="5"/><circle cx="105" cy="15" r="5"/><circle cx="30" cy="110" r="5"/><circle cx="60" cy="110" r="5"/><circle cx="90" cy="110" r="5"/><circle cx="120" cy="110" r="5"/></g>
|
||||||
|
<text x="62.5" y="50" fill="#14121f" font-family="sans-serif" font-size="13" font-weight="800" text-anchor="middle">Viral Banner</text>
|
||||||
|
<text x="62.5" y="66" fill="#14121f" font-family="sans-serif" font-size="13" font-weight="800" text-anchor="middle">Blitz</text>
|
||||||
|
<rect x="22" y="76" width="81" height="20" rx="10" fill="#ff2d87" stroke="#14121f" stroke-width="2"/>
|
||||||
|
<text x="62.5" y="90" fill="#fff" font-family="sans-serif" font-size="11" font-weight="700" text-anchor="middle">Post yours</text>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 944 B |
@@ -13,7 +13,7 @@
|
|||||||
['Shifts today', s.today.shifts], ['Cycles today', s.today.cycles], ['Visitors today', s.today.visits], ['Cycles total', s.totals.cycles], ['Views recorded', VBB.n(s.ledger.views)], ['Views credited', VBB.n(s.ledger.credited)], ['Members', s.members]]
|
['Shifts today', s.today.shifts], ['Cycles today', s.today.cycles], ['Visitors today', s.today.visits], ['Cycles total', s.totals.cycles], ['Views recorded', VBB.n(s.ledger.views)], ['Views credited', VBB.n(s.ledger.credited)], ['Members', s.members]]
|
||||||
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
||||||
$('aRaw').textContent = JSON.stringify(s, null, 2);
|
$('aRaw').textContent = JSON.stringify(s, null, 2);
|
||||||
prizes(); setInterval(prizes, 30000);
|
prizes(); setInterval(prizes, 30000); actions();
|
||||||
const l = await get('/api/admin/ledger?n=300');
|
const l = await get('/api/admin/ledger?n=300');
|
||||||
const who = r => r.username ? '@' + r.username : VBB.short(r.address || r.owner);
|
const who = r => r.username ? '@' + r.username : VBB.short(r.address || r.owner);
|
||||||
$('aMembers').innerHTML = l.members && l.members.length ? '<table class="t"><tr><th>Member</th><th class="n">Cycles</th><th class="n">Views</th></tr>' + l.members.map(m => '<tr><td>' + esc(who(m)) + '</td><td class="n">' + m.cycles + '</td><td class="n">' + VBB.n(m.views) + '</td></tr>').join('') + '</table>' : '<p class="muted">No cycles yet.</p>';
|
$('aMembers').innerHTML = l.members && l.members.length ? '<table class="t"><tr><th>Member</th><th class="n">Cycles</th><th class="n">Views</th></tr>' + l.members.map(m => '<tr><td>' + esc(who(m)) + '</td><td class="n">' + m.cycles + '</td><td class="n">' + VBB.n(m.views) + '</td></tr>').join('') + '</table>' : '<p class="muted">No cycles yet.</p>';
|
||||||
@@ -57,6 +57,56 @@
|
|||||||
const r = await VBB.getJSON('/api/admin/prizes/prepare', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: '{}' });
|
const r = await VBB.getJSON('/api/admin/prizes/prepare', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: '{}' });
|
||||||
VBB.status(r.error || 'Prepared the week of ' + r.week + '.', r.error ? 'err' : 'ok'); prizes();
|
VBB.status(r.error || 'Prepared the week of ' + r.week + '.', r.error ? 'err' : 'ok'); prizes();
|
||||||
};
|
};
|
||||||
|
// ---- banner takedown / restore (Marty 2026-11-15): reason required, credit back or none; restore takes a given credit back ----
|
||||||
|
const send = (u, body) => VBB.getJSON(u, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: JSON.stringify(body) });
|
||||||
|
const ct = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago' }) + ' CT' : '';
|
||||||
|
async function actions() {
|
||||||
|
const a = await get('/api/admin/actions?n=200'); if (a.error) return;
|
||||||
|
$('aActions').innerHTML = a.actions.length ? '<table class="t"><tr><th>When (CT)</th><th>Action</th><th>Banner</th><th>Owner</th><th>By</th><th>Reason</th><th>Credit</th></tr>'
|
||||||
|
+ a.actions.map(e => '<tr><td>' + esc(ct(e.at)) + '</td><td>' + esc(e.action) + (e.cycleRecorded ? ' (cycle recorded)' : '') + '</td><td>#' + e.bannerId + '</td><td>' + esc(e.username ? '@' + e.username : VBB.short(e.owner)) + '</td><td>' + esc(e.by) + '</td><td>' + esc(e.reason || '') + '</td><td>' + esc(e.credit) + '</td></tr>').join('') + '</table>'
|
||||||
|
: '<p class="muted">No takedowns yet.</p>';
|
||||||
|
}
|
||||||
|
async function findBanners() {
|
||||||
|
const q = $('bnQ').value.trim(); if (!q) return;
|
||||||
|
const d = await get('/api/admin/banners?q=' + encodeURIComponent(q));
|
||||||
|
if (d.error) { $('bnList').innerHTML = '<p class="note err small">' + esc(d.error) + '</p>'; return; }
|
||||||
|
$('bnList').innerHTML = '';
|
||||||
|
for (const b of d.banners) {
|
||||||
|
const el = document.createElement('div'); el.className = 'adm-b';
|
||||||
|
const st = b.down ? 'TAKEN DOWN ' + ct(b.down.at) + ' by ' + b.down.by + ': ' + b.down.reason + (b.down.creditBack ? ' (credit given back)' : ' (no credit)') + '. Slot: ' + b.state
|
||||||
|
: b.state === 'queued' ? 'Waiting #' + b.position + ' of ' + b.of : b.state === 'loop' ? 'In the loop, place ' + b.place + ' of ' + b.of : b.state;
|
||||||
|
el.innerHTML = '<img alt="Banner #' + b.id + '" width="72" height="72"><div class="s"><b>#' + b.id + '</b> ' + esc(b.username ? '@' + b.username : '') + ' <span class="mono small">' + esc(b.owner) + '</span><br>'
|
||||||
|
+ esc(st) + '<br>Link: <span class="mono small">' + esc(b.link) + '</span><br><span class="muted small">' + VBB.n(b.clicks) + ' clicks. Posted ' + esc(ct(b.createdAt)) + '.'
|
||||||
|
+ (b.swaps.length ? ' Swapped ' + esc(ct(b.swaps[0].at)) + ' from ' + esc(b.swaps[0].old.link) + '.' : '') + (b.downs.length ? ' Restored before: ' + b.downs.length + 'x.' : '') + '</span><div class="act"></div></div>';
|
||||||
|
el.querySelector('img').src = b.img;
|
||||||
|
const act = el.querySelector('.act');
|
||||||
|
if (b.down) {
|
||||||
|
act.innerHTML = '<div class="field"><label>Why restore (optional)</label><input class="rs"></div><button class="btn small">Restore this banner' + (b.down.creditBack ? ' (takes the credit back)' : '') + '</button>';
|
||||||
|
act.querySelector('button').onclick = async () => {
|
||||||
|
const r = await send('/api/admin/banners/' + b.id + '/restore', { reason: act.querySelector('.rs').value });
|
||||||
|
VBB.status(r.error || ('Banner #' + b.id + ' restored.' + (r.creditReversed ? ' The credit was taken back.' : r.creditAlreadyUsed ? ' The owner already used the credit, so it was not taken back.' : '') + (r.cycle ? ' Its place had ridden out, so its cycle is recorded now.' : '')), r.error ? 'err' : 'ok');
|
||||||
|
findBanners(); actions();
|
||||||
|
};
|
||||||
|
} else if (b.state === 'queued' || b.state === 'loop') {
|
||||||
|
act.innerHTML = '<div class="field"><label>Reason (the owner sees it)</label><textarea class="why" maxlength="300"></textarea></div>'
|
||||||
|
+ '<div class="row"><label class="small"><input type="radio" name="cr' + b.id + '" value="back"> Credit back</label><label class="small"><input type="radio" name="cr' + b.id + '" value="none"> No credit</label>'
|
||||||
|
+ '<button class="btn small">Take down</button></div>';
|
||||||
|
const bt = act.querySelector('button');
|
||||||
|
bt.onclick = async () => {
|
||||||
|
const reason = act.querySelector('.why').value.trim(); const c = act.querySelector('input[type=radio]:checked');
|
||||||
|
if (reason.length < 3) return VBB.status('Write the reason first.', 'err');
|
||||||
|
if (!c) return VBB.status('Choose credit back or no credit.', 'err');
|
||||||
|
if (!bt.dataset.armed) { bt.dataset.armed = '1'; bt.textContent = 'Click again to take down #' + b.id; setTimeout(() => { if (bt.isConnected) { delete bt.dataset.armed; bt.textContent = 'Take down'; } }, 8000); return; }
|
||||||
|
const r = await send('/api/admin/banners/' + b.id + '/takedown', { reason, credit: c.value });
|
||||||
|
VBB.status(r.error || ('Banner #' + b.id + ' taken down' + (c.value === 'back' ? ', credit given back.' : ', no credit.')), r.error ? 'err' : 'ok');
|
||||||
|
findBanners(); actions();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$('bnList').appendChild(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('bnFind').onclick = findBanners;
|
||||||
|
$('bnQ').addEventListener('keydown', e => { if (e.key === 'Enter') findBanners(); });
|
||||||
$('tokBtn').onclick = () => { tok = $('tok').value.trim(); open(); };
|
$('tokBtn').onclick = () => { tok = $('tok').value.trim(); open(); };
|
||||||
$('tok').addEventListener('keydown', e => { if (e.key === 'Enter') $('tokBtn').click(); });
|
$('tok').addEventListener('keydown', e => { if (e.key === 'Enter') $('tokBtn').click(); });
|
||||||
if (tok) open();
|
if (tok) open();
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/* Site assistant widget, Viral Banner Blitz look (vbb.css): pop-art. Cream panel, thick ink borders with hard offset shadows,
|
||||||
|
hot pink and amber, Bricolage Grotesque headings, DM Sans body. Fallbacks match vbb.css. */
|
||||||
|
#scChat{--sc-bg:var(--bg2,#fffaf0);--sc-ink:var(--ink,#14121f);--sc-sub:var(--muted,#4d4862);--sc-head:var(--amber,#ffd400);--sc-hot:var(--hot,#ff2d87);
|
||||||
|
--sc-bot:var(--panel,#fff);--sc-me:var(--sky,#2b59ff);--sc-edge:2.5px solid var(--line2,#14121f);--sc-shadow:5px 5px 0 var(--line2,#14121f);--sc-shadow-sm:3px 3px 0 var(--line2,#14121f);
|
||||||
|
--sc-font:var(--body,"DM Sans","Segoe UI",system-ui,sans-serif);--sc-disp:var(--disp,"Bricolage Grotesque","Arial Black",system-ui,sans-serif);
|
||||||
|
position:fixed;right:18px;bottom:18px;z-index:80;font-family:var(--sc-font)}
|
||||||
|
#scBtn{width:58px;height:58px;border-radius:16px;border:var(--sc-edge);cursor:pointer;background:var(--sc-hot);color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:var(--sc-shadow-sm);transition:transform .12s}
|
||||||
|
#scBtn:hover{transform:translate(-2px,-2px);box-shadow:var(--sc-shadow)}
|
||||||
|
#scBtn:focus-visible{outline:3px solid var(--sc-me);outline-offset:3px}
|
||||||
|
#scChat.open #scBtn{background:var(--sc-head);color:var(--sc-ink)}
|
||||||
|
/* the panel sets display:flex, which would beat the hidden attribute: closing must win */
|
||||||
|
#scPanel[hidden]{display:none}
|
||||||
|
#scPanel{position:absolute;right:0;bottom:74px;width:370px;max-width:calc(100vw - 32px);height:540px;max-height:calc(100vh - 110px);display:flex;flex-direction:column;
|
||||||
|
background:var(--sc-bg);color:var(--sc-ink);border:var(--sc-edge);border-radius:16px;box-shadow:var(--sc-shadow);overflow:hidden}
|
||||||
|
.sc-head{display:flex;align-items:flex-start;gap:10px;padding:14px 16px;background:var(--sc-head);color:var(--sc-ink);border-bottom:var(--sc-edge)}
|
||||||
|
.sc-head>div{flex:1;min-width:0}
|
||||||
|
.sc-title{display:block;font-family:var(--sc-disp);font-weight:800;font-size:20px;letter-spacing:-.02em}
|
||||||
|
.sc-sub{display:block;font-size:12.5px;color:var(--sc-ink);opacity:.8}
|
||||||
|
#scClose{background:#fff;border:2px solid var(--sc-ink);border-radius:8px;color:var(--sc-ink);font-size:20px;line-height:1;width:30px;height:30px;cursor:pointer;padding:0}
|
||||||
|
.sc-msgs{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px}
|
||||||
|
.sc-m{max-width:88%;padding:9px 12px;font-size:14.5px;line-height:1.45;border-radius:12px;border:2px solid var(--sc-ink);overflow-wrap:anywhere}
|
||||||
|
.sc-m.bot{align-self:flex-start;background:var(--sc-bot);color:var(--sc-ink);box-shadow:var(--sc-shadow-sm)}
|
||||||
|
.sc-m.me{align-self:flex-end;background:var(--sc-me);color:#fff;box-shadow:var(--sc-shadow-sm)}
|
||||||
|
.sc-m a{color:inherit;text-decoration:underline;text-decoration-thickness:2px}
|
||||||
|
.sc-m.wait{opacity:.6}
|
||||||
|
.sc-cta{display:inline-block;background:var(--sc-hot);color:#fff!important;text-decoration:none!important;font-weight:800;padding:8px 14px;border:2px solid var(--sc-ink);border-radius:10px;box-shadow:var(--sc-shadow-sm);font-family:var(--sc-disp)}
|
||||||
|
.sc-handoff{background:transparent!important;border:0!important;box-shadow:none!important;padding:0!important}
|
||||||
|
.sc-topics{display:flex;flex-wrap:wrap;gap:6px;padding:0 14px 8px}
|
||||||
|
.sc-topics button{background:var(--amber-soft,#fff3a8);color:var(--sc-ink);border:2px solid var(--sc-ink);border-radius:999px;font:700 12.5px var(--sc-font);padding:4px 10px;cursor:pointer}
|
||||||
|
.sc-topics button:hover{background:var(--sc-head)}
|
||||||
|
.sc-input{display:flex;gap:8px;padding:10px 12px;border-top:var(--sc-edge);background:#fff}
|
||||||
|
.sc-input input{flex:1;min-width:0;border:2px solid var(--sc-ink);border-radius:10px;padding:9px 12px;font:15px var(--sc-font);color:var(--sc-ink);background:var(--sc-bg)}
|
||||||
|
.sc-input input:focus{outline:3px solid var(--sc-hot);outline-offset:0}
|
||||||
|
.sc-input button{background:var(--sc-hot);color:#fff;border:2px solid var(--sc-ink);border-radius:10px;font:800 14px var(--sc-disp);padding:0 16px;cursor:pointer;box-shadow:var(--sc-shadow-sm)}
|
||||||
|
.sc-human{display:block;text-align:center;font-size:12.5px;color:var(--sc-sub);padding:0 0 10px;background:#fff}
|
||||||
|
@media (max-width:600px){#scChat{right:12px;bottom:12px}#scBtn{width:52px;height:52px}#scPanel{bottom:66px;height:calc(100vh - 100px)}}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// Site assistant widget (2026-11-15): a round button bottom right, a panel that asks /api/chat. The look is this site's own,
|
||||||
|
// in /assets/chat.css (colors and fonts from the site's stylesheet). When an answer cannot help, or the visitor asks for a
|
||||||
|
// person, it offers "Open network support": InstantAdPay's support desk, which already knows the question and the site.
|
||||||
|
// The SAME file ships in ViralAdBlitz, DownlineHydra, 5xYourTeam, Viral Banner Blitz, Downline Banners and Stack POL.
|
||||||
|
(function () {
|
||||||
|
if (window.__siteChat || /^\/admin/.test(location.pathname)) return;
|
||||||
|
window.__siteChat = 1;
|
||||||
|
var css = document.createElement('link'); css.rel = 'stylesheet'; css.href = '/assets/chat.css?v=20261115d'; document.head.appendChild(css);
|
||||||
|
var NAME = 'this site', TOPICS = [];
|
||||||
|
var root = document.createElement('div'); root.id = 'scChat';
|
||||||
|
root.innerHTML = '<button id="scBtn" type="button" aria-label="Ask a question" aria-expanded="false">'
|
||||||
|
+ '<svg viewBox="0 0 24 24" width="26" height="26" aria-hidden="true"><path fill="currentColor" d="M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 4v-4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm3 6.5a1.5 1.5 0 1 0 0 .01zm5 0a1.5 1.5 0 1 0 0 .01zm5 0a1.5 1.5 0 1 0 0 .01z"/></svg></button>'
|
||||||
|
+ '<div id="scPanel" role="dialog" aria-label="Questions" hidden>'
|
||||||
|
+ '<div class="sc-head"><div><b class="sc-title" id="scTitle">Ask a question</b><span class="sc-sub">Straight answers about this site and the network</span></div>'
|
||||||
|
+ '<button id="scClose" type="button" aria-label="Close">×</button></div>'
|
||||||
|
+ '<div class="sc-msgs" id="scMsgs" aria-live="polite"></div>'
|
||||||
|
+ '<div class="sc-topics" id="scTopics"></div>'
|
||||||
|
+ '<form class="sc-input" id="scForm"><input id="scIn" autocomplete="off" maxlength="600" placeholder="Type your question" aria-label="Your question">'
|
||||||
|
+ '<button type="submit" id="scSend">Send</button></form>'
|
||||||
|
+ '<a class="sc-human" id="scHuman" href="https://instantadpay.com/support" target="_blank" rel="noopener">Need a person? Open network support</a>'
|
||||||
|
+ '</div>';
|
||||||
|
document.body.appendChild(root);
|
||||||
|
var $ = function (id) { return document.getElementById(id); };
|
||||||
|
var msgs = $('scMsgs'), input = $('scIn'), panel = $('scPanel'), btn = $('scBtn');
|
||||||
|
var history = [], greeted = false, support = 'https://instantadpay.com/support';
|
||||||
|
fetch('/api/chat/config').then(function (r) { return r.json(); }).then(function (c) {
|
||||||
|
if (c.name) { NAME = c.name; $('scTitle').textContent = 'Ask ' + c.name; }
|
||||||
|
if (c.support) { support = c.support; $('scHuman').href = c.support; }
|
||||||
|
TOPICS = c.topics || [];
|
||||||
|
}).catch(function () {});
|
||||||
|
|
||||||
|
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); }
|
||||||
|
function add(text, who) {
|
||||||
|
var d = document.createElement('div'); d.className = 'sc-m ' + who;
|
||||||
|
d.innerHTML = esc(text).replace(/(https?:\/\/[^\s<]+[^\s<.,;:!?)])/g, '<a href="$1" target="_blank" rel="noopener">$1</a>');
|
||||||
|
msgs.appendChild(d); msgs.scrollTop = msgs.scrollHeight; return d;
|
||||||
|
}
|
||||||
|
function offer(link) {
|
||||||
|
var old = msgs.querySelector('.sc-handoff'); if (old) old.remove();
|
||||||
|
var d = document.createElement('div'); d.className = 'sc-m bot sc-handoff';
|
||||||
|
var a = document.createElement('a'); a.className = 'sc-cta'; a.href = link || support; a.target = '_blank'; a.rel = 'noopener'; a.textContent = 'Open network support';
|
||||||
|
d.appendChild(a); msgs.appendChild(d); msgs.scrollTop = msgs.scrollHeight;
|
||||||
|
}
|
||||||
|
function open() {
|
||||||
|
panel.hidden = false; btn.setAttribute('aria-expanded', 'true'); root.className = 'open';
|
||||||
|
if (!greeted) {
|
||||||
|
greeted = true;
|
||||||
|
add('Hi. Ask me how ' + NAME + ' works, what it costs, how payouts work, or about any other site in the network. Straight answers, no income hype.', 'bot');
|
||||||
|
var t = $('scTopics'); TOPICS.slice(0, 4).forEach(function (q) {
|
||||||
|
var b = document.createElement('button'); b.type = 'button'; b.textContent = q; b.addEventListener('click', function () { input.value = q; send(); }); t.appendChild(b);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setTimeout(function () { input.focus(); }, 50);
|
||||||
|
}
|
||||||
|
function close() { panel.hidden = true; btn.setAttribute('aria-expanded', 'false'); root.className = ''; }
|
||||||
|
btn.addEventListener('click', function () { panel.hidden ? open() : close(); });
|
||||||
|
$('scClose').addEventListener('click', close);
|
||||||
|
document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && !panel.hidden) close(); });
|
||||||
|
async function send() {
|
||||||
|
var q = input.value.trim(); if (!q) return;
|
||||||
|
input.value = ''; $('scTopics').innerHTML = '';
|
||||||
|
add(q, 'me'); var wait = add('...', 'bot wait');
|
||||||
|
try {
|
||||||
|
var r = await (await fetch('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: q, history: history.slice(-6) }) })).json();
|
||||||
|
wait.remove();
|
||||||
|
add(r.reply || r.error || 'Something went wrong. Try again in a moment.', 'bot');
|
||||||
|
history.push(q, r.reply || '');
|
||||||
|
if (r.handoff) offer(r.support);
|
||||||
|
} catch (e) { wait.remove(); add('I could not reach the assistant just now. Try again in a moment, or open network support.', 'bot'); offer(); }
|
||||||
|
}
|
||||||
|
$('scForm').addEventListener('submit', function (e) { e.preventDefault(); send(); });
|
||||||
|
})();
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
// Shared page helpers (VBB namespace, modelled on Downline Banners' common.js): nav, footer, toasts, fetch helpers.
|
// Shared page helpers (VBB namespace, modelled on Downline Banners' common.js): nav, footer, toasts, fetch helpers.
|
||||||
window.VBB = (function () {
|
window.VBB = (function () {
|
||||||
|
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints itself only while a network event is live (exact Central times)
|
||||||
|
if (!/^\/admin/.test(location.pathname)) { const nw = document.createElement('script'); nw.src = '/assets/netweekend.js?v=20261117a'; nw.defer = true; nw.setAttribute('data-site', 'vbb'); document.head.appendChild(nw); }
|
||||||
let cfgP = null;
|
let cfgP = null;
|
||||||
const $ = id => document.getElementById(id);
|
const $ = id => document.getElementById(id);
|
||||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||||
const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json()));
|
const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json()));
|
||||||
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
||||||
const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })();
|
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 || ''; }
|
function status(msg, cls) { const el = $('status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; if (msg) el.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); } // the note sits at the foot of the page: bring it into view (2026-11-15, a failed post looked like a dead button)
|
||||||
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; }
|
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 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');
|
const n = x => Number(x || 0).toLocaleString('en-US');
|
||||||
|
|
||||||
function renderNav(active) {
|
function renderNav(active) {
|
||||||
const nav = document.createElement('nav'); nav.className = 'top';
|
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']];
|
const links = [['/', 'The loop'], ['/leaders', 'Leaderboards'], ['/how', 'How it works'], ['/guides', 'Guides'], ['/packages', 'Packages'], ['/promote', 'Promote'], ['/my', 'My Banners']];
|
||||||
nav.innerHTML = '<div class="wrap"><a class="brand" href="/"><img src="/art/mark.svg" alt="" width="36" height="36"><span><span class="wm">Viral Banner <b>Blitz</b></span>'
|
nav.innerHTML = '<div class="wrap"><a class="brand" href="/"><img src="/art/mark.svg" alt="" width="36" height="36"><span><span class="wm">Viral Banner <b>Blitz</b></span>'
|
||||||
+ '<span class="by">Part of the Crypto Team Build Network</span></span></a><div class="links">'
|
+ '<span class="by">Part of the Crypto Team Build Network</span></span></a><div class="links">'
|
||||||
+ links.map(l => '<a href="' + l[0] + '"' + (l[0] === active ? ' class="on" aria-current="page"' : '') + '>' + l[1] + '</a>').join('') + '</div></div>';
|
+ links.map(l => '<a href="' + l[0] + '"' + (l[0] === active ? ' class="on" aria-current="page"' : '') + '>' + l[1] + '</a>').join('') + '</div></div>';
|
||||||
@@ -24,7 +26,7 @@ window.VBB = (function () {
|
|||||||
// network ad zones (Marty 2026-11-14, the Downline Banners pattern): LinkSpin zones on Marty's account, one per placement, each
|
// 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
|
// 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.
|
// server.js. NEVER on the loop page (/) or admin. An empty id = that placement stays off.
|
||||||
const ZONES = { footWide: '', footPhone: '', leaders: '', my: '', how: '' };
|
const ZONES = { footWide: 'ls-b17eff', footPhone: 'ls-e8f989', leaders: 'ls-0be4df', my: 'ls-88b761', how: 'ls-9824e4' }; // Marty's LinkSpin zones for viralbannerblitz.com (2026-11-14)
|
||||||
function zone(el, key) {
|
function zone(el, key) {
|
||||||
if (!el || el.dataset.zoned || !ZONES[key]) return; el.dataset.zoned = '1'; el.classList.add('net-zone');
|
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 lab = document.createElement('div'); lab.className = 'net-zone-label'; lab.textContent = 'Network';
|
||||||
@@ -47,34 +49,75 @@ window.VBB = (function () {
|
|||||||
const f = document.createElement('footer'); f.className = 'foot';
|
const f = document.createElement('footer'); f.className = 'foot';
|
||||||
f.innerHTML = '<div class="wrap"><p><b>Viral Banner Blitz</b>, part of the Crypto Team Build Network</p>'
|
f.innerHTML = '<div class="wrap"><p><b>Viral Banner Blitz</b>, part of the Crypto Team Build Network</p>'
|
||||||
+ '<p>A banner that cycles earns advertising across the network, not cash. Nothing here is an income opportunity.</p>'
|
+ '<p>A banner that cycles earns advertising across the network, not cash. Nothing here is an income opportunity.</p>'
|
||||||
+ '<p><a href="/">The loop</a> · <a href="/leaders">Leaderboards</a> · <a href="/how">How it works</a> · <a href="/packages">Packages</a> · <a href="/promote">Promote</a> · <a href="/my">My Banners</a></p></div>';
|
+ '<p><a href="/">The loop</a> · <a href="/leaders">Leaderboards</a> · <a href="/how">How it works</a> · <a href="/guides">Guides</a> · <a href="/packages">Packages</a> · <a href="/promote">Promote</a> · <a href="/my">My Banners</a></p>'
|
||||||
|
// trust pack (Marty 2026-11-14): legal + proof links, company line, and the network line served by the hub
|
||||||
|
+ '<p class="legal-links"><a href="/terms">Terms</a> · <a href="/disclaimer">Earnings Disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="/contract">Contract</a> · <a href="/ledger">Ledger</a> · <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Support</a></p>'
|
||||||
|
+ '<p class="co">© 2026 TrustClickz</p><p class="netline"></p></div>';
|
||||||
document.body.appendChild(f);
|
document.body.appendChild(f);
|
||||||
|
netLine(f.querySelector('.netline'));
|
||||||
toasts();
|
toasts();
|
||||||
}
|
}
|
||||||
// live cycle toasts: real cycles from the ledger only, bottom-left, one at a time, never older than 30 minutes
|
// "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] }));
|
||||||
|
// the footer links carry a referral username (Marty 2026-11-15): the signed-in member's own, else the ?ref= this visitor came in on
|
||||||
|
// (vbb.ref cookie, usernames only). Tracked links get it as s1 (LinkSpin sends it on as ?ref=), plain links as ?ref=. Earners Corner takes none.
|
||||||
|
const REF_RE = /^[A-Za-z0-9_.-]{1,40}$/;
|
||||||
|
const refCookie = () => { const m = document.cookie.match(/(?:^|;\s*)vbb\.ref=([^;]*)/); try { const v = m ? decodeURIComponent(m[1]) : ''; return REF_RE.test(v) && !/^0x[0-9a-f]{40}$/i.test(v) ? v : ''; } catch (e) { return ''; } };
|
||||||
|
function withRef(s, ref) {
|
||||||
|
const href = s.go || s.url; if (!ref || s.id === 'earnerscorner') return href;
|
||||||
|
try { const u = new URL(href); u.searchParams.set(s.go ? 's1' : 'ref', ref); return u.toString(); } catch (e) { return href; }
|
||||||
|
}
|
||||||
|
function netLine(el) {
|
||||||
|
if (!el) return;
|
||||||
|
let list = NET; let ref = refCookie();
|
||||||
|
const paint = () => { el.innerHTML = '<b>Part of the network</b> · One account across the network: ' + list.map(s => (s.id === 'vbb' || /viralbannerblitz\.com/.test(s.url))
|
||||||
|
? '<span class="here" aria-current="page">' + esc(s.name) + '</span>' : '<a href="' + esc(withRef(s, ref)) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>').join(' · '); };
|
||||||
|
paint();
|
||||||
|
fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) { list = l; paint(); } }).catch(() => {});
|
||||||
|
fetch('/api/me', { credentials: 'same-origin' }).then(r => r.json()).then(m => { if (m && m.signedIn && m.username && REF_RE.test(m.username)) { ref = m.username; paint(); } }).catch(() => {});
|
||||||
|
}
|
||||||
|
// live toasts: real cycles, purchases and prize payouts only, bottom-left, one at a time, never older than 30 minutes
|
||||||
let toastsOn = false;
|
let toastsOn = false;
|
||||||
function toasts() {
|
function toasts() {
|
||||||
if (toastsOn) return; toastsOn = true;
|
if (toastsOn) return; toastsOn = true;
|
||||||
const seen = new Set(); let first = 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 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 show = c => {
|
||||||
const el = document.createElement('a'); el.className = 'toast'; el.href = '/how';
|
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 = '<b>' + whoOf(c.buyer, c.buyerName) + ' bought ' + esc(c.what) + '</b><br><span>' + (sp ? whoOf(sp.to, sp.name) + ' got ' + polOf(sp.wei) + ' POL, same transaction' : 'paid on-chain, split by the contract') + '</span>';
|
||||||
|
} else if (c.kind === 'prize') {
|
||||||
|
el.href = '/ledger'; el.className = 'toast prize';
|
||||||
|
el.innerHTML = '<b>' + esc(c.name) + ' won a weekly prize</b><br><span>' + esc(c.pol) + ' POL paid on-chain</span>';
|
||||||
|
} else {
|
||||||
|
el.href = '/how';
|
||||||
el.innerHTML = '<b>' + (c.name ? esc(c.name) + '\'s banner' : 'A banner') + ' just cycled</b><br><span>' + n(c.views) + ' network ad views earned for its owner</span>';
|
el.innerHTML = '<b>' + (c.name ? esc(c.name) + '\'s banner' : 'A banner') + ' just cycled</b><br><span>' + n(c.views) + ' network ad views earned for its owner</span>';
|
||||||
|
}
|
||||||
box.appendChild(el); requestAnimationFrame(() => el.classList.add('in'));
|
box.appendChild(el); requestAnimationFrame(() => el.classList.add('in'));
|
||||||
setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000);
|
setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000);
|
||||||
};
|
};
|
||||||
const tick = async () => {
|
const tick = async () => {
|
||||||
let d; try { d = await getJSON('/api/recent'); } catch (e) { return; } if (!d || !d.cycles) return;
|
const [d, l] = await Promise.all([getJSON('/api/recent').catch(() => null), getJSON('/api/ledger?n=6').catch(() => null)]);
|
||||||
const fresh = d.cycles.filter(c => !seen.has(c.id)); d.cycles.forEach(c => seen.add(c.id));
|
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;
|
const list = first ? fresh.slice(0, 1) : fresh.reverse(); first = false;
|
||||||
list.slice(0, 3).forEach((c, i) => setTimeout(() => show(c), 1500 + i * 8000));
|
list.slice(0, 3).forEach((c, i) => setTimeout(() => show(c), 1500 + i * 8000));
|
||||||
};
|
};
|
||||||
tick(); setInterval(tick, 25000);
|
tick(); setInterval(tick, 25000);
|
||||||
}
|
}
|
||||||
function tile(t, extra) {
|
function tile(t, extra) {
|
||||||
const a = document.createElement('a'); a.className = 'tile' + (t.look ? ' look' : '') + (extra && extra.cls ? ' ' + extra.cls : '');
|
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.href = t.href; a.target = '_blank'; a.rel = 'noopener';
|
||||||
a.innerHTML = '<img alt="' + esc(t.owner ? 'Banner by ' + t.owner : 'Member banner #' + t.id) + '" width="125" height="125" loading="lazy" referrerpolicy="no-referrer">'
|
a.innerHTML = '<img alt="' + esc(t.t === 'spin' ? 'LinkSpin Banner Spin' + (t.owner ? ' by ' + t.owner : '') : t.owner ? 'Banner by ' + t.owner : 'Member banner #' + t.id) + '" width="125" height="125" loading="lazy" referrerpolicy="no-referrer">'
|
||||||
+ (extra && extra.pos ? '<span class="pos">' + esc(extra.pos) + '</span>' : '') + (t.owner ? '<span class="who">' + esc(t.owner) + '</span>' : '');
|
+ (extra && extra.pos ? '<span class="pos">' + esc(extra.pos) + '</span>' : '') + (t.owner ? '<span class="who">' + esc(t.owner) + '</span>' : '');
|
||||||
if (t.look && t.teaser) { const s = document.createElement('span'); s.className = 'teaser'; s.textContent = t.teaser; a.appendChild(s); a.title = t.teaser; }
|
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'; };
|
const img = a.querySelector('img'); img.src = t.img; img.onerror = () => { img.onerror = null; img.src = '/art/tile-fallback.svg'; };
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// Contract proof page (trust pack 2026-11-14): live facts from /api/contract (read from Polygon, cached 5 minutes on the server).
|
||||||
|
(async function () {
|
||||||
|
VBB.renderNav('/contract'); VBB.renderFooter();
|
||||||
|
const el = document.getElementById('facts'); const esc = VBB.esc;
|
||||||
|
let d; try { d = await VBB.getJSON('/api/contract'); } catch (e) { d = {}; }
|
||||||
|
const ex = d.explorer || 'https://polygonscan.com';
|
||||||
|
const addr = (a, note) => a ? '<a class="mono" href="' + esc(ex) + '/address/' + esc(a) + '" target="_blank" rel="noopener">' + esc(VBB.short(a)) + '</a>' + (note ? '<br><span class="muted small">' + note + '</span>' : '') : '<span class="muted">not read yet</span>';
|
||||||
|
const pol = w => { try { const v = BigInt(w || 0); return (Number(v / 10n ** 14n) / 1e4).toFixed(4) + ' POL'; } catch (e) { return '0 POL'; } };
|
||||||
|
if (!d.address) { el.innerHTML = '<tr><td class="muted">The contract address is not set on this copy of the site.</td></tr>'; return; }
|
||||||
|
const rows = [
|
||||||
|
['Contract', addr(d.address, 'VBBShop on ' + (d.chainId === 137 ? 'Polygon' : 'chain ' + d.chainId))],
|
||||||
|
['Source code', 'Verified on <a href="' + esc(d.verified && d.verified.sourcifyUrl || '#') + '" target="_blank" rel="noopener">Sourcify</a> (exact match). Polygonscan: ' + (d.verified && d.verified.polygonscan === 'done' ? '<a href="' + esc(ex) + '/address/' + esc(d.address) + '#code" target="_blank" rel="noopener">verified</a>' : 'pending')],
|
||||||
|
['Owner', addr(d.owner, 'A Tangem hardware wallet. It can pause new sales, set package prices, and change the keeper and the prize wallet. It cannot move anyone\'s money or change the split.')],
|
||||||
|
['Prize wallet', addr(d.prizeWallet, 'Receives the 10% prize share of each purchase and pays the weekly leaderboard winners.')],
|
||||||
|
['Company', addr(d.company, 'Viral Banner Blitz. Fixed in the contract when it was deployed.')],
|
||||||
|
['Keeper', addr(d.keeper, 'The site\'s signing key. It only signs which sponsor a buyer has, once, on their first purchase.')],
|
||||||
|
['Sales', d.live ? (d.paused ? '<b>Paused</b>' : 'Open') + ' · ' + VBB.n(d.orderCount) + ' purchases so far' : '<span class="muted">' + esc(d.error || 'not read yet') + '</span>'],
|
||||||
|
['Held by the contract', d.live ? pol(d.balanceWei) + (BigInt(d.totalOwedWei || 0) > 0n ? ' (all of it owed to wallets whose payment bounced, waiting for them to claim)' : ' (nothing is kept: every purchase is paid out in the same transaction)') : '<span class="muted">not read yet</span>']
|
||||||
|
];
|
||||||
|
const psn = document.getElementById('psnote');
|
||||||
|
if (psn) psn.textContent = d.verified && d.verified.polygonscan === 'done' ? 'Its source code is verified on Polygonscan (Contract tab) and on Sourcify (exact match).' : 'Its source code is verified on Sourcify (exact match); the Polygonscan verification check is pending, so use the Sourcify link to read the source.';
|
||||||
|
el.innerHTML = '<tbody>' + rows.map(r => '<tr><th style="width:30%">' + r[0] + '</th><td>' + r[1] + '</td></tr>').join('') + '</tbody>';
|
||||||
|
})();
|
||||||
@@ -13,13 +13,15 @@ window.KitPage = (function () {
|
|||||||
const cb = (text, label, cls) => { TXT.push(text); return '<button type="button" class="btn small ' + (cls || 'sec') + '" data-kc="' + (TXT.length - 1) + '">' + esc(label || 'Copy') + '</button>'; };
|
const cb = (text, label, cls) => { TXT.push(text); return '<button type="button" class="btn small ' + (cls || 'sec') + '" data-kc="' + (TXT.length - 1) + '">' + esc(label || 'Copy') + '</button>'; };
|
||||||
// on the kit's own site, show creatives from this origin (same files; the copied URL stays absolute)
|
// on the kit's own site, show creatives from this origin (same files; the copied URL stays absolute)
|
||||||
function local(url, k) { try { const u = new URL(url); return u.hostname === k.site && location.hostname !== k.site ? u.pathname : url; } catch (e) { return url; } }
|
function local(url, k) { try { const u = new URL(url); return u.hostname === k.site && location.hostname !== k.site ? u.pathname : url; } catch (e) { return url; } }
|
||||||
|
const row = (label, url, cls) => '<div class="kit-row"><div class="kit-l"><span class="kit-lab">' + esc(label) + '</span><code class="kit-url">' + esc(url) + '</code></div>' + cb(url, 'Copy link', cls) + '</div>';
|
||||||
function render(root, k) {
|
function render(root, k) {
|
||||||
TXT.length = 0;
|
TXT.length = 0;
|
||||||
const angles = []; const by = {};
|
const angles = []; const by = {};
|
||||||
(k.creatives || []).forEach(c => { if (!by[c.angle]) { by[c.angle] = []; angles.push(c); } by[c.angle].push(c); });
|
(k.creatives || []).forEach(c => { if (!by[c.angle]) { by[c.angle] = []; angles.push(c); } by[c.angle].push(c); });
|
||||||
let h = '';
|
let h = '';
|
||||||
h += '<div class="card"><h3>Your links</h3>' + (k.username ? '<p class="muted small">Every link, creative and line below carries <b>' + esc(k.username) + '</b>.</p>' : '<p class="muted small">Add your network username above so these links carry it.</p>')
|
h += '<div class="card"><h3>Your links</h3>' + (k.username ? '<p class="muted small">Every link, creative and line below carries <b>' + esc(k.username) + '</b>.</p>' : '<p class="muted small">Add your network username above so these links carry it.</p>')
|
||||||
+ k.links.map(l => '<div class="kit-row"><div class="kit-l"><span class="kit-lab">' + esc(l.label) + '</span><code class="kit-url">' + esc(l.url) + '</code></div>' + cb(l.url, 'Copy link', '') + '</div>').join('') + '</div>';
|
+ k.links.map(l => row(l.label, l.url, '') + (l.tracked ? row(l.label + ', tracked', l.tracked, 'sec') : '')).join('')
|
||||||
|
+ (k.links.some(l => l.tracked) ? '<p class="muted small">A tracked link goes through LinkSpin first, so the network can see which site sent the visit, then opens the same page with your username. Use either one.</p>' : '') + '</div>';
|
||||||
h += '<div class="card"><h3>Creatives</h3><p class="muted small">Download them, or copy the HTML: it already links to you.</p><div class="kit-tabs" role="tablist">'
|
h += '<div class="card"><h3>Creatives</h3><p class="muted small">Download them, or copy the HTML: it already links to you.</p><div class="kit-tabs" role="tablist">'
|
||||||
+ angles.map((c, i) => '<button type="button" class="kit-tab' + (i ? '' : ' on') + '" data-ka="' + esc(c.angle) + '">' + esc(c.angleLabel) + '</button>').join('') + '</div>';
|
+ angles.map((c, i) => '<button type="button" class="kit-tab' + (i ? '' : ' on') + '" data-ka="' + esc(c.angle) + '">' + esc(c.angleLabel) + '</button>').join('') + '</div>';
|
||||||
angles.forEach((a, i) => {
|
angles.forEach((a, i) => {
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Live ledger (trust pack 2026-11-14): purchases with their split and weekly prize payouts from /api/ledger, refreshed every 30 s.
|
||||||
|
(function () {
|
||||||
|
VBB.renderNav('/ledger'); VBB.renderFooter();
|
||||||
|
const esc = VBB.esc;
|
||||||
|
const pol = w => { try { const v = BigInt(w || 0); const n = Number(v / 10n ** 12n) / 1e6; return (n >= 100 ? n.toFixed(2) : n.toFixed(4)) + ' POL'; } catch (e) { return '0 POL'; } };
|
||||||
|
const usd = c => '$' + (Number(c || 0) / 100).toFixed(2);
|
||||||
|
const when = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
|
||||||
|
const who = (a, n) => n ? '@' + esc(n) : '<span class="mono">' + esc(VBB.short(a || '')) + '</span>';
|
||||||
|
const ROLE = { sponsor: 'Sponsor 30%', prize: 'Prize pot 10%', company: 'Viral Banner Blitz' };
|
||||||
|
async function load() {
|
||||||
|
let d; try { d = await VBB.getJSON('/api/ledger?n=100'); } catch (e) { return; } if (!d || !d.items) return;
|
||||||
|
const ex = d.explorer || 'https://polygonscan.com'; const t = d.totals || {};
|
||||||
|
document.getElementById('totals').innerHTML = '<div class="stat"><b>' + VBB.n(t.purchases) + '</b><span>purchases on-chain</span></div>'
|
||||||
|
+ '<div class="stat"><b>' + pol(t.sponsorWei) + '</b><span>paid to sponsors, same transaction</span></div>'
|
||||||
|
+ '<div class="stat"><b>' + VBB.n(t.prizePayouts) + '</b><span>weekly prize payouts</span></div>'
|
||||||
|
+ '<div class="stat"><b>0</b><span>withdrawals needed: every purchase pays out in the same transaction</span></div>';
|
||||||
|
const body = document.querySelector('#rows tbody');
|
||||||
|
if (!d.items.length) { body.innerHTML = '<tr><td colspan="4" class="muted">No purchases yet. The first one will show here within a minute of its transaction.</td></tr>'; return; }
|
||||||
|
body.innerHTML = d.items.map(r => {
|
||||||
|
const link = '<a href="' + esc(ex) + '/tx/' + esc(r.tx) + '" target="_blank" rel="noopener">Polygonscan</a>';
|
||||||
|
if (r.kind === 'prize') {
|
||||||
|
const place = ['1st', '2nd', '3rd'][r.place - 1] || '#' + r.place;
|
||||||
|
return '<tr><td class="small">' + when(r.at) + '</td><td><span class="pill cycled">Prize</span><br>' + esc(r.name) + ', ' + place + ' place, ' + (r.board === 'sources' ? 'most traffic sources' : 'most verified visitors') + ' (week of ' + esc(r.week) + ')</td>'
|
||||||
|
+ '<td class="small">' + esc(r.pol) + ' POL ($' + Number(r.usd).toFixed(2) + ') from the prize wallet' + (r.confirmed ? '' : ' <span class="muted">(confirming)</span>') + '</td><td>' + link + '</td></tr>';
|
||||||
|
}
|
||||||
|
const pays = (r.pays || []).map(p => esc(ROLE[p.role] || p.role) + ': ' + pol(p.wei) + (p.role === 'sponsor' ? ' to ' + who(p.to, p.name) : '') + (p.failed ? ' <span class="muted">(bounced, waiting in the contract for them to claim)</span>' : '')).join('<br>');
|
||||||
|
return '<tr><td class="small">' + when(r.at) + '</td><td><span class="pill loop">Purchase</span><br>' + who(r.buyer, r.buyerName) + ' bought ' + esc(r.what) + ' for ' + usd(r.usdCents) + '</td><td class="small">' + pays + '</td><td>' + link + '</td></tr>';
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
load(); setInterval(load, 30000);
|
||||||
|
})();
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$('outBtn').onclick = async () => { await VBB.post('/api/auth/logout'); location.reload(); };
|
$('outBtn').onclick = async () => { await VBB.post('/api/auth/logout'); location.reload(); };
|
||||||
|
$('outAllBtn').onclick = async () => { $('outAllBtn').disabled = true; await VBB.post('/api/auth/logout-everywhere'); location.reload(); };
|
||||||
|
|
||||||
let uploaded = '';
|
let uploaded = '';
|
||||||
function preview(src) { const p = $('preview'); p.innerHTML = src ? '<img alt="Preview" width="125" height="125">' : '125 x 125<br>preview'; if (src) p.querySelector('img').src = src; }
|
function preview(src) { const p = $('preview'); p.innerHTML = src ? '<img alt="Preview" width="125" height="125">' : '125 x 125<br>preview'; if (src) p.querySelector('img').src = src; }
|
||||||
@@ -40,13 +41,93 @@
|
|||||||
VBB.status(r.banner.state === 'loop' ? 'Posted. Your banner went straight into the loop.' : 'Posted. Your banner is number ' + r.banner.position + ' in line.', 'ok');
|
VBB.status(r.banner.state === 'loop' ? 'Posted. Your banner went straight into the loop.' : 'Posted. Your banner is number ' + r.banner.position + ' in line.', 'ok');
|
||||||
load();
|
load();
|
||||||
};
|
};
|
||||||
|
// LinkSpin Banner Spin (2026-11-14, the Downline Banners pattern): pick one of your 125x125 (or 250x250) spins and it posts
|
||||||
|
$('lsBtn').onclick = async () => {
|
||||||
|
const pick = $('lsPick'); pick.hidden = false; pick.innerHTML = '<p class="small muted">Looking up your LinkSpin Banner Spins...</p>';
|
||||||
|
const d = await VBB.getJSON('/api/my/lsspins');
|
||||||
|
if (d.error) { pick.innerHTML = '<p class="note err small">' + esc(d.error) + '</p>'; return; }
|
||||||
|
const make = '<a href="https://linkspin.app/links#b" target="_blank" rel="noopener">make one on LinkSpin</a>';
|
||||||
|
if (!d.account) { pick.innerHTML = '<p class="small">No LinkSpin account holds this wallet yet. Join LinkSpin (free) with the same email as InstantAdPay, link this wallet there, then ' + make + ' (size 125x125).</p>'; return; }
|
||||||
|
if (!d.spins.length) { pick.innerHTML = '<p class="small">You have no 125x125 Banner Spin yet: ' + make + ' (pick size 125x125), then tap the button again.</p>'; return; }
|
||||||
|
pick.innerHTML = '<p class="small muted">Tap a Banner Spin to post it to the loop (one credit).</p><div class="row"></div>';
|
||||||
|
const row = pick.querySelector('.row');
|
||||||
|
for (const sp of d.spins) {
|
||||||
|
const bt = document.createElement('button'); bt.className = 'btn sec small'; bt.dataset.spin = sp.id;
|
||||||
|
bt.textContent = sp.name + ' (' + sp.size + ', ' + sp.banners + ' image' + (sp.banners === 1 ? '' : 's') + (sp.paused ? ', paused' : '') + ')';
|
||||||
|
bt.disabled = !sp.banners || sp.paused; if (bt.disabled) bt.title = sp.paused ? 'Unpause it on LinkSpin first.' : 'Add an image to it on LinkSpin first.';
|
||||||
|
bt.onclick = async () => {
|
||||||
|
row.querySelectorAll('button').forEach(x => { x.disabled = true; }); VBB.status('Posting your Banner Spin...');
|
||||||
|
const r = await VBB.post('/api/my/banners', { spinId: sp.id });
|
||||||
|
if (r.error) { VBB.status(r.error, 'err'); row.querySelectorAll('button').forEach(x => { x.disabled = false; }); return; }
|
||||||
|
pick.hidden = true; pick.innerHTML = '';
|
||||||
|
VBB.status((r.banner.state === 'loop' ? 'Posted. Your Banner Spin went straight into the loop.' : 'Posted. Your Banner Spin is number ' + r.banner.position + ' in line.')
|
||||||
|
+ (r.otherSource ? ' It already reports under another LinkSpin source, so its clicks stay there.' : ''), 'ok');
|
||||||
|
load();
|
||||||
|
};
|
||||||
|
row.appendChild(bt);
|
||||||
|
}
|
||||||
|
};
|
||||||
$('copyBtn').onclick = () => { $('share').select(); try { navigator.clipboard.writeText($('share').value); } catch (e) { document.execCommand('copy'); } VBB.status('Link copied.', 'ok'); };
|
$('copyBtn').onclick = () => { $('share').select(); try { navigator.clipboard.writeText($('share').value); } catch (e) { document.execCommand('copy'); } VBB.status('Link copied.', 'ok'); };
|
||||||
|
|
||||||
const where = b => b.state === 'queued' ? '<span class="pill queued">Waiting</span><br>Number ' + b.position + ' of ' + b.of + ' in line'
|
const when = t => new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT';
|
||||||
|
const where = b => b.state === 'down' ? '<span class="pill down">Taken down</span><br>Reason: ' + esc(b.downReason) + '<br><span class="muted">'
|
||||||
|
+ (b.creditBack ? 'Your post credit was given back.' : 'The post credit was not given back.') + ' It no longer shows anywhere.</span>'
|
||||||
|
: b.state === 'queued' ? '<span class="pill queued">Waiting</span><br>Number ' + b.position + ' of ' + b.of + ' in line'
|
||||||
: b.state === 'loop' ? '<span class="pill loop">In the loop</span><br>Place ' + b.place + ' of ' + b.of + ', rides out in about ' + b.shiftsToRideOut + ' shift' + (b.shiftsToRideOut === 1 ? '' : 's')
|
: b.state === 'loop' ? '<span class="pill loop">In the loop</span><br>Place ' + b.place + ' of ' + b.of + ', rides out in about ' + b.shiftsToRideOut + ' shift' + (b.shiftsToRideOut === 1 ? '' : 's')
|
||||||
: '<span class="pill cycled">Cycled</span><br>' + (b.cycledAt ? new Date(b.cycledAt).toLocaleString() : '');
|
: '<span class="pill cycled">Cycled</span><br>' + (b.cycledAt ? new Date(b.cycledAt).toLocaleString() : '');
|
||||||
// banner look (SKU 3): buy it for a banner that is waiting or in the loop; with the look, edit its hover teaser
|
// banner look (SKU 3): buy it for a banner that is waiting or in the loop; with the look, edit its hover teaser
|
||||||
let buying = false, editing = false;
|
let buying = false, editing = false, swapping = false;
|
||||||
|
// one swap per banner (Marty 2026-11-15): new image and/or link, or another of your Banner Spins. Same checks as a new post.
|
||||||
|
function swapRow(row, b) {
|
||||||
|
if (b.swapUsed) { row.innerHTML = '<span class="muted small">Swap used' + (b.swappedAt ? ' on ' + esc(when(b.swappedAt)) : '') + '. Each banner can be swapped once.</span>'; return; }
|
||||||
|
if (!b.canSwap) return;
|
||||||
|
row.innerHTML = '<button class="btn sec small">Swap image or link</button>';
|
||||||
|
row.querySelector('button').onclick = () => openSwap(row, b);
|
||||||
|
}
|
||||||
|
function openSwap(row, b) {
|
||||||
|
swapping = true; let up = ''; const item = row.closest('.item'); if (item) item.classList.add('swapping');
|
||||||
|
row.innerHTML = '<div class="swap-box"><p class="small"><b>Swap banner #' + b.id + '</b> (one time only). It keeps its place, clicks and progress. Leave a field empty to keep what it has'
|
||||||
|
+ (b.spin ? '; a Banner Spin swaps to another Banner Spin, or to your own image and link together' : '') + '.</p>'
|
||||||
|
+ '<div class="field"><label>New image address (https), or upload a file</label><input class="sw-img" placeholder="https://your-site.com/banner.png" autocomplete="off"></div>'
|
||||||
|
+ '<div class="row"><label class="btn sec small">Upload image<input type="file" class="sw-file" accept="image/png,image/jpeg,image/gif" hidden></label><span class="muted small sw-note"></span></div>'
|
||||||
|
+ '<div class="field"><label>New target link (https)</label><input class="sw-link" placeholder="https://your-site.com/page" autocomplete="off"></div>'
|
||||||
|
+ '<div class="row"><button class="btn small sw-go">Swap now</button><button class="btn sec small sw-spin">Use another Banner Spin</button><button class="btn quiet small sw-x">Cancel</button></div><div class="sw-pick"></div></div>';
|
||||||
|
const q = k => row.querySelector(k);
|
||||||
|
q('.sw-img').addEventListener('input', () => { up = ''; q('.sw-note').textContent = ''; });
|
||||||
|
q('.sw-file').addEventListener('change', async e => {
|
||||||
|
const f = e.target.files[0]; if (!f) return;
|
||||||
|
if (f.size > 100 * 1024) { VBB.status('That file is ' + Math.ceil(f.size / 1024) + ' KB. The limit is 100 KB.', 'err'); return; }
|
||||||
|
q('.sw-note').textContent = 'Uploading...';
|
||||||
|
const r = await VBB.getJSON('/api/my/upload', { method: 'POST', headers: { 'Content-Type': 'application/octet-stream' }, body: f });
|
||||||
|
e.target.value = '';
|
||||||
|
if (r.error) { q('.sw-note').textContent = ''; VBB.status(r.error, 'err'); return; }
|
||||||
|
up = r.img; q('.sw-img').value = ''; q('.sw-note').textContent = 'Uploaded: ' + f.name; VBB.status('');
|
||||||
|
});
|
||||||
|
const send = async body => {
|
||||||
|
row.querySelectorAll('button').forEach(x => { x.disabled = true; }); VBB.status('Checking the new image and link...');
|
||||||
|
const r = await VBB.post('/api/my/banners/' + b.id + '/swap', body);
|
||||||
|
if (r.error) { VBB.status(r.error, 'err'); row.querySelectorAll('button').forEach(x => { x.disabled = false; }); return; }
|
||||||
|
swapping = false; VBB.status('Swapped. Banner #' + b.id + ' keeps its place and now shows the new ' + (body.spinId != null ? 'Banner Spin' : 'image and link') + '.', 'ok'); load();
|
||||||
|
};
|
||||||
|
q('.sw-go').onclick = () => {
|
||||||
|
const img = up || q('.sw-img').value.trim(), link = q('.sw-link').value.trim();
|
||||||
|
if (!img && !link) return VBB.status('Add a new image, a new link, or both.', 'err');
|
||||||
|
send({ img, link });
|
||||||
|
};
|
||||||
|
q('.sw-x').onclick = () => { swapping = false; if (item) item.classList.remove('swapping'); swapRow(row, b); };
|
||||||
|
q('.sw-spin').onclick = async () => {
|
||||||
|
const pick = q('.sw-pick'); pick.innerHTML = '<p class="small muted">Looking up your LinkSpin Banner Spins...</p>';
|
||||||
|
const d = await VBB.getJSON('/api/my/lsspins');
|
||||||
|
if (d.error) { pick.innerHTML = '<p class="note err small">' + esc(d.error) + '</p>'; return; }
|
||||||
|
const list = (d.spins || []).filter(sp => sp.banners && !sp.paused);
|
||||||
|
if (!d.account || !list.length) { pick.innerHTML = '<p class="small">No 125x125 (or 250x250) Banner Spin with images on your LinkSpin account yet.</p>'; return; }
|
||||||
|
pick.innerHTML = '<p class="small muted">Tap a Banner Spin to swap to it.</p><div class="row"></div>';
|
||||||
|
for (const sp of list) {
|
||||||
|
const bt = document.createElement('button'); bt.className = 'btn sec small'; bt.textContent = sp.name + ' (' + sp.size + ')';
|
||||||
|
bt.onclick = () => send({ spinId: sp.id }); pick.querySelector('.row').appendChild(bt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
function lookRow(row, b) {
|
function lookRow(row, b) {
|
||||||
if (b.look) {
|
if (b.look) {
|
||||||
row.innerHTML = '<span class="pill look">Banner look</span><input maxlength="40" aria-label="Hover teaser for banner #' + b.id + '"><button class="btn sec small">Save teaser</button>';
|
row.innerHTML = '<span class="pill look">Banner look</span><input maxlength="40" aria-label="Hover teaser for banner #' + b.id + '"><button class="btn sec small">Save teaser</button>';
|
||||||
@@ -71,24 +152,26 @@
|
|||||||
}
|
}
|
||||||
const shopLive = !!(c.shop && c.shop.live);
|
const shopLive = !!(c.shop && c.shop.live);
|
||||||
async function load() {
|
async function load() {
|
||||||
if (buying || editing) return;
|
if (buying || editing || swapping) return;
|
||||||
const d = await VBB.getJSON('/api/my');
|
const d = await VBB.getJSON('/api/my');
|
||||||
if (d.error) return VBB.status(d.error, 'err');
|
if (d.error) return VBB.status(d.error, 'err');
|
||||||
$('dash').hidden = false;
|
$('dash').hidden = false;
|
||||||
$('me').textContent = d.username ? '@' + d.username + ' (' + VBB.short(d.address) + ')' : d.address;
|
$('me').textContent = d.username ? '@' + d.username + ' (' + VBB.short(d.address) + ')' : d.address;
|
||||||
const live = d.banners.filter(b => b.state !== 'cycled').length, cyc = d.banners.filter(b => b.state === 'cycled').length;
|
const live = d.banners.filter(b => b.state === 'queued' || b.state === 'loop').length, cyc = d.banners.filter(b => b.state === 'cycled').length;
|
||||||
$('stats').innerHTML = [['Post credits', d.credits], ['Banners waiting or in the loop', live], ['Banners cycled', cyc], ['Network ad views earned', VBB.n(d.rewardViews)]]
|
$('stats').innerHTML = [['Post credits', d.credits], ['Banners waiting or in the loop', live], ['Banners cycled', cyc], ['Network ad views earned', VBB.n(d.rewardViews)]]
|
||||||
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
||||||
$('creditNote').textContent = !d.netVerified ? 'Free daily credits are for network members. Sign in through InstantAdPay or LinkSpin, or make a free InstantAdPay account with this wallet, and your free credit arrives each day you sign in. You can have up to ' + d.maxQueued + ' banners waiting at once.' : (d.grantedNow ? 'Your free credit for today was just added. ' : d.freeToday ? 'Today\'s free credit is in. ' : '')
|
$('creditNote').textContent = !d.netVerified ? 'Free daily credits are for network members. Sign in through InstantAdPay or LinkSpin, or make a free InstantAdPay account with this wallet, and your free credit arrives each day you sign in. You can have up to ' + d.maxQueued + ' banners waiting at once.' : (d.grantedNow ? ((d.freePerDay || 1) > 1 ? 'Your free credits for today were just added. ' : 'Your free credit for today was just added. ') : d.freeToday ? 'Today\'s free credit is in. ' : '')
|
||||||
+ 'One free credit arrives each day you sign in (they bank up to ' + d.freeCreditCap + '). You can have up to ' + d.maxQueued + ' banners waiting at once.';
|
+ ((d.freePerDay || 1) > 1 ? 'Network Weekend: ' + d.freePerDay + ' free credits arrive each day you sign in, through Monday 11-30 Central (they bank up to ' : 'One free credit arrives each day you sign in (they bank up to ') + d.freeCreditCap + '). You can have up to ' + d.maxQueued + ' banners waiting at once.';
|
||||||
$('postBtn').disabled = d.credits < 1;
|
$('postBtn').disabled = d.credits < 1; $('lsBtn').disabled = d.credits < 1;
|
||||||
if (d.credits < 1) $('creditNote').textContent += (shopLive ? ' Out of credits: get a pack on the Packages page, or come back tomorrow for a free one.' : '');
|
if (d.credits < 1) $('creditNote').textContent += (shopLive ? ' Out of credits: get a pack on the Packages page, or come back tomorrow for a free one.' : '');
|
||||||
$('mine').innerHTML = d.banners.length ? '' : '<p class="muted">No banners yet. Post your first one above.</p>';
|
$('mine').innerHTML = d.banners.length ? '' : '<p class="muted">No banners yet. Post your first one above.</p>';
|
||||||
for (const b of d.banners) {
|
for (const b of d.banners) {
|
||||||
const el = document.createElement('div'); el.className = 'item';
|
const el = document.createElement('div'); el.className = 'item';
|
||||||
el.innerHTML = '<img alt="Banner #' + b.id + '" width="72" height="72"><div class="s">' + where(b) + '<br><a target="_blank" rel="noopener"></a><br><span class="muted">' + VBB.n(b.clicks) + ' clicks</span><div class="look-row"></div></div>';
|
el.innerHTML = '<img alt="Banner #' + b.id + '" width="72" height="72"><div class="s">' + where(b) + '<br><a target="_blank" rel="noopener"></a><br><span class="muted">' + VBB.n(b.clicks) + ' clicks</span><div class="look-row"></div><div class="swap-row"></div></div>';
|
||||||
el.querySelector('img').src = b.img; const a = el.querySelector('a'); a.href = b.link; a.textContent = b.link.replace(/^https:\/\//, '').slice(0, 60);
|
el.querySelector('img').src = b.img; const a = el.querySelector('a'); a.href = b.link; a.textContent = b.link.replace(/^https:\/\//, '').slice(0, 60);
|
||||||
lookRow(el.querySelector('.look-row'), b);
|
if (b.spin) { a.removeAttribute('href'); a.textContent = 'LinkSpin Banner Spin: ' + b.spin.name; a.insertAdjacentHTML('beforebegin', '<span class="pill spin">Banner Spin</span> '); }
|
||||||
|
if (b.state === 'down') { el.classList.add('down'); a.removeAttribute('href'); }
|
||||||
|
else { lookRow(el.querySelector('.look-row'), b); swapRow(el.querySelector('.swap-row'), b); }
|
||||||
$('mine').appendChild(el);
|
$('mine').appendChild(el);
|
||||||
}
|
}
|
||||||
$('share').value = d.share;
|
$('share').value = d.share;
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// "Network Weekend" ribbon (Marty 2026-11-17): a thin bar at the top of every network site page while a network event is live.
|
||||||
|
// Data: /api/network-deals (netdeals.js, from the hub). Switches on and off by this page's own clock at the event's exact
|
||||||
|
// startsAt / endsAt (US Central midnights), so a cached feed never shows it early or late, and it takes itself down at endsAt on
|
||||||
|
// a page left open. Shows this site's own deal for today (byDay, Central date) and links to the full deals page.
|
||||||
|
// The same file lives in every network site. Never RM Circle, never the games. No inline styles (CSP): styles go through CSSOM.
|
||||||
|
// Test clock: window.__NW_NOW (ms) before this script runs; nothing else.
|
||||||
|
(function () {
|
||||||
|
if (window.__nwRibbon) return; window.__nwRibbon = 1;
|
||||||
|
var tag = document.currentScript;
|
||||||
|
var meAttr = (tag && tag.getAttribute('data-site')) || '';
|
||||||
|
function now() { return typeof window.__NW_NOW === 'number' ? window.__NW_NOW : Date.now(); }
|
||||||
|
// late November is CST (UTC-6) for every date this ribbon covers
|
||||||
|
function ctDay(ms) { return new Date(ms - 6 * 3600 * 1000).toISOString().slice(0, 10); }
|
||||||
|
function closedKey(id, day) { return 'nw.closed.' + id + '.' + day; }
|
||||||
|
function isClosed(id, day) { try { return window.localStorage.getItem(closedKey(id, day)) === '1'; } catch (e) { return false; } }
|
||||||
|
function setClosed(id, day) { try { window.localStorage.setItem(closedKey(id, day), '1'); } catch (e) {} }
|
||||||
|
var bar = null;
|
||||||
|
function remove() { if (bar && bar.parentNode) bar.parentNode.removeChild(bar); bar = null; }
|
||||||
|
function paint(body) {
|
||||||
|
var me = meAttr || (body && body.self) || '';
|
||||||
|
var t = now();
|
||||||
|
var ev = ((body && body.events) || []).filter(function (e) { return t >= Date.parse(e.startsAt) && t < Date.parse(e.endsAt); })[0];
|
||||||
|
if (!ev) { remove(); return false; }
|
||||||
|
var day = ctDay(t);
|
||||||
|
if (isClosed(ev.id, day)) { remove(); return true; }
|
||||||
|
var mine = (ev.deals || []).filter(function (d) { return d.site === me && t < Date.parse(d.endsAt || ev.endsAt); })[0];
|
||||||
|
var line = mine ? ((mine.byDay && mine.byDay[day]) || mine.text) : '';
|
||||||
|
var label = (ev.days && ev.days[day]) || '';
|
||||||
|
var onDealsPage = ev.url && (location.origin + location.pathname) === ev.url;
|
||||||
|
remove();
|
||||||
|
bar = document.createElement('div');
|
||||||
|
bar.className = 'nw-ribbon'; bar.setAttribute('role', 'region'); bar.setAttribute('aria-label', ev.name);
|
||||||
|
bar.style.cssText = 'position:relative;z-index:50;display:flex;flex-wrap:wrap;gap:4px 12px;align-items:center;justify-content:center;padding:8px 40px 8px 16px;'
|
||||||
|
+ 'background:#14161b;color:#f4f1e8;font:600 13.5px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;text-align:center;border-bottom:2px solid #f2c94c';
|
||||||
|
// built node by node with CSSOM styles: no style attributes, so a strict CSP (style-src 'self') has nothing to block
|
||||||
|
function el(tagName, css, text) { var n = document.createElement(tagName); if (css) n.style.cssText = css; if (text) n.textContent = text; return n; }
|
||||||
|
var head = el('span'); head.appendChild(el('b', 'color:#f2c94c', ev.name)); if (label) head.appendChild(document.createTextNode(' · ' + label));
|
||||||
|
bar.appendChild(head);
|
||||||
|
var body2 = el('span', 'font-weight:500', line || ev.tagline);
|
||||||
|
if (line && mine && mine.note) { body2.appendChild(document.createTextNode(' ')); body2.appendChild(el('span', 'opacity:.75', mine.note)); }
|
||||||
|
bar.appendChild(body2);
|
||||||
|
if (ev.url && !onDealsPage) { var a = el('a', 'color:#f2c94c;text-decoration:underline', 'See every deal'); a.href = ev.url; a.target = '_blank'; a.rel = 'noopener'; bar.appendChild(a); }
|
||||||
|
var x = el('button', 'position:absolute;right:8px;top:50%;transform:translateY(-50%);background:none;border:0;color:#f4f1e8;font-size:18px;line-height:1;cursor:pointer;padding:4px 8px', '×');
|
||||||
|
x.type = 'button'; x.setAttribute('aria-label', 'Hide for today'); bar.appendChild(x);
|
||||||
|
bar.querySelector('button').addEventListener('click', function () { setClosed(ev.id, day); remove(); });
|
||||||
|
document.body.insertBefore(bar, document.body.firstChild);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var feed = null, timer = null;
|
||||||
|
function schedule() {
|
||||||
|
clearTimeout(timer); if (!feed) return;
|
||||||
|
// wake at the next switch moment (start, end, a deal ending, the next Central midnight), at least once a minute
|
||||||
|
var t = now(), next = t + 60 * 1000;
|
||||||
|
(feed.events || []).forEach(function (e) {
|
||||||
|
[e.startsAt, e.endsAt].concat((e.deals || []).map(function (d) { return d.endsAt; })).forEach(function (s) { var x = Date.parse(s); if (x > t && x < next) next = x; });
|
||||||
|
});
|
||||||
|
timer = setTimeout(function () { if (typeof window.__NW_NOW === 'number') window.__NW_NOW += next - t; paint(feed); schedule(); }, Math.max(250, next - t));
|
||||||
|
}
|
||||||
|
function run() {
|
||||||
|
fetch('/api/network-deals', { credentials: 'omit' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (b) {
|
||||||
|
if (!b || !Array.isArray(b.events) || !b.events.length) return;
|
||||||
|
feed = b; paint(b); schedule();
|
||||||
|
}).catch(function () {});
|
||||||
|
}
|
||||||
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
|
||||||
|
window.__nwPaint = function (b) { feed = b; return paint(b); }; // tests
|
||||||
|
})();
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
const c = await VBB.getConfig().catch(() => ({}));
|
const c = await VBB.getConfig().catch(() => ({}));
|
||||||
const money = v => '$' + (Number.isInteger(v) ? v : Number(v).toFixed(2));
|
const money = v => '$' + (Number.isInteger(v) ? v : Number(v).toFixed(2));
|
||||||
if (c.lookUsd) $('pkLook').textContent = money(c.lookUsd) + ' per banner';
|
if (c.lookUsd) $('pkLook').textContent = money(c.lookUsd) + ' per banner';
|
||||||
|
// Network Weekend (2026-11-17): the free daily credits as the server grants them today
|
||||||
|
if (c.freeCreditsPerDay > 1 && $('pkFree')) $('pkFree').textContent = 'Network Weekend: every network member (InstantAdPay or LinkSpin) gets ' + c.freeCreditsPerDay + ' free post credits each day they sign in, through Monday 11-30, midnight Central.';
|
||||||
const packs = (c.packs || []).slice(0, 2);
|
const packs = (c.packs || []).slice(0, 2);
|
||||||
packs.forEach((p, i) => { const el = $('pkPack' + i); if (!el) return;
|
packs.forEach((p, i) => { const el = $('pkPack' + i); if (!el) return;
|
||||||
el.querySelector('[data-pk=credits]').textContent = VBB.n(p.credits); el.querySelector('[data-pk=usd]').textContent = money(p.usd); });
|
el.querySelector('[data-pk=credits]').textContent = VBB.n(p.credits); el.querySelector('[data-pk=usd]').textContent = money(p.usd); });
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
const t = d.today || {};
|
const t = d.today || {};
|
||||||
$('today').textContent = VBB.n(t.shifts) + ' shifts and ' + VBB.n(t.cycles) + ' cycles today';
|
$('today').textContent = VBB.n(t.shifts) + ' shifts and ' + VBB.n(t.cycles) + ' cycles today';
|
||||||
// the loop
|
// the loop
|
||||||
const ids = d.loop.map(x => x.id + (x.look ? '*' + x.teaser : '')).join(','); // a new banner look repaints too
|
const fill = d.fill || { loop: [], queue: [] };
|
||||||
|
const ids = d.loop.map(x => x.id + (x.look ? '*' + x.teaser : '')).join(',') + '|' + fill.loop.map(x => x.img).join(','); // a new banner look or fill repaints too
|
||||||
if (ids !== lastLoop) {
|
if (ids !== lastLoop) {
|
||||||
lastLoop = ids; const g = $('loop'); g.innerHTML = '';
|
lastLoop = ids; const g = $('loop'); g.innerHTML = '';
|
||||||
const full = d.loop.length >= d.loopSize;
|
const full = d.loop.length >= d.loopSize;
|
||||||
@@ -24,16 +25,21 @@
|
|||||||
const el = VBB.tile(t, { pos: last ? 'NEXT OUT' : String(i + 1), cls: (last ? 'next' : '') + (!firstPaint && !known.has(t.id) ? ' fresh' : '') });
|
const el = VBB.tile(t, { pos: last ? 'NEXT OUT' : String(i + 1), cls: (last ? 'next' : '') + (!firstPaint && !known.has(t.id) ? ' fresh' : '') });
|
||||||
g.appendChild(el); known.add(t.id);
|
g.appendChild(el); known.add(t.id);
|
||||||
});
|
});
|
||||||
for (let i = d.loop.length; i < d.loopSize; i++) {
|
// open places: the first stays "post yours", the next ones show members' LinkSpin Banner Spins (never part of the loop)
|
||||||
|
for (let i = d.loop.length, k = 0; i < d.loopSize; i++) {
|
||||||
|
const sp = i > d.loop.length ? fill.loop[k] : null;
|
||||||
|
if (sp) { k++; g.appendChild(VBB.tile(sp, { pos: 'SPIN' })); continue; }
|
||||||
const a = document.createElement('a'); a.className = 'tile open'; a.href = '/my';
|
const a = document.createElement('a'); a.className = 'tile open'; a.href = '/my';
|
||||||
a.innerHTML = '<b>+</b>Open place<br>post yours'; g.appendChild(a);
|
a.innerHTML = '<b>+</b>Open place<br>post yours'; g.appendChild(a);
|
||||||
}
|
}
|
||||||
firstPaint = false;
|
firstPaint = false;
|
||||||
}
|
}
|
||||||
$('loopInfo').textContent = d.loop.length + ' of ' + d.loopSize + ' places filled';
|
$('loopInfo').textContent = d.loop.length + ' of ' + d.loopSize + ' places filled';
|
||||||
|
$('fillNote').hidden = !(fill.loop.length || (!d.waiting && fill.queue.length));
|
||||||
// the queue
|
// the queue
|
||||||
const q = $('queue'); q.innerHTML = '';
|
const q = $('queue'); q.innerHTML = '';
|
||||||
d.queue.forEach((t, i) => q.appendChild(VBB.tile(t, { pos: '#' + (i + 1) })));
|
d.queue.forEach((t, i) => q.appendChild(VBB.tile(t, { pos: '#' + (i + 1) })));
|
||||||
|
if (!d.waiting) fill.queue.forEach(t => q.appendChild(VBB.tile(t, { pos: 'SPIN' })));
|
||||||
$('queueEmpty').hidden = d.waiting > 0;
|
$('queueEmpty').hidden = d.waiting > 0;
|
||||||
$('queueInfo').textContent = d.waiting ? VBB.n(d.waiting) + ' waiting' + (d.waiting > d.queue.length ? ', first ' + d.queue.length + ' shown' : '') : '';
|
$('queueInfo').textContent = d.waiting ? VBB.n(d.waiting) + ' waiting' + (d.waiting > d.queue.length ? ', first ' + d.queue.length + ' shown' : '') : '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
// How it works + Packages: nav, footer, and the live config numbers.
|
// How it works, Packages and the Guides pages (2026-11-17): nav, footer, and the live config numbers.
|
||||||
(async function () {
|
(async function () {
|
||||||
const page = location.pathname.replace(/\/$/, '') || '/';
|
const page = location.pathname.replace(/\/$/, '') || '/';
|
||||||
VBB.renderNav(page); VBB.renderFooter();
|
VBB.renderNav(page.indexOf('/guides') === 0 ? '/guides' : page); VBB.renderFooter();
|
||||||
const c = await VBB.getConfig().catch(() => ({}));
|
const c = await VBB.getConfig().catch(() => ({}));
|
||||||
const set = (k, v) => document.querySelectorAll('[data-k=' + k + ']').forEach(el => { el.textContent = v; });
|
const set = (k, v) => document.querySelectorAll('[data-k=' + k + ']').forEach(el => { el.textContent = v; });
|
||||||
if (c.perShift) set('perShift', c.perShift);
|
if (c.perShift) set('perShift', c.perShift);
|
||||||
if (c.viewsPerCycle != null) set('views', VBB.n(c.viewsPerCycle));
|
if (c.viewsPerCycle != null) set('views', VBB.n(c.viewsPerCycle));
|
||||||
if (c.visitSeconds) set('secs', c.visitSeconds);
|
if (c.visitSeconds) set('secs', c.visitSeconds);
|
||||||
|
// Guides (2026-11-17): free credits a day (Network Weekend aware, from the server), the free-credit bank, waiting banners, the look, the packs
|
||||||
|
if (c.freeCreditsPerDay) set('freeDay', c.freeCreditsPerDay === 1 ? 'one free post credit' : c.freeCreditsPerDay + ' free post credits');
|
||||||
|
if (c.freeCreditCap) set('freeCap', c.freeCreditCap);
|
||||||
|
if (c.maxQueued) set('maxQueued', c.maxQueued);
|
||||||
// package prices from config (the Packages page has its own script, packages.js, with the Buy buttons)
|
// package prices from config (the Packages page has its own script, packages.js, with the Buy buttons)
|
||||||
const money = v => '$' + (Number.isInteger(v) ? v : Number(v).toFixed(2));
|
const money = v => '$' + (Number.isInteger(v) ? v : Number(v).toFixed(2));
|
||||||
const pp = document.getElementById('pkPacks');
|
const pp = document.getElementById('pkPacks');
|
||||||
if (pp && c.packs && c.packs.length) pp.innerHTML = c.packs.map(p => '<li>' + VBB.n(p.credits) + ' post credits for ' + money(p.usd) + '</li>').join('');
|
if (pp && c.packs && c.packs.length) pp.innerHTML = c.packs.map(p => '<li>' + VBB.n(p.credits) + ' post credits for ' + money(p.usd) + '</li>').join('');
|
||||||
|
if (c.lookUsd) set('lookUsd', money(c.lookUsd));
|
||||||
|
if (c.packs && c.packs.length) set('packsText', c.packs.map(p => VBB.n(p.credits) + ' post credits for ' + money(p.usd)).join(' or '));
|
||||||
const lk = document.getElementById('pkLook'); if (lk && c.lookUsd) lk.textContent = money(c.lookUsd) + ' per banner';
|
const lk = document.getElementById('pkLook'); if (lk && c.lookUsd) lk.textContent = money(c.lookUsd) + ' per banner';
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ nav.top .links{display:flex;gap:6px;flex-wrap:wrap}
|
|||||||
nav.top .links a{color:var(--ink);text-decoration:none;font-weight:700;font-size:14px;padding:6px 11px;border-radius:999px;border:2px solid transparent}
|
nav.top .links a{color:var(--ink);text-decoration:none;font-weight:700;font-size:14px;padding:6px 11px;border-radius:999px;border:2px solid transparent}
|
||||||
nav.top .links a:hover{border-color:var(--ink);background:var(--bg2)}
|
nav.top .links a:hover{border-color:var(--ink);background:var(--bg2)}
|
||||||
nav.top .links a.on{color:#fff;background:var(--ink);border-color:var(--ink)}
|
nav.top .links a.on{color:#fff;background:var(--ink);border-color:var(--ink)}
|
||||||
@media (max-width:720px){nav.top .links{width:100%;overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none;margin:0 -4px 2px}nav.top .links::-webkit-scrollbar{display:none}nav.top .links a{flex:none}}
|
@media (max-width:720px){nav.top .links{width:100%;flex-wrap:wrap;justify-content:center;gap:4px;margin:0 0 4px}nav.top .links a{flex:none;font-size:13px;padding:6px 9px}} /* 2026-11-15: wrap on phones, the hidden side-scroll hid half the menu */
|
||||||
/* hero */
|
/* hero */
|
||||||
.hero{padding:34px 0 8px}
|
.hero{padding:34px 0 8px}
|
||||||
.hero .eyebrow{display:inline-flex;align-items:center;gap:8px;font:700 12px/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink);
|
.hero .eyebrow{display:inline-flex;align-items:center;gap:8px;font:700 12px/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink);
|
||||||
@@ -172,3 +172,45 @@ footer.foot a{color:var(--amber)} footer.foot p{margin:6px 0}
|
|||||||
.mine .item .look-row input{flex:1;min-width:120px;background:var(--panel);border:2px solid var(--ink);border-radius:8px;padding:6px 8px;font:13px var(--body)}
|
.mine .item .look-row input{flex:1;min-width:120px;background:var(--panel);border:2px solid var(--ink);border-radius:8px;padding:6px 8px;font:13px var(--body)}
|
||||||
.pill.look{background:var(--hot);color:#fff}
|
.pill.look{background:var(--hot);color:#fff}
|
||||||
.past{display:grid;gap:12px}.past .wk{background:var(--bg2);border:var(--edge);border-radius:14px;padding:12px 14px}
|
.past{display:grid;gap:12px}.past .wk{background:var(--bg2);border:var(--edge);border-radius:14px;padding:12px 14px}
|
||||||
|
/* LinkSpin Banner Spins (2026-11-14): fill tiles in open places / the empty waiting line, never loop banners */
|
||||||
|
.tile.fill{border-style:dashed;box-shadow:none;opacity:.92}
|
||||||
|
.tile.fill .pos{background:var(--sky-soft);color:var(--ink)}
|
||||||
|
.fill-note{margin-top:6px}
|
||||||
|
.ls-box{margin-top:16px;padding-top:12px;border-top:1.5px dashed var(--muted)}
|
||||||
|
.pill.spin{background:var(--sky-soft);color:var(--ink)}
|
||||||
|
/* trust pack (2026-11-14): footer legal + network line, proof toasts, legal pages */
|
||||||
|
footer.foot .legal-links{margin-top:14px} footer.foot .co{opacity:.8;font-size:12.5px}
|
||||||
|
footer.foot .netline{margin-top:12px;padding-top:12px;border-top:1px dashed rgba(217,212,234,.3);font-size:13px;line-height:1.9}
|
||||||
|
footer.foot .netline b{color:#fff} footer.foot .netline .here{color:#fff;font-weight:700;background:var(--hot);border:1.5px solid #fff;border-radius:999px;padding:1px 8px}
|
||||||
|
.toast.buy{background:var(--amber-soft)} .toast.prize{background:var(--ok-soft)}
|
||||||
|
.legal .card h2{font-size:21px} .legal .card p,.legal .card li{max-width:760px} .legal .card ul{padding-left:20px} .legal .card li{margin:6px 0}
|
||||||
|
#facts th{font:700 11.5px var(--mono);letter-spacing:.06em;text-transform:uppercase;vertical-align:top}
|
||||||
|
/* one-time swap + admin takedown (2026-11-15) */
|
||||||
|
.pill.down{background:#14121f;color:#fff}
|
||||||
|
.mine .item.down{opacity:.7}.mine .item.down img{filter:grayscale(1)}
|
||||||
|
.mine .item .swap-row{margin-top:6px}
|
||||||
|
.swap-box{background:var(--panel);border:2px solid var(--ink);border-radius:10px;padding:10px;margin-top:4px}
|
||||||
|
.swap-box .field input{width:100%}
|
||||||
|
.swap-box .row{flex-wrap:wrap;gap:6px}
|
||||||
|
.adm-b{display:flex;gap:12px;align-items:flex-start;border:var(--edge);border-radius:12px;padding:10px;margin:10px 0;background:var(--bg2);flex-wrap:wrap}
|
||||||
|
.adm-b img{width:72px;height:72px;border:2px solid var(--ink);border-radius:8px;object-fit:cover;flex:none}
|
||||||
|
.adm-b .s{flex:1;min-width:220px;font-size:13.5px;word-break:break-all}
|
||||||
|
.adm-b textarea{width:100%;min-height:54px;font:14px var(--body);border:var(--edge);border-radius:8px;padding:8px}
|
||||||
|
.mine .item.swapping{flex-wrap:wrap;align-items:flex-start}.mine .item.swapping .s{flex:1 1 100%}
|
||||||
|
/* Guides (2026-11-17): the /guides index cards, the guide-to-guide links and the FAQ list */
|
||||||
|
.guides{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:14px;margin:12px 0}
|
||||||
|
.guides a.card{display:block;margin:0;color:var(--ink);text-decoration:none}
|
||||||
|
.guides a.card:hover{transform:translate(-2px,-2px)}
|
||||||
|
.guides a.card b{display:block;font:800 19px/1.15 var(--disp);margin-bottom:6px}
|
||||||
|
.guide-next{display:flex;gap:8px;flex-wrap:wrap;margin:6px 0 0}
|
||||||
|
.faq details{border-bottom:1.5px solid var(--line);padding:12px 0}
|
||||||
|
.faq details:last-child{border-bottom:0}
|
||||||
|
.faq summary{cursor:pointer;font-weight:700;font-size:16px}
|
||||||
|
.faq details p{margin:8px 0 0;max-width:760px}
|
||||||
|
.addr{word-break:break-all}
|
||||||
|
|
||||||
|
/* tutorial video (2026-11-18): home watch link + the player on the how-it-works guide */
|
||||||
|
.watchlink{display:inline-flex;align-items:center;gap:8px;margin-top:14px;font-weight:700;color:var(--ink);text-decoration:underline;text-underline-offset:3px}
|
||||||
|
.watchlink svg{color:var(--hot);flex:none}
|
||||||
|
.howvid video{display:block;width:100%;height:auto;aspect-ratio:16/9;border:var(--edge);border-radius:12px;background:#14121f;margin-top:8px}
|
||||||
|
.howvid p{margin:10px 0 0}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Contract Proof | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="The Viral Banner Blitz shop contract on Polygon: verified source, owner, prize wallet and the fixed 30/10/60 split, read live from the chain.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/contract">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Contract Proof | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="The Viral Banner Blitz shop contract on Polygon: verified source, owner, prize wallet and the fixed 30/10/60 split, read live from the chain.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/contract">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Contract Proof | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="The Viral Banner Blitz shop contract on Polygon: verified source, owner, prize wallet and the fixed 30/10/60 split, read live from the chain.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><span class="eyebrow"><i></i>Read live from Polygon</span><h1>Contract <em>proof</em></h1><p class="lead">Every Viral Banner Blitz purchase is paid to one smart contract on Polygon. It splits the payment in the same transaction. Check every number here yourself.</p></section>
|
||||||
|
<div class="card">
|
||||||
|
<h2>The contract</h2>
|
||||||
|
<table class="t" id="facts"><tbody><tr><td class="muted">Reading the contract...</td></tr></tbody></table>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Where each purchase goes, in the same transaction</h2>
|
||||||
|
<div class="stats">
|
||||||
|
<div class="stat"><b>30%</b><span>to the network member who introduced the buyer (no sponsor: to Viral Banner Blitz)</span></div>
|
||||||
|
<div class="stat"><b>10%</b><span>to the prize wallet, which pays the weekly leaderboard prizes</span></div>
|
||||||
|
<div class="stat"><b>60%</b><span>to Viral Banner Blitz</span></div>
|
||||||
|
</div>
|
||||||
|
<p class="muted small">The percentages are constants in the contract code: nobody can change who gets what share. There is no owner withdraw. The contract keeps nothing: if a payment cannot be delivered, it waits in the contract for that wallet to claim, and nobody else can take it. Anything sent above the price comes back in the same transaction.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Check it yourself</h2>
|
||||||
|
<ol class="small">
|
||||||
|
<li>Open the contract on Polygonscan (link above). <span id="psnote">Its source code is verified on Sourcify (exact match).</span></li>
|
||||||
|
<li>On Polygonscan, choose <b>Read Contract</b> and compare owner, prize wallet, company and keeper with this page.</li>
|
||||||
|
<li>Open any purchase in the <a href="/ledger">live ledger</a> and look at its <b>Logs</b>: one Purchase event, then one Paid event per payment.</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/contract.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Earnings Disclaimer | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="Viral Banner Blitz sells advertising, not income. No earnings are promised; any payment happens only on-chain when later purchases happen.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/disclaimer">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Earnings Disclaimer | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="Viral Banner Blitz sells advertising, not income. No earnings are promised; any payment happens only on-chain when later purchases happen.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/disclaimer">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Earnings Disclaimer | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="Viral Banner Blitz sells advertising, not income. No earnings are promised; any payment happens only on-chain when later purchases happen.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap legal">
|
||||||
|
<section class="hero"><h1>Earnings Disclaimer</h1><p class="lead">Please read this before you buy anything.</p><p class="muted small">Last updated November 14, 2026</p></section>
|
||||||
|
<div class="card"><h2>Advertising, not an investment</h2><p>Viral Banner Blitz sells advertising. It is not an investment, a security, a savings plan or an income opportunity, and nothing you buy here is a promise of money back.</p></div>
|
||||||
|
<div class="card"><h2>No earnings promised</h2><p>The sponsor share is paid only when someone you introduced chooses to buy a package. If nobody does, you receive nothing from it.</p><p>Weekly prizes go only to the top three on each leaderboard. Your rank depends on what every other member does that week, and most members will not win a prize in a given week. A prize is a promotion, not a return on anything you bought.</p><p>Network ad views earned when a banner cycles are advertising, not cash, and have no cash value.</p><p>We do not promise, project or guarantee any earnings. Any numbers in examples, posts, banners or videos are illustrations or one member's results, not what you should expect.</p></div>
|
||||||
|
<div class="card"><h2>How any payment happens</h2><p>Any payment to you happens only on the blockchain, when a later purchase happens, and is paid by the smart contract in that same transaction. Nothing is held for you and there is nothing to withdraw. If no later purchase happens, no payment happens.</p></div>
|
||||||
|
<div class="card"><h2>Crypto risk</h2><ul><li>The price of POL moves. The dollar value of a payment can be higher or lower later than when it was paid.</li><li>You are responsible for your wallet and its recovery phrase. Nobody, including us, can recover a lost wallet or reverse a payment sent from it.</li><li>Blockchain transactions are final. Each one costs a small network fee (gas) in POL, paid to the network, not to us.</li><li>Use SafePal or any other crypto wallet you trust, and never share your recovery phrase with anyone. We will never ask for it.</li></ul></div>
|
||||||
|
<div class="card"><h2>Your decision</h2><p>Only spend what you can afford to lose completely. This is not financial, legal or tax advice. You are responsible for any taxes on what you receive.</p></div>
|
||||||
|
<div class="card"><h2>Contact</h2><p>Questions, problems or a request about your data: <a href="https://instantadpay.com/support" target="_blank" rel="noopener">network support</a> (TrustClickz).</p></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=1"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>FAQ | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="Viral Banner Blitz FAQ: free post credits, posting and swapping banners, verified visitors, packages, the 30/10/60 split, prizes, refunds and support.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/guides/faq">
|
||||||
|
<meta property="og:type" content="article">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="FAQ | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="Viral Banner Blitz FAQ: free post credits, posting and swapping banners, verified visitors, packages, the 30/10/60 split, prizes, refunds and support.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/guides/faq">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="FAQ | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="Viral Banner Blitz FAQ: free post credits, posting and swapping banners, verified visitors, packages, the 30/10/60 split, prizes, refunds and support.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><div class="eyebrow"><i></i>Guides</div><h1>Viral Banner Blitz FAQ</h1><p class="lead">Short answers. The chat button on every page answers the same way.</p></section>
|
||||||
|
<div class="card faq">
|
||||||
|
<details><summary>What is Viral Banner Blitz?</summary><p>One public banner loop the whole community moves. Post a 125x125 banner; it waits in line, then enters the loop. Every <span data-k="perShift">10</span> verified visitors shift every banner one place forward, and the banner at the end rides out: it has cycled, and its owner earns <span data-k="views">150</span> network ad views. See <a href="/how">how the loop works</a>.</p></details>
|
||||||
|
<details><summary>Is posting free?</summary><p>Network members (anyone with an InstantAdPay or LinkSpin account) get <span data-k="freeDay">one free post credit</span> each day they sign in, Central time. Each credit posts one banner. Want to post more? Credit packs are one-time purchases: <span data-k="packsText">10 post credits for $3 or 40 post credits for $10</span>. More in <a href="/guides/free-account">getting the most from your free account</a>.</p></details>
|
||||||
|
<details><summary>How do I post a banner, and what size?</summary><p>On <a href="/my">My Banners</a> upload a 125x125 image (100 KB or less) with your link, or post one of your LinkSpin Banner Spins (125x125 or 250x250). It uses one post credit, waits in line, and enters the loop at the front at the next shift. Your link must be a real page that loads.</p></details>
|
||||||
|
<details><summary>Can I change or remove my banner?</summary><p>Each banner can be swapped one time: a new image, a new link, or both, from My Banners. It keeps its place, its clicks and its progress through the loop. After that one swap the button is gone. Members cannot withdraw or remove a posted banner, and post credits are not refunded. A banner that breaks the rules can be taken down by the admin, and its owner sees the reason on My Banners.</p></details>
|
||||||
|
<details><summary>What do I get when my banner cycles?</summary><p><span data-k="views">150</span> network ad views, advertising for your own offers across the network. Right now each cycle is recorded on your My Banners page; adding those views to your network advertising is the next step and is not switched on yet. It is advertising, not cash.</p></details>
|
||||||
|
<details><summary>What counts as a verified visitor?</summary><p>A real browser that keeps the loop page open and visible for about <span data-k="secs">6</span> seconds. Each visitor counts once every 24 hours. Bots, crawlers, repeat visits and more than a few visitors per internet connection a day do not count.</p></details>
|
||||||
|
<details><summary>How much are the packages? Is it a subscription?</summary><p>Post credit packs: <span data-k="packsText">10 post credits for $3 or 40 post credits for $10</span>. The banner look is <span data-k="lookUsd">$2</span> per banner: a bright border in the loop plus a teaser line. All one-time purchases in POL at the live price, never a subscription. Anything above the price comes back in the same transaction. See <a href="/packages">packages</a>.</p></details>
|
||||||
|
<details><summary>Where does my payment go?</summary><p>Each purchase is split on Polygon in the same transaction: 30% to the network member who introduced the buyer (to Viral Banner Blitz if nobody did), 10% to the weekly prize pot, 60% to Viral Banner Blitz. The introducer is set once, on the buyer's first purchase, and never changes. See <a href="/guides/is-it-legit">is Viral Banner Blitz legit?</a></p></details>
|
||||||
|
<details><summary>How do I withdraw?</summary><p>There is nothing to withdraw. The introducer's 30% goes straight to their wallet inside the buyer's transaction (a payment that fails to send waits in the contract for that wallet to claim). Leaderboard prizes are paid in POL to the winners' wallets. Every payment is in the <a href="/ledger">ledger</a>.</p></details>
|
||||||
|
<details><summary>How do I sign in, and which wallet do I use?</summary><p>Sign in on <a href="/my">My Banners</a> through InstantAdPay, LinkSpin or a wallet signature (free, it cannot move funds). Packages are paid in POL on Polygon with SafePal or any other crypto wallet; keep a little extra POL for the network fee.</p></details>
|
||||||
|
<details><summary>Can I get a refund?</summary><p>Purchases are paid on Polygon and are final once confirmed, so they cannot be reversed or refunded. Every package is a one-time purchase that never renews, so there is nothing to cancel. If something went wrong with a payment, open network support with the transaction link.</p></details>
|
||||||
|
<details><summary>How do the leaderboards and prizes work?</summary><p>Two weekly leaderboards, Monday to Sunday Central time: most verified visitors sent on your link, and most different websites they came from. The top three on each share the prize pot (10% of the week's sales, 50/30/20 percent), paid in POL to the wallet of their Viral Banner Blitz account the following Monday. Ties go to whoever got there first. See <a href="/guides/prize-boards">how the weekly prize boards work</a>.</p></details>
|
||||||
|
<details><summary>What are the SPIN tiles in the loop?</summary><p>Members' LinkSpin Banner Spins showing in empty places of the loop. They are not in the loop: they never shift it, never cycle and never earn. Post a banner and yours takes a real place.</p></details>
|
||||||
|
<details><summary>Is this a pyramid scheme?</summary><p>Posting is free for network members every day, and packages buy more banner posts and a better-looking banner. The VBBShop contract splits each purchase with fixed shares and has no owner withdraw. You buy advertising for your own banners, not an income opportunity.</p></details>
|
||||||
|
<details><summary>Do I need a new account? Where is my old account?</summary><p>Viral Banner Blitz is part of the network: one account, username and sponsor across InstantAdPay, LinkSpin and the other network sites. Sign in here through InstantAdPay or LinkSpin. The site was rebuilt as one shared banner loop: old members were matched to the network by email, and old balances and credits were not carried over.</p></details>
|
||||||
|
<details><summary>Is there a promo kit?</summary><p>Yes. The <a href="/promote">promo kit</a> has creatives in the common sizes and copy, all with your link.</p></details>
|
||||||
|
<details><summary>How do I reach a person?</summary><p>Open network support at <a href="https://instantadpay.com/support" target="_blank" rel="noopener">instantadpay.com/support</a>, say it is about Viral Banner Blitz, and include your wallet address (and the transaction link if it is about a purchase).</p></details>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>More guides</h2>
|
||||||
|
<div class="guide-next"><a class="btn small" href="/guides">All guides</a><a class="btn quiet small" href="/how">How the loop works</a><a class="btn quiet small" href="/guides/is-it-legit">Is Viral Banner Blitz legit?</a><a class="btn quiet small" href="/guides/free-account">Getting the most from your free account</a><a class="btn quiet small" href="/guides/prize-boards">How the weekly prize boards work</a></div>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Getting the most from your free account | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="How to get the most from a free Viral Banner Blitz account: the free daily post credit, what network-verified means, and how to make each banner count.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/guides/free-account">
|
||||||
|
<meta property="og:type" content="article">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Getting the most from your free account | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="How to get the most from a free Viral Banner Blitz account: the free daily post credit, what network-verified means, and how to make each banner count.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/guides/free-account">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Getting the most from your free account | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="How to get the most from a free Viral Banner Blitz account: the free daily post credit, what network-verified means, and how to make each banner count.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><div class="eyebrow"><i></i>Guides</div><h1>Getting the most from your free account</h1><p class="lead">You can post a banner every day without buying anything. Here is how to make each one count.</p></section>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Your free daily post credit</h2>
|
||||||
|
<p>Network members get <span data-k="freeDay">one free post credit</span> each day they sign in, by the Central time day. Each credit posts one banner into the loop. Credits you do not use stay on your account, up to <span data-k="freeCap">7</span>, and you can have up to <span data-k="maxQueued">3</span> banners waiting at once.</p>
|
||||||
|
<p>So the simple habit is: sign in on <a href="/my">My Banners</a> every day, even on days you do not post.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>What network-verified means</h2>
|
||||||
|
<p>Free credits go to network members only. That stops people farming credits with throwaway wallets. You are verified when the network knows you: you signed in here through InstantAdPay or LinkSpin, or the wallet you signed in with belongs to a network member.</p>
|
||||||
|
<p>Signed in with a wallet the network does not know yet? It is checked again on each visit, so once you join InstantAdPay or LinkSpin the free credits start. One account, one username and one sponsor carry across every network site. On InstantAdPay, ad credits buy advertising, not income.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Make each banner count</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Use a clear 125x125 image (100 KB or less) that reads at a glance, or post one of your LinkSpin Banner Spins (125x125 or 250x250).</li>
|
||||||
|
<li>Point it at a real page that loads. Links that do not answer are refused.</li>
|
||||||
|
<li>Each banner gets one swap of its image, link or both, and it keeps its place. Save it for a real fix.</li>
|
||||||
|
<li>The banner look (a bright border plus a teaser line) is an optional one-time add-on, <span data-k="lookUsd">$2</span> per banner, paid with SafePal or any other crypto wallet. You never need it to post.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Share your link</h2>
|
||||||
|
<p>Your link ends in <span class="mono">?ref=</span> and your network username (copy it from My Banners, or grab ready-made creatives from the <a href="/promote">promo kit</a>). Every <span data-k="perShift">10</span> verified visitors move every banner in the loop forward one place, yours included, and your visitors count on the <a href="/guides/prize-boards">weekly prize boards</a>.</p>
|
||||||
|
<p>If someone you introduced buys a package, 30% of it goes to your wallet in the same transaction. That only happens when they choose to buy.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>What a cycle earns</h2>
|
||||||
|
<p>When your banner rides out of the loop you earn <span data-k="views">150</span> network ad views, advertising for your own offers across the network. Right now each cycle is recorded on your My Banners page. Adding those views to your network advertising is the next step and is not switched on yet.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>More guides</h2>
|
||||||
|
<div class="guide-next"><a class="btn small" href="/guides">All guides</a><a class="btn quiet small" href="/how">How the loop works</a><a class="btn quiet small" href="/guides/is-it-legit">Is Viral Banner Blitz legit?</a><a class="btn quiet small" href="/guides/prize-boards">How the weekly prize boards work</a><a class="btn quiet small" href="/guides/faq">FAQ</a></div>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Is Viral Banner Blitz legit? | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="Is Viral Banner Blitz legit? The VBBShop contract on Polygon, the public ledger, and the fixed 30/10/60 split of every purchase, all checkable.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/guides/is-it-legit">
|
||||||
|
<meta property="og:type" content="article">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Is Viral Banner Blitz legit? | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="Is Viral Banner Blitz legit? The VBBShop contract on Polygon, the public ledger, and the fixed 30/10/60 split of every purchase, all checkable.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/guides/is-it-legit">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Is Viral Banner Blitz legit? | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="Is Viral Banner Blitz legit? The VBBShop contract on Polygon, the public ledger, and the fixed 30/10/60 split of every purchase, all checkable.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><div class="eyebrow"><i></i>Guides</div><h1>Is Viral Banner Blitz legit?</h1><p class="lead">You should not have to take our word for it. Here is what to check, and where.</p></section>
|
||||||
|
<div class="card">
|
||||||
|
<h2>The short answer</h2>
|
||||||
|
<p>Posting is free for network members every day. Packages buy more banner posts and a better-looking banner. Every purchase is paid to one smart contract on Polygon, VBBShop, and it splits the payment in the same transaction. You can check every part of that yourself.</p>
|
||||||
|
<p>Viral Banner Blitz is advertising for your own banners. It is not an income opportunity, and nothing here promises income.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>The contract</h2>
|
||||||
|
<p>VBBShop on Polygon: <a class="mono addr" href="https://polygonscan.com/address/0x36F6ccc8752DcE1c84e06b65f07dF30e8a4707D7#code" target="_blank" rel="noopener">0x36F6ccc8752DcE1c84e06b65f07dF30e8a4707D7</a></p>
|
||||||
|
<p>Its source code is verified on Polygonscan (the Contract tab) and on <a href="https://repo.sourcify.dev/137/0x36F6ccc8752DcE1c84e06b65f07dF30e8a4707D7" target="_blank" rel="noopener">Sourcify</a> (exact match). The <a href="/contract">contract page</a> reads the owner, company, prize wallet and keeper live from Polygon.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Where every purchase goes</h2>
|
||||||
|
<table class="t">
|
||||||
|
<tr><th>Share</th><th>Goes to</th></tr>
|
||||||
|
<tr><td class="n">30%</td><td>the network member who introduced the buyer (if nobody did, Viral Banner Blitz)</td></tr>
|
||||||
|
<tr><td class="n">10%</td><td>the prize wallet, which pays the weekly leaderboard prizes</td></tr>
|
||||||
|
<tr><td class="n">60%</td><td>Viral Banner Blitz</td></tr>
|
||||||
|
</table>
|
||||||
|
<p>For every $10 spent, that is $3 to the introducer, $1 to the prize wallet and $6 to Viral Banner Blitz. The 30% and 10% are constants written into the contract code, so nobody can change who gets what share. The company gets the rest, including any rounding dust.</p>
|
||||||
|
<p>The introducer is set once, on the buyer's first purchase, through a voucher the site signs, and it never changes after that.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>What the contract cannot do, and what the owner can</h2>
|
||||||
|
<p>There is no owner withdraw, no proxy and no self-destruct. The contract keeps nothing: if a payment cannot be delivered, it waits in the contract for that wallet to claim, and nobody else can take it. Anything sent above the price comes back in the same transaction.</p>
|
||||||
|
<p>The owner wallet can set package prices and credits, change the prize wallet and the keeper key, and pause new purchases. It cannot change the shares, the company wallet, or anyone's introducer. Each of those actions is a public transaction on Polygon.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>The public ledger</h2>
|
||||||
|
<p>The <a href="/ledger">ledger</a> lists every purchase and every payment it made, each with its Polygon transaction, plus every weekly prize payout. Nothing is shown there that you cannot open on Polygonscan.</p>
|
||||||
|
<div class="row"><a class="btn small" href="/ledger">Open the ledger</a><a class="btn quiet small" href="/contract">Contract proof</a></div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Check it yourself in three steps</h2>
|
||||||
|
<ol>
|
||||||
|
<li>Open the contract on Polygonscan and read the source on the Contract tab.</li>
|
||||||
|
<li>Choose Read Contract and compare owner, company, prize wallet and keeper with the <a href="/contract">contract page</a>.</li>
|
||||||
|
<li>Open any purchase in the <a href="/ledger">ledger</a> and look at its Logs: one Purchase event, then one Paid event per payment.</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>What is not promised</h2>
|
||||||
|
<p>A banner that cycles earns network ad views, which is advertising, not cash. The 30% only reaches a member when someone they introduced buys a package. Purchases are paid on Polygon and are final, and packages never renew. The <a href="/disclaimer">earnings disclaimer</a> has the rest.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>More guides</h2>
|
||||||
|
<div class="guide-next"><a class="btn small" href="/guides">All guides</a><a class="btn quiet small" href="/how">How the loop works</a><a class="btn quiet small" href="/guides/free-account">Getting the most from your free account</a><a class="btn quiet small" href="/guides/prize-boards">How the weekly prize boards work</a><a class="btn quiet small" href="/guides/faq">FAQ</a></div>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>How the weekly prize boards work | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="How the Viral Banner Blitz weekly prize boards work: most verified visitors, most traffic sources, a pot from 10% of sales, paid in POL to the top three.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/guides/prize-boards">
|
||||||
|
<meta property="og:type" content="article">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="How the weekly prize boards work | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="How the Viral Banner Blitz weekly prize boards work: most verified visitors, most traffic sources, a pot from 10% of sales, paid in POL to the top three.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/guides/prize-boards">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="How the weekly prize boards work | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="How the Viral Banner Blitz weekly prize boards work: most verified visitors, most traffic sources, a pot from 10% of sales, paid in POL to the top three.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><div class="eyebrow"><i></i>Guides</div><h1>How the weekly prize boards work</h1><p class="lead">Two leaderboards, a fresh start every Monday, and every payout on Polygon.</p></section>
|
||||||
|
<div class="card">
|
||||||
|
<h2>The two boards</h2>
|
||||||
|
<p>Each week runs Monday 12:00 AM to Sunday night, Central time. Your link (ending in <span class="mono">?ref=</span> and your network username) is what counts.</p>
|
||||||
|
<ul>
|
||||||
|
<li><b>Most visitors sent:</b> the verified visitors who came in on your link that week.</li>
|
||||||
|
<li><b>Most traffic sources:</b> how many different websites those visitors came from, so spreading your link widely counts.</li>
|
||||||
|
</ul>
|
||||||
|
<p>Only verified visitors count: a real browser that keeps the loop page open and visible for about <span data-k="secs">6</span> seconds, once per visitor every 24 hours. Bots, crawlers, repeat visits and more than a few visitors per internet connection a day do not count. <a href="/how">How the loop works</a> has the details.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Where the prize pot comes from</h2>
|
||||||
|
<p>10% of every package purchase goes to the prize wallet in the same transaction, by the contract. A week's pot is 10% of that week's sales. Half the pot goes to each board, and the top three on each board share it 50%, 30% and 20%.</p>
|
||||||
|
<p>The <a href="/leaders">leaderboard page</a> shows this week's pot and each place's prize, live.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>How winners are paid</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Prizes are set in dollars and paid in POL at the POL price at payout time, to the wallet of the winner's Viral Banner Blitz account, the following Monday.</li>
|
||||||
|
<li>Ties go to whoever reached the count first.</li>
|
||||||
|
<li>A winner who cannot be paid is skipped and everyone below moves up a place. A place nobody fills stays in the prize wallet for later weeks.</li>
|
||||||
|
<li>Every payout is a public Polygon transaction. Past winners and their transactions are on the <a href="/leaders">leaderboard page</a> and in the <a href="/ledger">ledger</a>.</li>
|
||||||
|
</ul>
|
||||||
|
<div class="row"><a class="btn small" href="/leaders">See this week's leaders</a><a class="btn quiet small" href="/my">Get my link</a></div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Play it fair</h2>
|
||||||
|
<p>The boards reward real visitors. Share your link where people actually look: your own sites, social posts, traffic exchanges and the <a href="/promote">promo kit</a> creatives. A prize is a reward for sending traffic, not a promise of income.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>More guides</h2>
|
||||||
|
<div class="guide-next"><a class="btn small" href="/guides">All guides</a><a class="btn quiet small" href="/how">How the loop works</a><a class="btn quiet small" href="/guides/is-it-legit">Is Viral Banner Blitz legit?</a><a class="btn quiet small" href="/guides/free-account">Getting the most from your free account</a><a class="btn quiet small" href="/guides/faq">FAQ</a></div>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Guides | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="Plain guides to Viral Banner Blitz: how the loop works, whether it is legit, the free account, the weekly prize boards and the FAQ.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/guides">
|
||||||
|
<meta property="og:type" content="article">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Guides | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="Plain guides to Viral Banner Blitz: how the loop works, whether it is legit, the free account, the weekly prize boards and the FAQ.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/guides">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Guides | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="Plain guides to Viral Banner Blitz: how the loop works, whether it is legit, the free account, the weekly prize boards and the FAQ.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><div class="eyebrow"><i></i>Guides</div><h1>Viral Banner Blitz guides</h1><p class="lead">Plain answers about the loop, where the money goes, and how to get the most from a free account.</p></section>
|
||||||
|
<div class="guides">
|
||||||
|
<a class="card" href="/how"><b>How the loop works</b><span class="muted">Post a banner, verified visitors move the loop, and a banner that rides out earns network ad views.</span></a>
|
||||||
|
<a class="card" href="/guides/is-it-legit"><b>Is Viral Banner Blitz legit?</b><span class="muted">The contract, the public ledger and exactly where every purchase goes.</span></a>
|
||||||
|
<a class="card" href="/guides/free-account"><b>Getting the most from your free account</b><span class="muted">Your free daily post credit, what network-verified means, and how to make each banner count.</span></a>
|
||||||
|
<a class="card" href="/guides/prize-boards"><b>How the weekly prize boards work</b><span class="muted">The two leaderboards, how the prize pot is made and how winners are paid.</span></a>
|
||||||
|
<a class="card" href="/guides/faq"><b>FAQ</b><span class="muted">Short answers to the questions people ask most.</span></a>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Still have a question?</h2>
|
||||||
|
<p>Tap the chat button on any page, or open network support at <a href="https://instantadpay.com/support" target="_blank" rel="noopener">instantadpay.com/support</a> and say it is about Viral Banner Blitz.</p>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -22,11 +22,12 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="wrap">
|
<main class="wrap">
|
||||||
<section class="hero"><h1>How the loop works</h1><p class="lead">One public page, one shared loop. The whole community moves it with real visitors.</p></section>
|
<section class="hero"><h1>How the loop works</h1><p class="lead">One public page, one shared loop. The whole community moves it with real visitors.</p></section>
|
||||||
|
<div class="card howvid" id="watch"><h2 id="watchTitle">Watch how it works</h2><video controls playsinline preload="none" poster="/art/how-it-works.jpg?v=20261118a" width="1920" height="1080" aria-describedby="watchNote"><source src="/art/how-it-works.mp4?v=20261118a" type="video/mp4"></video><p class="muted small" id="watchNote">A short walkthrough in Marty's voice: your free daily credit, posting a banner, how visitors move the loop, your link and the weekly leaderboards, packages, and where to start.</p></div>
|
||||||
<ol class="how">
|
<ol class="how">
|
||||||
<li><b>Sign in, get a credit</b>Sign in through InstantAdPay, LinkSpin or a wallet. Network members (InstantAdPay or LinkSpin) get one free post credit every day they sign in.</li>
|
<li><b>Sign in, get a credit</b>Sign in through InstantAdPay, LinkSpin or a wallet. Network members (InstantAdPay or LinkSpin) get one free post credit every day they sign in.</li>
|
||||||
<li><b>Post a banner</b>A 125x125 image and a link. It waits in line, then enters the loop at the front.</li>
|
<li><b>Post a banner</b>A 125x125 image and a link. It waits in line, then enters the loop at the front.</li>
|
||||||
@@ -53,9 +54,16 @@
|
|||||||
<p>Want to post more than once a day? Post credit packs and the banner look (a bright border plus a teaser line) are one-time purchases in POL with SafePal or any other crypto wallet. Never a subscription.</p>
|
<p>Want to post more than once a day? Post credit packs and the banner look (a bright border plus a teaser line) are one-time purchases in POL with SafePal or any other crypto wallet. Never a subscription.</p>
|
||||||
<div class="row"><a class="btn small" href="/packages">See the packages</a></div>
|
<div class="row"><a class="btn small" href="/packages">See the packages</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>More guides</h2>
|
||||||
|
<p>Where the money goes, the free account, the weekly prize boards and the FAQ.</p>
|
||||||
|
<div class="row"><a class="btn small" href="/guides">All guides</a><a class="btn quiet small" href="/guides/is-it-legit">Is it legit?</a><a class="btn quiet small" href="/guides/faq">FAQ</a></div>
|
||||||
|
</div>
|
||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/static.js?v=1"></script>
|
<script src="/assets/static.js?v=2"></script>
|
||||||
|
<script src="https://polhunter.com/embed.js" data-slots="4" data-selector="main.wrap > .card" async></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="wrap">
|
<main class="wrap">
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
<h1>Every visitor pushes the loop. <em>Ride it out, earn advertising.</em></h1>
|
<h1>Every visitor pushes the loop. <em>Ride it out, earn advertising.</em></h1>
|
||||||
<p class="lead">This page is the loop: member banners in 125x125 tiles. Every <b data-k="perShift">10</b> verified visitors shift it one place, and the banner at the end rides out. That banner has cycled, and its owner earns <b data-k="views">150</b> network ad views.</p>
|
<p class="lead">This page is the loop: member banners in 125x125 tiles. Every <b data-k="perShift">10</b> verified visitors shift it one place, and the banner at the end rides out. That banner has cycled, and its owner earns <b data-k="views">150</b> network ad views.</p>
|
||||||
<div class="row"><a class="btn" href="/my">Post your banner</a><a class="btn sec" href="/how">How it works</a></div>
|
<div class="row"><a class="btn" href="/my">Post your banner</a><a class="btn sec" href="/how">How it works</a></div>
|
||||||
|
<a class="watchlink" href="/how#watch"><svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><circle cx="12" cy="12" r="11" fill="currentColor"/><path d="M10 8l6 4-6 4z" fill="#fff"/></svg>Watch the 2-minute walkthrough</a>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="meter" aria-label="Next shift">
|
<section class="meter" aria-label="Next shift">
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
<div class="loop-head"><h2>Waiting to enter</h2><span class="side" id="queueInfo"></span></div>
|
<div class="loop-head"><h2>Waiting to enter</h2><span class="side" id="queueInfo"></span></div>
|
||||||
<div class="queue" id="queue"></div>
|
<div class="queue" id="queue"></div>
|
||||||
<p class="muted small" id="queueEmpty" hidden>Nobody is waiting. A banner posted now enters the loop at the next shift.</p>
|
<p class="muted small" id="queueEmpty" hidden>Nobody is waiting. A banner posted now enters the loop at the next shift.</p>
|
||||||
|
<p class="muted small fill-note" id="fillNote" hidden>Tiles marked SPIN are members' LinkSpin Banner Spins showing in empty space. They are not in the loop: they never shift it, never cycle and never earn. <a href="/my">Post a banner</a> and yours takes a real place.</p>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h3>Send visitors, move up the leaderboard</h3>
|
<h3>Send visitors, move up the leaderboard</h3>
|
||||||
@@ -55,7 +57,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/splash.js?v=2"></script>
|
<script src="/assets/splash.js?v=3"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="wrap">
|
<main class="wrap">
|
||||||
@@ -33,7 +33,8 @@
|
|||||||
<div class="card" id="pastCard" hidden><h2>Past winners</h2><p class="muted small">Paid in POL from the prize wallet at the POL price at payout time. Every payment is a public Polygon transaction.</p><div class="past" id="past"></div></div>
|
<div class="card" id="pastCard" hidden><h2>Past winners</h2><p class="muted small">Paid in POL from the prize wallet at the POL price at payout time. Every payment is a public Polygon transaction.</p><div class="past" id="past"></div></div>
|
||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/leaders.js?v=3"></script>
|
<script src="/assets/leaders.js?v=3"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Live Ledger | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="Every Viral Banner Blitz purchase and weekly prize payout on Polygon, with the split paid in the same transaction and a link to verify each one.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/ledger">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Live Ledger | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="Every Viral Banner Blitz purchase and weekly prize payout on Polygon, with the split paid in the same transaction and a link to verify each one.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/ledger">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Live Ledger | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="Every Viral Banner Blitz purchase and weekly prize payout on Polygon, with the split paid in the same transaction and a link to verify each one.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap">
|
||||||
|
<section class="hero"><span class="eyebrow"><i></i>Live from Polygon</span><h1>The live <em>ledger</em></h1><p class="lead">Every purchase and every weekly prize payout, with the transaction to check it. Purchases are split by the contract in the same transaction they are paid.</p></section>
|
||||||
|
<div class="stats" id="totals"></div>
|
||||||
|
<div class="card">
|
||||||
|
<h2>Purchases and prize payouts</h2>
|
||||||
|
<div style="overflow-x:auto"><table class="t" id="rows"><thead><tr><th>When</th><th>What happened</th><th>Paid in the same transaction</th><th>Verify</th></tr></thead><tbody><tr><td colspan="4" class="muted">Loading...</td></tr></tbody></table></div>
|
||||||
|
<p class="muted small">Purchases buy advertising: post credits and the banner look. They are not an investment and nothing is promised. Prize payouts go from the prize wallet to the weekly leaderboard winners. <a href="/contract">How to check the contract</a>.</p>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="note" hidden></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/ledger.js?v=1"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="wrap">
|
<main class="wrap">
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<div id="dash" hidden>
|
<div id="dash" hidden>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="row" style="justify-content:space-between"><div><span class="muted small">Signed in as</span> <span class="mono" id="me"></span></div><button class="btn quiet small" id="outBtn">Sign out</button></div>
|
<div class="row" style="justify-content:space-between"><div><span class="muted small">Signed in as</span> <span class="mono" id="me"></span></div><span class="row" style="gap:8px"><button class="btn quiet small" id="outBtn">Sign out</button><button class="btn quiet small" id="outAllBtn" title="Ends your network sign-in on every network site">Sign out everywhere</button></span></div>
|
||||||
<div class="stats" id="stats"></div>
|
<div class="stats" id="stats"></div>
|
||||||
<p class="muted small" id="creditNote"></p>
|
<p class="muted small" id="creditNote"></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -58,9 +58,14 @@
|
|||||||
<button class="btn" id="postBtn">Post to the loop</button>
|
<button class="btn" id="postBtn">Post to the loop</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ls-box">
|
||||||
|
<p class="small"><b>Have a LinkSpin Banner Spin?</b> Post it instead: its images rotate in your tile and every click goes through your spin, so it shows in LinkSpin Reports under a Viral Banner Blitz source. 125x125 (or 250x250) spins. One post uses one credit.</p>
|
||||||
|
<button class="btn sec small" id="lsBtn">Use my LinkSpin Banner Spin</button>
|
||||||
|
<div id="lsPick" hidden></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card"><h2>Your banners</h2><p class="muted small">Add the banner look to any banner that is waiting or in the loop: a bright border, plus a teaser line that shows when someone points at it. One-time, per banner.</p><div class="mine" id="mine"></div></div>
|
<div class="card"><h2>Your banners</h2><p class="muted small">Add the banner look to any banner that is waiting or in the loop: a bright border, plus a teaser line that shows when someone points at it. One-time, per banner.</p><p class="muted small">Need to fix a banner? Each banner that is waiting or in the loop can swap its image or link one time. It keeps its place in the loop.</p><div class="mine" id="mine"></div></div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>Your link</h2>
|
<h2>Your link</h2>
|
||||||
@@ -73,9 +78,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/wallet.js?v=2"></script>
|
<script src="/assets/wallet.js?v=2"></script>
|
||||||
<script src="/assets/buy.js?v=1"></script>
|
<script src="/assets/buy.js?v=1"></script>
|
||||||
<script src="/assets/my.js?v=2"></script>
|
<script src="/assets/my.js?v=6"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="wrap">
|
<main class="wrap">
|
||||||
@@ -40,12 +40,13 @@
|
|||||||
<div class="card pk-item"><h3>Tokens</h3><p class="pk-price">Network visits</p><p class="muted small">Each token is a visit to your site from the network, at the InstantAdPay visit rate.</p><span class="tag-soon">Coming soon</span></div>
|
<div class="card pk-item"><h3>Tokens</h3><p class="pk-price">Network visits</p><p class="muted small">Each token is a visit to your site from the network, at the InstantAdPay visit rate.</p><span class="tag-soon">Coming soon</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card"><h3>Where your payment goes</h3><p class="muted small">Each purchase is split on the Polygon blockchain in the same transaction: 30% to the network member who introduced you (to Viral Banner Blitz if nobody did), 10% to the weekly leaderboard prize pot, 60% to Viral Banner Blitz. You buy advertising for your own banners, not an income opportunity.</p></div>
|
<div class="card"><h3>Where your payment goes</h3><p class="muted small">Each purchase is split on the Polygon blockchain in the same transaction: 30% to the network member who introduced you (to Viral Banner Blitz if nobody did), 10% to the weekly leaderboard prize pot, 60% to Viral Banner Blitz. You buy advertising for your own banners, not an income opportunity.</p></div>
|
||||||
<div class="card center"><p>Every network member (InstantAdPay or LinkSpin) also gets one free post credit each day they sign in.</p><a class="btn sec" href="/my">Use my free credit</a></div>
|
<div class="card center"><p id="pkFree">Every network member (InstantAdPay or LinkSpin) also gets one free post credit each day they sign in.</p><a class="btn sec" href="/my">Use my free credit</a></div>
|
||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/wallet.js?v=2"></script>
|
<script src="/assets/wallet.js?v=2"></script>
|
||||||
<script src="/assets/buy.js?v=1"></script>
|
<script src="/assets/buy.js?v=1"></script>
|
||||||
<script src="/assets/packages.js?v=1"></script>
|
<script src="/assets/packages.js?v=2"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Privacy Policy | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="What Viral Banner Blitz collects (wallet, username, visit checks), how the network shares one account through the hub, and what is public on the blockchain.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/privacy">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Privacy Policy | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="What Viral Banner Blitz collects (wallet, username, visit checks), how the network shares one account through the hub, and what is public on the blockchain.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/privacy">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Privacy Policy | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="What Viral Banner Blitz collects (wallet, username, visit checks), how the network shares one account through the hub, and what is public on the blockchain.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap legal">
|
||||||
|
<section class="hero"><h1>Privacy Policy</h1><p class="lead">What we collect, why, and who sees it.</p><p class="muted small">Last updated November 14, 2026</p></section>
|
||||||
|
<div class="card"><h2>Who we are</h2><p>Viral Banner Blitz is run by TrustClickz. This policy says what we collect, why, and who sees it.</p></div>
|
||||||
|
<div class="card"><h2>What we collect</h2><ul><li><b>Your wallet address</b>, which you prove by signing a message (signing costs nothing and moves no money).</li><li><b>Your network username and sponsor</b>, looked up from the network hub. If you sign in through InstantAdPay or LinkSpin, your email is used only to find you on the hub; Viral Banner Blitz does not store it.</li><li><b>Your banners</b>: the image, link and teaser you post, and their place in the loop.</li><li><b>Visit verification</b>: your IP address and browser type, combined into one-way codes, to count each visitor once a day and keep out bots, plus the website a visitor came from (for the traffic-sources leaderboard). Visit records are deleted after 15 days. We do not keep raw IP addresses.</li><li><b>Cookies</b>: a sign-in cookie, and a referral cookie (30 days) that remembers who sent you.</li></ul></div>
|
||||||
|
<div class="card"><h2>One account across the network</h2><p>The Crypto Team Build Network shares one account across its sites through the network hub. The hub keeps your email address, username, wallet and sponsor, and each network site (InstantAdPay, LinkSpin, Downline Banners, Viral Banner Blitz, Stack POL, Earners Corner) asks it who you are, so you have one identity and one sponsor everywhere. Sites only see what they need.</p></div>
|
||||||
|
<div class="card"><h2>What is public</h2><p>Purchases and payments on the blockchain are public and permanent: anyone can see the wallet addresses and amounts, and nobody can delete them. Our live ledger, leaderboards and toasts show your network username or a shortened wallet. When a package is bought or a weekly prize is paid, a message with the username (or a shortened wallet), the amounts and the transaction link is posted to the network's Telegram payments topic.</p></div>
|
||||||
|
<div class="card"><h2>Who else sees it</h2><p>We do not sell your data. We use service providers to run the site (hosting, databases, blockchain connections, and Telegram for the payment messages), and we share data if the law requires it.</p></div>
|
||||||
|
<div class="card"><h2>Your choices</h2><p>You can ask us to delete your account data on this site or on the network hub. Records on the blockchain cannot be deleted by anyone. You can clear the cookies in your browser at any time; you will need to sign in again.</p></div>
|
||||||
|
<div class="card"><h2>Contact</h2><p>Questions, problems or a request about your data: <a href="https://instantadpay.com/support" target="_blank" rel="noopener">network support</a> (TrustClickz).</p></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=1"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<meta name="theme-color" content="#ffd400">
|
<meta name="theme-color" content="#ffd400">
|
||||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/vbb.css?v=4">
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
<link rel="stylesheet" href="/assets/kit.css?v=1">
|
<link rel="stylesheet" href="/assets/kit.css?v=1">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -34,8 +34,9 @@
|
|||||||
<div id="status" class="note" hidden></div>
|
<div id="status" class="note" hidden></div>
|
||||||
<div id="kit"><p class="muted">Loading the kit...</p></div>
|
<div id="kit"><p class="muted">Loading the kit...</p></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="/assets/common.js?v=3"></script>
|
<script src="/assets/common.js?v=11"></script>
|
||||||
<script src="/assets/kitpage.js?v=1"></script>
|
<script src="/assets/kitpage.js?v=2"></script>
|
||||||
<script src="/assets/promote.js?v=1"></script>
|
<script src="/assets/promote.js?v=1"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Terms and Conditions | Viral Banner Blitz</title>
|
||||||
|
<meta name="description" content="The terms for using Viral Banner Blitz: what you buy (advertising), how each payment is split on-chain, no refunds, crypto risk and fair use.">
|
||||||
|
<link rel="canonical" href="https://viralbannerblitz.com/terms">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:site_name" content="Viral Banner Blitz">
|
||||||
|
<meta property="og:title" content="Terms and Conditions | Viral Banner Blitz">
|
||||||
|
<meta property="og:description" content="The terms for using Viral Banner Blitz: what you buy (advertising), how each payment is split on-chain, no refunds, crypto risk and fair use.">
|
||||||
|
<meta property="og:url" content="https://viralbannerblitz.com/terms">
|
||||||
|
<meta property="og:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Viral Banner Blitz: a community banner loop that moves with every verified visitor">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Terms and Conditions | Viral Banner Blitz">
|
||||||
|
<meta name="twitter:description" content="The terms for using Viral Banner Blitz: what you buy (advertising), how each payment is split on-chain, no refunds, crypto risk and fair use.">
|
||||||
|
<meta name="twitter:image" content="https://viralbannerblitz.com/art/og-share.png">
|
||||||
|
|
||||||
|
<meta name="theme-color" content="#ffd400">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@400;500;700&family=Space+Mono:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="/assets/vbb.css?v=9">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="wrap legal">
|
||||||
|
<section class="hero"><h1>Terms and Conditions</h1><p class="lead">The rules for using Viral Banner Blitz, in plain English.</p><p class="muted small">Last updated November 14, 2026</p></section>
|
||||||
|
<div class="card"><h2>Who we are</h2><p>Viral Banner Blitz (viralbannerblitz.com) is run by TrustClickz. It is part of the Crypto Team Build Network: one network account works across InstantAdPay, LinkSpin, Downline Banners, Viral Banner Blitz, Stack POL and Earners Corner. By using Viral Banner Blitz you agree to these terms.</p></div>
|
||||||
|
<div class="card"><h2>What Viral Banner Blitz is</h2><p>Viral Banner Blitz is a community loop of 125x125 banners. Verified visitors move the loop, and a banner that rides out of the loop earns network ad views.</p></div>
|
||||||
|
<div class="card"><h2>What you buy</h2><p>Network members (InstantAdPay or LinkSpin) get one free post credit each day they sign in. You can also buy post credit packs and the banner look (a bright border and a teaser line). Prices are on the Packages page.</p><p>Purchases are paid in POL on Polygon at the live Chainlink POL/USD price the contract reads when you buy. Anything you send above the price comes back to you in the same transaction.</p><p>What you buy is advertising for your own banners. It is not income, an investment or a share of anything.</p><p>Every package is a single, one-time purchase. Nothing renews and nothing is ever billed again. There are no subscriptions.</p></div>
|
||||||
|
<div class="card"><h2>How a payment is split</h2><p>The Viral Banner Blitz shop contract splits each purchase in the same transaction it is paid: 30% to the network member who introduced the buyer (no sponsor: Viral Banner Blitz), 10% to the prize wallet for the weekly leaderboard prizes, and 60% to Viral Banner Blitz.</p><p>The split is fixed in the contract code and there is no owner withdraw. The contract keeps nothing: a sponsor payment goes straight to the sponsor's wallet in the buyer's transaction, and there is nothing to withdraw. If a payment cannot be delivered, it waits in the contract for that wallet to claim, and nobody else can take it.</p><p>The 10% prize share is held in the prize wallet until the weekly prizes are paid. Each week the top three on each leaderboard are paid in POL from the prize wallet the following Monday, after an administrator approves the payout. A place nobody qualifies for is not paid and its share stays in the prize wallet for later weeks.</p><p>Your sponsor is set on your first purchase from the network sponsor the network hub knows for your wallet, through a voucher the site signs. Once set on the contract, it never changes.</p></div>
|
||||||
|
<div class="card"><h2>Nothing is promised</h2><p>We do not promise or guarantee any income, payout, prize or result. Read the <a href="/disclaimer">Earnings Disclaimer</a>.</p></div>
|
||||||
|
<div class="card"><h2>No refunds</h2><p>Payments are made on the blockchain and are final once confirmed. We cannot reverse, cancel or refund them. Check the amount and what you are buying before you confirm in your wallet.</p></div>
|
||||||
|
<div class="card"><h2>Crypto risk</h2><ul><li>The price of POL moves. The dollar value of a payment can be higher or lower later than when it was paid.</li><li>You are responsible for your wallet and its recovery phrase. Nobody, including us, can recover a lost wallet or reverse a payment sent from it.</li><li>Blockchain transactions are final. Each one costs a small network fee (gas) in POL, paid to the network, not to us.</li><li>Use SafePal or any other crypto wallet you trust, and never share your recovery phrase with anyone. We will never ask for it.</li></ul></div>
|
||||||
|
<div class="card"><h2>Fair use</h2><p>A verified visitor is a real browser that keeps the loop page open and visible for a few seconds. Each visitor counts once every 24 hours, only a few visitors per internet connection count each day, and bots, crawlers and repeat visits do not count. We may refuse visits we judge not to be real, and may disqualify anyone who fakes traffic from the leaderboards and prizes.</p><p>Your banner must be your own or one you have the right to use, and its link must lead to a lawful page that can be shown in the loop. No adult content, malware, phishing, deceptive offers, hate, or anything illegal where you or your visitors live. We may remove a banner and close an account that breaks these rules; credits already used are not returned.</p><p>Do not try to break, overload or game the site, and do not use more than one account to get extra free credits, views or prizes.</p></div>
|
||||||
|
<div class="card"><h2>Your account</h2><p>You sign in with your wallet or through InstantAdPay or LinkSpin. Your network account, username and sponsor are shared across the network through the network hub, as described in the <a href="/privacy">Privacy Policy</a>. You must be old enough to make a binding agreement where you live, and using crypto must be legal there.</p></div>
|
||||||
|
<div class="card"><h2>The service</h2><p>The site is provided as it is. We work to keep it running but cannot promise it will always be available or free of errors. The smart contract runs on Polygon on its own; its rules are public and can be checked on the <a href="/contract">contract page</a>. We may change features, prices of future purchases or these terms; changes apply from the date they are posted here.</p></div>
|
||||||
|
<div class="card"><h2>Limits</h2><p>As far as the law allows, we are not responsible for losses caused by the blockchain, your wallet, the price of POL, third-party websites in banners, or events outside our control, and our total responsibility to you is limited to what you paid for the purchase in question. These terms are governed by the laws of the State of Alabama, USA.</p></div>
|
||||||
|
<div class="card"><h2>Contact</h2><p>Questions, problems or a request about your data: <a href="https://instantadpay.com/support" target="_blank" rel="noopener">network support</a> (TrustClickz).</p></div>
|
||||||
|
</main>
|
||||||
|
<script src="/assets/common.js?v=11"></script>
|
||||||
|
<script src="/assets/static.js?v=1"></script>
|
||||||
|
<script src="/assets/chat.js?v=2" defer></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
// prizes: last week's leaderboards (seeded visits) -> prepare -> refuse while the prize wallet is short (says how much) ->
|
// prizes: last week's leaderboards (seeded visits) -> prepare -> refuse while the prize wallet is short (says how much) ->
|
||||||
// fund it -> approve and pay -> exact POL per winner at the feed price, ties to the earlier, the prize wallet itself
|
// fund it -> approve and pay -> exact POL per winner at the feed price, ties to the earlier, the prize wallet itself
|
||||||
// skipped -> a second approval refused -> /api/prizes lists the winners with their transactions.
|
// skipped -> a second approval refused -> /api/prizes lists the winners with their transactions.
|
||||||
|
// trust pack (2026-11-14): /api/ledger (each purchase with its real split from the receipt, prize payouts), /api/contract (live
|
||||||
|
// facts), the pages, and a stand-in Telegram API: one photo card per purchase, one line per prize payout, never twice.
|
||||||
// node qa/chain.mjs (needs anvil: ~/.foundry/bin/anvil(.exe), and forge build output in ../contracts/out)
|
// node qa/chain.mjs (needs anvil: ~/.foundry/bin/anvil(.exe), and forge build output in ../contracts/out)
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
@@ -38,6 +40,11 @@ function ctWeek(ts) { const p = Object.fromEntries(fmt.formatToParts(new Date(ts
|
|||||||
const THIS_WEEK = ctWeek(Date.now()); const LAST_WEEK = new Date(Date.parse(THIS_WEEK + 'T12:00:00Z') - 7 * 86400000).toISOString().slice(0, 10);
|
const THIS_WEEK = ctWeek(Date.now()); const LAST_WEEK = new Date(Date.parse(THIS_WEEK + 'T12:00:00Z') - 7 * 86400000).toISOString().slice(0, 10);
|
||||||
const LW_AT = Date.parse(LAST_WEEK + 'T18:00:00Z'); // Monday noon CT of last week
|
const LW_AT = Date.parse(LAST_WEEK + 'T18:00:00Z'); // Monday noon CT of last week
|
||||||
|
|
||||||
|
// ---- stand-in Telegram Bot API (never the real group): records every call ----
|
||||||
|
const TPORT = PORT + 2; const tgCalls = [];
|
||||||
|
require('node:http').createServer(async (q, r) => { let b = ''; for await (const c of q) b += c; let j = {}; try { j = JSON.parse(b || '{}'); } catch (e) {}
|
||||||
|
tgCalls.push({ method: q.url.split('/').pop(), token: q.url.split('/')[1], body: j }); r.setHeader('Content-Type', 'application/json'); r.end(JSON.stringify({ ok: true, result: { message_id: tgCalls.length } })); }).listen(TPORT, '127.0.0.1').unref();
|
||||||
|
|
||||||
// ---- stand-in hub: M's network sponsor is S ----
|
// ---- stand-in hub: M's network sponsor is S ----
|
||||||
const people = new Map(); // wallet -> { id, username, sponsorWallet }
|
const people = new Map(); // wallet -> { id, username, sponsorWallet }
|
||||||
const HUB_SECRET = 'c'.repeat(40);
|
const HUB_SECRET = 'c'.repeat(40);
|
||||||
@@ -83,7 +90,8 @@ async function main() {
|
|||||||
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '', LINK_PROBE: '0', NETWORK_LOOKUP_URL: '',
|
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '', LINK_PROBE: '0', NETWORK_LOOKUP_URL: '',
|
||||||
CHAIN_ID: '31337', CONTRACT_ADDRESS: SHOP, CHAIN_RPC: RPC, KEEPER_KEY: K[1], SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '300',
|
CHAIN_ID: '31337', CONTRACT_ADDRESS: SHOP, CHAIN_RPC: RPC, KEEPER_KEY: K[1], SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '300',
|
||||||
PRIZE_KEY: P.privateKey, PRIZE_WALLET: P.address, PRIZE_RECEIPT_MS: '300', EXPLORER: 'https://explorer.invalid',
|
PRIZE_KEY: P.privateKey, PRIZE_WALLET: P.address, PRIZE_RECEIPT_MS: '300', EXPLORER: 'https://explorer.invalid',
|
||||||
HUB_URL: 'http://127.0.0.1:' + HPORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_ENABLED: '0' });
|
HUB_URL: 'http://127.0.0.1:' + HPORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_ENABLED: '0',
|
||||||
|
TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TPORT });
|
||||||
const log = fs.openSync(path.join(OUT, 'chain-server.log'), 'w');
|
const log = fs.openSync(path.join(OUT, 'chain-server.log'), 'w');
|
||||||
const srv = spawn(process.execPath, ['server.js'], { cwd: APP, env, stdio: ['ignore', log, log] }); procs.push(srv);
|
const srv = spawn(process.execPath, ['server.js'], { cwd: APP, env, stdio: ['ignore', log, log] }); procs.push(srv);
|
||||||
for (let i = 0; i < 80; i++) { try { if ((await fetch(BASE + '/health')).ok) break; } catch (e) {} await sleep(150); }
|
for (let i = 0; i < 80; i++) { try { if ((await fetch(BASE + '/health')).ok) break; } catch (e) {} await sleep(150); }
|
||||||
@@ -127,6 +135,38 @@ async function main() {
|
|||||||
ok(look, 'the watcher gives that banner the look');
|
ok(look, 'the watcher gives that banner the look');
|
||||||
const spl = await call('/api/splash'); ok([...spl.loop, ...spl.queue].some(t => t.id === bid && t.look && t.teaser === 'example-member.com'), 'the loop shows it with the border + teaser');
|
const spl = await call('/api/splash'); ok([...spl.loop, ...spl.queue].some(t => t.id === bid && t.look && t.teaser === 'example-member.com'), 'the loop shows it with the border + teaser');
|
||||||
|
|
||||||
|
console.log('1b. trust pack: ledger, contract, pages, Telegram cards');
|
||||||
|
const share = w => ({ sp: w * 3000n / 10000n, pz: w * 1000n / 10000n, co: w - w * 3000n / 10000n - w * 1000n / 10000n });
|
||||||
|
let led; for (let i = 0; i < 40; i++) { led = await call('/api/ledger?n=50'); const x = (led.items || []).find(y => y.tx === tx.hash.toLowerCase()); if (x && x.pays && x.pays.length === 3 && x.pays[0].role === 'sponsor') break; await sleep(200); }
|
||||||
|
const it1 = (led.items || []).find(x => x.tx === tx.hash.toLowerCase()); const sh = share(wei);
|
||||||
|
ok(it1 && it1.kind === 'purchase' && it1.what === '10 post credits' && it1.usdCents === 300, 'ledger lists the pack purchase', it1);
|
||||||
|
const pz = it1 && Object.fromEntries(it1.pays.map(x => [x.role, x]));
|
||||||
|
ok(pz && pz.sponsor && pz.sponsor.to === S && BigInt(pz.sponsor.wei) === sh.sp && BigInt(pz.prize.wei) === sh.pz && BigInt(pz.company.wei) === sh.co && pz.prize.to === P.address.toLowerCase(),
|
||||||
|
'ledger split from the receipt: 30% to the sponsor, 10% prize wallet, 60% company (exact wei)', it1 && it1.pays);
|
||||||
|
ok(led.totals && led.totals.purchases === 3 && BigInt(led.totals.sponsorWei) === BigInt(led.totals.weiPaid) * 3000n / 10000n, 'ledger totals: 3 purchases (seeded + 2), sponsor POL = 30% of both sponsored purchases', led.totals);
|
||||||
|
ok((led.items || []).some(x => x.kind === 'purchase' && x.what === 'the banner look'), 'ledger names the banner look purchase', led.items && led.items.map(x => x.what));
|
||||||
|
const cf = await call('/api/contract');
|
||||||
|
ok(cf.live === true && cf.owner === deployer.address.toLowerCase() && cf.prizeWallet === P.address.toLowerCase() && cf.company === company.toLowerCase() && cf.keeper === keeper.address.toLowerCase()
|
||||||
|
&& cf.paused === false && cf.orderCount === 2 && cf.balanceWei === '0' && cf.split.sponsorPct === 30 && cf.split.prizePct === 10 && cf.split.companyPct === 60 && cf.verified.sourcify === true,
|
||||||
|
'/api/contract reads the live facts (owner, prize wallet, company, keeper, 2 orders, holds 0)', cf);
|
||||||
|
for (const pg of ['/contract', '/ledger', '/terms', '/disclaimer', '/privacy']) { const r2 = await fetch(BASE + pg); const h = await r2.text();
|
||||||
|
ok(r2.status === 200 && /common\.js\?v=\d+/.test(h) && !h.includes('—'), pg + ' serves (no em dashes)'); }
|
||||||
|
const legal = (await (await fetch(BASE + '/terms')).text()) + (await (await fetch(BASE + '/disclaimer')).text()) + (await (await fetch(BASE + '/privacy')).text());
|
||||||
|
ok(legal.includes('TrustClickz') && !/Green Valley|Moody|35004/.test(legal) && /ever billed again/.test(legal) && /final once confirmed/.test(legal) && /not an investment/.test(legal) && /network hub/.test(legal) && !/\$50|cap/i.test(legal.replace(/capture|capital|escape/gi, '')),
|
||||||
|
'legal pages: TrustClickz, one-time purchases, no refunds on-chain, not an investment, the hub, no prize cap');
|
||||||
|
const ns = await call('/api/network-sites'); const nl = Object.keys(ns).filter(k => /^\d+$/.test(k)).map(k => ns[k]);
|
||||||
|
ok(nl.length === 6 && nl.map(x => x.name).join(',') === 'InstantAdPay,LinkSpin,Downline Banners,Viral Banner Blitz,Stack POL,Earners Corner', '/api/network-sites: the six network sites (fallback list when the hub has none)', nl.map(x => x.name));
|
||||||
|
let photos = []; for (let i = 0; i < 40; i++) { photos = tgCalls.filter(c => c.method === 'sendPhoto'); if (photos.length >= 2) break; await sleep(200); }
|
||||||
|
const c1 = photos.find(c => String(c.body.caption).includes(tx.hash.toLowerCase()));
|
||||||
|
ok(photos.length === 2 && photos.every(c => c.token === 'botstandin-token' && c.body.chat_id === '-100123' && c.body.message_thread_id === 632242 && c.body.parse_mode === 'HTML' && /\/art\/proof\/vbb-proof-(pink|blue|yellow)\.png$/.test(c.body.photo)),
|
||||||
|
'one Telegram photo card per purchase (2), to the payments topic, with a proof image', photos.map(c => [c.token, c.body.chat_id, c.body.message_thread_id, c.body.photo]));
|
||||||
|
ok(photos.length === 2 && photos[0].body.photo !== photos[1].body.photo, 'the card image rotates between posts');
|
||||||
|
ok(c1 && /@buyerm bought 10 post credits · \$3\.00 \(12\.0000 POL\)/.test(c1.body.caption) && c1.body.caption.includes('Sponsor 30%: 3.6000 POL → @sponsors') && c1.body.caption.includes('Weekly prize pot 10%: 1.2000 POL')
|
||||||
|
&& c1.body.caption.includes('Viral Banner Blitz: 7.2000 POL') && /This week: \d+ purchases?, \$[\d.]+ · prize pot \$[\d.]+/.test(c1.body.caption) && c1.body.caption.includes('https://explorer.invalid/tx/' + tx.hash.toLowerCase()) && !c1.body.caption.includes('—'),
|
||||||
|
'card caption: buyer, sponsor + prize + company split in POL, this week\'s stats, verify link', c1 && c1.body.caption);
|
||||||
|
await call('/api/my/paid', {}); await sleep(1500); // more watcher scans
|
||||||
|
ok(tgCalls.filter(c => c.method === 'sendPhoto').length === 2, 'rescans never post the same purchase twice');
|
||||||
|
|
||||||
console.log('2. weekly prize payout (last week: ' + LAST_WEEK + ')');
|
console.log('2. weekly prize payout (last week: ' + LAST_WEEK + ')');
|
||||||
let ap, plan; for (let i = 0; i < 40; i++) { ap = await adm('/api/admin/prizes'); plan = (ap.weeks || []).find(w => w.week === LAST_WEEK); if (plan) break; await sleep(250); }
|
let ap, plan; for (let i = 0; i < 40; i++) { ap = await adm('/api/admin/prizes'); plan = (ap.weeks || []).find(w => w.week === LAST_WEEK); if (plan) break; await sleep(250); }
|
||||||
ok(plan && plan.status === 'prepared', 'the app prepared last week by itself', ap.weeks && ap.weeks.map(w => w.week + ':' + w.status));
|
ok(plan && plan.status === 'prepared', 'the app prepared last week by itself', ap.weeks && ap.weeks.map(w => w.week + ':' + w.status));
|
||||||
@@ -152,7 +192,13 @@ async function main() {
|
|||||||
let r = await adm('/api/admin/prizes/prepare', { week: LAST_WEEK }); ok(r.status === 'paid', 'preparing a paid week again changes nothing', r.status);
|
let r = await adm('/api/admin/prizes/prepare', { week: LAST_WEEK }); ok(r.status === 'paid', 'preparing a paid week again changes nothing', r.status);
|
||||||
const pub = await call('/api/prizes'); const lw = (pub.past || [])[0];
|
const pub = await call('/api/prizes'); const lw = (pub.past || [])[0];
|
||||||
ok(lw && lw.week === LAST_WEEK && lw.winners.length === 6 && lw.winners.every(x => x.tx && x.confirmed && x.pol) && pub.explorer === 'https://explorer.invalid' && !JSON.stringify(pub).includes(P.privateKey.slice(2, 12)), 'public /api/prizes lists the winners with their transactions (never the key)', lw);
|
ok(lw && lw.week === LAST_WEEK && lw.winners.length === 6 && lw.winners.every(x => x.tx && x.confirmed && x.pol) && pub.explorer === 'https://explorer.invalid' && !JSON.stringify(pub).includes(P.privateKey.slice(2, 12)), 'public /api/prizes lists the winners with their transactions (never the key)', lw);
|
||||||
|
let lines = []; for (let i = 0; i < 40; i++) { lines = tgCalls.filter(c => c.method === 'sendMessage' && /weekly prize/.test(c.body.text)); if (lines.length >= 6) break; await sleep(200); }
|
||||||
|
ok(lines.length === 6 && lines.every(c => c.body.message_thread_id === 632242 && /POL \(\$\d+\.\d\d\)/.test(c.body.text) && /explorer\.invalid\/tx\/0x[0-9a-f]{64}/.test(c.body.text))
|
||||||
|
&& new Set(lines.map(c => c.body.text.match(/tx\/(0x[0-9a-f]{64})/)[1])).size === 6, 'one Telegram line per confirmed prize payout (6), each with its own transaction', lines.map(c => c.body.text.split('\n')[1]));
|
||||||
|
ok(lines.some(c => c.body.text.includes('@winner1 · 1st place, most verified visitors') && c.body.text.includes('20.0000 POL ($5.00)')), 'prize line names the winner, place, board and amount', lines.map(c => c.body.text.split('\n')[1]));
|
||||||
|
const led2 = await call('/api/ledger?n=50'); ok((led2.items || []).filter(x => x.kind === 'prize' && x.confirmed).length === 6 && led2.totals.prizePayouts === 6, 'the ledger lists the 6 prize payouts with their transactions', led2.totals);
|
||||||
const st = await adm('/api/admin/status'); ok(!JSON.stringify(st).includes(P.privateKey.slice(2, 12)) && st.prize && st.prize.keyAddress === P.address.toLowerCase(), 'admin status shows the prize wallet, never its key');
|
const st = await adm('/api/admin/status'); ok(!JSON.stringify(st).includes(P.privateKey.slice(2, 12)) && st.prize && st.prize.keyAddress === P.address.toLowerCase(), 'admin status shows the prize wallet, never its key');
|
||||||
|
ok(st.proof && st.proof.telegram === true && st.proof.posted === 2 && st.proof.prizeLines === 6 && !JSON.stringify(st).includes('standin-token'), 'admin status shows the proof posts, never the bot token', st.proof);
|
||||||
|
|
||||||
srv.kill(); an.kill();
|
srv.kill(); an.kill();
|
||||||
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"site": "vbb",
|
||||||
|
"home": [
|
||||||
|
{ "q": "What is Viral Banner Blitz?", "kb": "about", "must": ["loop", "10 verified visitors", "150 network ad views"] },
|
||||||
|
{ "q": "Is posting free?", "kb": "free-credit", "must": ["one free post credit", "InstantAdPay or LinkSpin"] },
|
||||||
|
{ "q": "What size is the banner?", "kb": "post", "must": ["125x125", "100 KB"] },
|
||||||
|
{ "q": "How much are the packages?", "kb": "packages", "must": ["10 post credits for \\$3", "40 post credits for \\$10", "\\$2"] },
|
||||||
|
{ "q": "Where does my payment go?", "kb": "split", "must": ["30%", "10%", "60%"] },
|
||||||
|
{ "q": "Are the 150 views added to my advertising yet?", "kb": "cycle", "must": ["not switched on yet"] },
|
||||||
|
{ "q": "How do I win the weekly prize?", "kb": "leaders", "must": ["top three", "following Monday"] },
|
||||||
|
{ "q": "What are the SPIN tiles?", "kb": "spin-tiles", "must": ["never shift"] },
|
||||||
|
{ "q": "Can I change the link on my banner?", "kb": "swap", "must": ["one time", "keeps its place"] },
|
||||||
|
{ "q": "Which wallet should I use?", "kb": "wallet", "must": ["SafePal or any other crypto wallet"] },
|
||||||
|
{ "q": "Is this a pyramid scheme?", "kb": "safe", "must": ["contract", "not an income opportunity"] }
|
||||||
|
],
|
||||||
|
"cross": [
|
||||||
|
{ "q": "What is Downline Banners?", "site": "bannerline" },
|
||||||
|
{ "q": "How does a ViralAdBlitz Boost work?", "site": "viraladblitz" },
|
||||||
|
{ "q": "What is DownlineHydra Pro?", "site": "downlinehydra" },
|
||||||
|
{ "q": "What is LinkSpin Banner Spin?", "site": "linkspin" },
|
||||||
|
{ "q": "What is the 5xYourTeam draft?", "site": "fivex" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// Site assistant checks (2026-11-15): node qa/chatbot.test.mjs
|
||||||
|
// No network: a stand-in OpenRouter and a stand-in hub. Checks the instant answers route every example question to its own entry,
|
||||||
|
// the house rules (no em dashes, no MetaMask, never RM Circle, ad-credits line where credits come up, no income promises),
|
||||||
|
// the network merge (home boosted, a named site boosted), the support hand-off, and the site's scripted Q&A (qa/chat-qa.json:
|
||||||
|
// home questions must land on the named entry and contain the expected facts).
|
||||||
|
// The SAME file ships in every rebuilt network site.
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import http from 'node:http';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const ROOT = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||||
|
|
||||||
|
const DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'chat-'));
|
||||||
|
process.env.DATA_DIR = DIR; delete process.env.DOCSTORE_URL; process.env.NETKB = '0'; delete process.env.OPENROUTER_API_KEY;
|
||||||
|
let pass = 0, fail = 0; const bad = [];
|
||||||
|
const ok = (c, m) => { if (c) pass++; else { fail++; bad.push(m); console.log('FAIL', m); } };
|
||||||
|
|
||||||
|
// stand-in OpenRouter: answers with what the system prompt says about the first KB entry, so we can see the prompt
|
||||||
|
let lastPrompt = '', reply = 'Fine.';
|
||||||
|
const or = http.createServer((req, res) => { let b = ''; req.on('data', c => { b += c; }); req.on('end', () => {
|
||||||
|
const j = JSON.parse(b); lastPrompt = j.messages[0].content; ok(j.reasoning && j.reasoning.enabled === false, 'reasoning is switched off');
|
||||||
|
res.writeHead(200, { 'Content-Type': 'application/json' }); res.end('\n\n' + JSON.stringify({ choices: [{ message: { content: reply } }] })); }); });
|
||||||
|
await new Promise(r => or.listen(0, r));
|
||||||
|
process.env.OPENROUTER_URL = 'http://127.0.0.1:' + or.address().port + '/v1/chat/completions';
|
||||||
|
|
||||||
|
try { const cfg = require(path.join(ROOT, 'config.js')); if (cfg.reset) cfg.reset(); } catch (e) {} // Stack POL has no config.js
|
||||||
|
const bot = require(path.join(ROOT, 'chatbot.js'));
|
||||||
|
const core = require(path.join(ROOT, 'chatcore.js'));
|
||||||
|
const kb = require(path.join(ROOT, 'kb.js'));
|
||||||
|
const netkb = require(path.join(ROOT, 'netkb.js'));
|
||||||
|
const dataDir = bot.SITE.dataDir;
|
||||||
|
await bot.init();
|
||||||
|
|
||||||
|
// 1. seeds and the fast path: every example question of a canned entry lands on that entry (first match wins)
|
||||||
|
const seeds = core.seeds();
|
||||||
|
ok(seeds.length >= 10, 'at least 10 seeded entries (' + seeds.length + ')');
|
||||||
|
for (const c of bot.CANNED) {
|
||||||
|
ok(c.re instanceof RegExp, c.id + ' has a pattern');
|
||||||
|
for (const q of c.q || []) { const hit = await kb.fastPath(q); ok(hit && hit.id === 'c-' + c.id, 'example "' + q + '" -> ' + c.id + ' (got ' + (hit && hit.id) + ')'); }
|
||||||
|
}
|
||||||
|
// 2. house rules in every seeded answer
|
||||||
|
for (const s of seeds) {
|
||||||
|
ok(!/[—―]/.test(s.answer + s.title), s.id + ': no em dashes');
|
||||||
|
ok(!/metamask/i.test(s.answer), s.id + ': never recommends MetaMask');
|
||||||
|
ok(!/rm ?circle/i.test(s.answer), s.id + ': never RM Circle');
|
||||||
|
ok(!/(guarantee[ds]? (income|earnings|profit)|you will (earn|make)|passive income|get rich|up to \$?\d[\d,.]* (a|per) (day|week|month))/i.test(s.answer), s.id + ': no income promise');
|
||||||
|
if (/\bad credits?\b/i.test(s.answer)) ok(/Ad credits buy advertising, not income\./.test(s.answer), s.id + ': ad credits line');
|
||||||
|
if (/wallet/i.test(s.answer) && /(which|use|recommend)/i.test(s.answer) && /safepal/i.test(s.answer)) ok(/SafePal or any other crypto wallet/i.test(s.answer), s.id + ': wallet wording');
|
||||||
|
}
|
||||||
|
// 3. the engine: scrub, support hand-off, the AI path
|
||||||
|
ok(core.scrub('A — B, use MetaMask or SafePal') === 'A, B, use SafePal', 'scrub: em dash and MetaMask (' + core.scrub('A — B, use MetaMask or SafePal') + ')');
|
||||||
|
{ const r = await bot.answer('I need to talk to a real person about my account'); ok(r.handoff === true, 'asking for a person hands off'); }
|
||||||
|
{ const r = await bot.answer(''); ok(!!r.error, 'empty question refused'); }
|
||||||
|
if (dataDir) fs.writeFileSync(path.join(dataDir, 'openrouter.key'), 'test-key'); else process.env.OPENROUTER_API_KEY = 'test-key'; // no volume (Stack POL): the env key
|
||||||
|
reply = 'Sure — try RM Circle'; { const r = await bot.answer('zzqx unrelated words nobody wrote down'); ok(!/rm ?circle/i.test(r.reply) && !/—/.test(r.reply), 'an RM Circle or em dash reply never leaves (' + r.reply + ')'); }
|
||||||
|
ok(/NEVER promise or estimate income/.test(lastPrompt) && /SafePal or any other crypto wallet/.test(lastPrompt) && /Ad credits buy advertising, not income\./.test(lastPrompt), 'house rules in the system prompt');
|
||||||
|
reply = 'Fine.';
|
||||||
|
|
||||||
|
// 4. the network merge: home boosted, a named site boosted, labelled with the site and its link
|
||||||
|
const GENERAL = bot.CANNED.find(c => !['support', 'refund', 'about'].includes(c.id) && (c.q || []).length).q[0].replace(/\?$/, '');
|
||||||
|
netkb._set({ version: 'v1', sites: { othersite: { name: 'Other Site', url: 'https://other.example', count: 1 }, [process.env.HUB_SITE || bot.SITE.hubSite]: { name: bot.SITE.name, url: bot.SITE.url } },
|
||||||
|
entries: [{ site: 'othersite', id: 'about', title: 'What is Other Site?', questions: ['What is Other Site?', GENERAL + ' on Other Site'], answer: 'Other Site is a test site with its own rules.', tags: ['test'] }] });
|
||||||
|
await kb.load(true);
|
||||||
|
{ const hits = await kb.search(GENERAL, 8); const top = hits[0] && hits[0].entry; ok(top && !top.site, 'home entries first for a general question (top ' + (top && top.id) + ')'); }
|
||||||
|
{ const hits = await kb.search(GENERAL + ' on Other Site', 8); const top = hits[0] && hits[0].entry; ok(top && top.site === 'othersite', 'a named site boosts its own entry (top ' + (top && top.id) + ')'); }
|
||||||
|
{ const block = kb.promptBlock(await kb.context('What is Other Site', 6)); ok(/about Other Site, another network site; send people to https:\/\/other\.example/.test(block), 'remote entry labelled with site and link'); }
|
||||||
|
{ const fp = await kb.fastPath('What is Other Site?'); ok(!fp || !String(fp.id).startsWith('othersite:'), 'other sites never take the fast path'); }
|
||||||
|
{ const r = await bot.answer(GENERAL + ' on Other Site'); ok(!r.canned, 'a question naming another site skips this site\'s instant answers (' + r.kb + ')'); }
|
||||||
|
{ const r = await bot.answer('I need a real person, my order on Other Site failed'); ok(r.handoff === true, 'a hand-off still wins when another site is named'); }
|
||||||
|
{ const r = await bot.answer(bot.CANNED.find(c => c.id === 'about').q[0]); ok(r.canned && r.kb === 'c-about', 'this site\'s own name keeps the instant answer'); }
|
||||||
|
{ const own = await kb.own(); ok(own.length === seeds.length && own.every(e => !e.site), 'publish set = this site\'s own entries only'); }
|
||||||
|
|
||||||
|
// 5. the scripted Q&A (home questions)
|
||||||
|
const qaFile = path.join(ROOT, 'qa', 'chat-qa.json');
|
||||||
|
if (fs.existsSync(qaFile)) {
|
||||||
|
const qa = JSON.parse(fs.readFileSync(qaFile, 'utf8'));
|
||||||
|
for (const t of qa.home || []) {
|
||||||
|
const r = await bot.answer(t.q);
|
||||||
|
if (t.kb) ok(r.kb === 'c-' + t.kb || (Array.isArray(r.kb) && r.kb.includes('c-' + t.kb)), 'Q&A "' + t.q + '" -> ' + t.kb + ' (got ' + JSON.stringify(r.kb) + ')');
|
||||||
|
for (const m of t.must || []) ok(new RegExp(m, 'i').test(r.reply) || new RegExp(m, 'i').test(lastPrompt), 'Q&A "' + t.q + '" mentions /' + m + '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
or.close();
|
||||||
|
console.log((fail ? 'FAILED ' : 'ok ') + pass + ' passed, ' + fail + ' failed');
|
||||||
|
process.exit(fail ? 1 : 0);
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
// Semantic matching, site side (netkb.js route/suggest/match, 2026-11-16) + parity of the shared files: node qa/netkb-semantic.test.mjs
|
||||||
|
// A stand-in hub answers /v1/kb/match with scripted hits, so no model and no network. Checks: a sure match answers with this site's
|
||||||
|
// entry, a pattern hit is kept when the match agrees or has no idea and overruled when the match points elsewhere, other sites'
|
||||||
|
// entries rank behind this site's unless named or clearly closer, a named site that asks about "here" stays home, a slow or down hub
|
||||||
|
// answers null inside the timeout and is skipped for a while (fail soft), and the support suggestions never offer the contact-support entry.
|
||||||
|
// Parity: netkb.js is the same file in all eight network sites, chatcore.js + kb.js in the six that share them (checked against the
|
||||||
|
// sibling checkouts beside this one; a missing sibling is skipped, a different one fails).
|
||||||
|
// The SAME file ships in every network site (InstantAdPay, LinkSpin, ViralAdBlitz, DownlineHydra, 5xYourTeam, VBB, Downline Banners, Stack POL).
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import http from 'node:http';
|
||||||
|
import crypto from 'node:crypto';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const ROOT = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||||
|
let pass = 0, fail = 0, skip = 0;
|
||||||
|
const ok = (c, m) => { if (c) pass++; else { fail++; console.log('FAIL', m); } };
|
||||||
|
|
||||||
|
// ---- parity with the sibling checkouts
|
||||||
|
const sha = f => crypto.createHash('sha1').update(fs.readFileSync(f, 'utf8').replace(/\r\n/g, '\n')).digest('hex');
|
||||||
|
const SIBLINGS = ['onchain-ad-membership/site', 'linkspin/site', 'vbb/app', 'banner-line/app', 'viraladblitz/app', 'downlinehydra/app', '5xyourteam/app', 'stackpol'];
|
||||||
|
const KIT = new Set(['vbb/app', 'banner-line/app', 'viraladblitz/app', 'downlinehydra/app', '5xyourteam/app', 'stackpol']);
|
||||||
|
let base = ROOT; for (let i = 0; i < 4 && !SIBLINGS.some(s => path.resolve(base, s) === ROOT); i++) base = path.dirname(base);
|
||||||
|
const mine = SIBLINGS.find(s => path.resolve(base, s) === ROOT);
|
||||||
|
for (const s of SIBLINGS) {
|
||||||
|
if (s === mine) continue;
|
||||||
|
const dir = path.resolve(base, s);
|
||||||
|
const files = ['netkb.js'].concat(mine && KIT.has(mine) && KIT.has(s) ? ['chatcore.js', 'kb.js'] : []);
|
||||||
|
for (const f of files) {
|
||||||
|
if (!fs.existsSync(path.join(dir, f))) { skip++; continue; }
|
||||||
|
ok(sha(path.join(dir, f)) === sha(path.join(ROOT, f)), 'parity: ' + f + ' differs from ' + s + '/' + f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok(/The SAME file ships in every network site/.test(fs.readFileSync(path.join(ROOT, 'netkb.js'), 'utf8')), 'netkb.js carries the shared-file header');
|
||||||
|
|
||||||
|
// ---- a stand-in hub
|
||||||
|
let script = () => ({ hits: [], margin: 0 }), delay = 0, status = 200, last = null;
|
||||||
|
const hub = http.createServer((req, res) => { let b = ''; req.on('data', c => { b += c; }); req.on('end', () => {
|
||||||
|
last = { path: req.url, body: JSON.parse(b || '{}'), site: req.headers['x-hub-site'] };
|
||||||
|
setTimeout(() => { res.writeHead(status, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(status === 200 ? Object.assign({ ok: true }, script(last.body)) : { error: 'embeddings_down' })); }, delay);
|
||||||
|
}); });
|
||||||
|
await new Promise(r => hub.listen(0, '127.0.0.1', r));
|
||||||
|
process.env.HUB_URL = 'http://127.0.0.1:' + hub.address().port; process.env.HUB_SECRET = 'q'.repeat(40); process.env.HUB_SITE = 'home'; process.env.NETKB_MATCH_MS = '400';
|
||||||
|
delete process.env.NETKB; delete process.env.NETKB_MATCH;
|
||||||
|
process.env.DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'nksem-'));
|
||||||
|
const netkb = require(path.join(ROOT, 'netkb.js'));
|
||||||
|
netkb._set({ version: 'v', sites: { home: { name: 'Home', url: 'https://home.example' }, other: { name: 'Other', url: 'https://other.example' } },
|
||||||
|
entries: [{ site: 'other', id: 'c-split', title: 'Other split', questions: [], answer: 'Other split answer.', tags: [] }] });
|
||||||
|
const own = [{ id: 'c-split', title: 'Split', answer: 'Home split.' }, { id: 'c-packages', title: 'Packages', answer: 'Home prices.' }, { id: 'c-support', title: 'Support', answer: 'Ask support.', handoff: true }, { id: 'kb-t1', title: 'From a ticket', answer: 'Ticket answer.', source: 'ticket' }];
|
||||||
|
const H = (site, id, score) => ({ site, id, title: id, answer: '', score, boosted: score + (site === 'home' ? 0.08 : 0), home: site === 'home' });
|
||||||
|
const set = (hits, margin) => { script = () => ({ hits, margin: margin == null ? 0.1 : margin, confidence: hits.length ? hits[0].score : 0 }); };
|
||||||
|
|
||||||
|
// a sure match answers with this site's entry, even over a pattern hit that points elsewhere
|
||||||
|
set([H('home', 'c-split', 0.93), H('home', 'c-packages', 0.7)]);
|
||||||
|
let r = await netkb.route('how much do I earn', { fast: own[1], own });
|
||||||
|
ok(r && r.via === 'answer' && r.hit.id === 'c-split', 'sure match answers (' + JSON.stringify(r && [r.via, r.hit && r.hit.id]) + ')');
|
||||||
|
ok(last && last.path === '/v1/kb/match' && last.site === 'home' && last.body.k === 8, 'signed match call as this site');
|
||||||
|
// the pattern hit kept when the match agrees
|
||||||
|
set([H('home', 'c-split', 0.78), H('home', 'c-packages', 0.72)], 0.01);
|
||||||
|
r = await netkb.route('what does it cost', { fast: own[1], own });
|
||||||
|
ok(r && r.via === 'agree' && r.hit.id === 'c-packages', 'pattern kept when the match agrees (' + (r && r.via) + ')');
|
||||||
|
// the pattern hit kept when the match has no idea
|
||||||
|
set([H('home', 'c-split', 0.55)]);
|
||||||
|
r = await netkb.route('zzq', { fast: own[1], own });
|
||||||
|
ok(r && r.via === 'regex' && r.hit.id === 'c-packages', 'pattern kept when the match has no idea');
|
||||||
|
// overruled when the match points elsewhere with some confidence
|
||||||
|
set([H('home', 'c-split', 0.8), H('home', 'kb-t1', 0.75)], 0.05);
|
||||||
|
r = await netkb.route('what is my cut when my friends buy', { fast: own[1], own });
|
||||||
|
ok(r && r.via === 'veto' && r.hit === null && r.hits[0].entry.id === 'c-split', 'pattern overruled, the match feeds the prompt (' + (r && r.via) + ')');
|
||||||
|
// home first: another site's entry stays behind unless clearly closer
|
||||||
|
set([H('other', 'c-split', 0.82), H('home', 'c-split', 0.79)], 0.02);
|
||||||
|
r = await netkb.route('my cut', { own });
|
||||||
|
ok(r && r.via === 'context' && r.hits[0].entry.id === 'c-split' && !r.hits[0].entry.site, 'home entry first when no site is named');
|
||||||
|
set([H('other', 'c-split', 0.95), H('home', 'c-packages', 0.70)], 0.2);
|
||||||
|
r = await netkb.route('other thing', { own });
|
||||||
|
ok(r && !r.hits[0].entry.site && r.hits.some(h => h.entry.site === 'other'), 'another site rides behind this site entry when clearly closer');
|
||||||
|
set([H('other', 'c-split', 0.95), H('home', 'c-packages', 0.55)], 0.2);
|
||||||
|
r = await netkb.route('other thing', { own });
|
||||||
|
ok(r && r.hits[0].entry.site === 'other', 'another site leads when this site has nothing close');
|
||||||
|
// a named site asked about "here" stays home (no prefer sent)
|
||||||
|
set([H('home', 'c-split', 0.9)]);
|
||||||
|
await netkb.route('I am on Other, will my team carry over here?', { own, prefer: ['other'] });
|
||||||
|
ok(!last.body.prefer, 'named site + "here": no prefer');
|
||||||
|
await netkb.route('How much is the split on Other?', { own, prefer: ['other'] });
|
||||||
|
ok(Array.isArray(last.body.prefer) && last.body.prefer[0] === 'other', 'named site: prefer sent');
|
||||||
|
// remote never answers outright
|
||||||
|
set([H('other', 'c-split', 0.99)], 0.3);
|
||||||
|
r = await netkb.route('How much is the split on Other?', { own, prefer: ['other'] });
|
||||||
|
ok(r && r.hit === null && r.hits[0].entry.site === 'other', 'another site\'s entry rides as context, never the instant answer');
|
||||||
|
|
||||||
|
// suggestions: KB entries only, no contact-support entry, ticket-derived entries labelled
|
||||||
|
set([H('home', 'kb-t1', 0.82), H('home', 'c-support', 0.8), H('home', 'c-split', 0.79), H('home', 'c-packages', 0.5)]);
|
||||||
|
let s = await netkb.suggest('my payout never arrived after a purchase', { own });
|
||||||
|
ok(s.via === 'semantic' && s.items.map(i => i.id).join() === 'kb-t1,c-split', 'suggest: closest answers, no support entry, no weak ones (' + s.items.map(i => i.id) + ')');
|
||||||
|
ok(s.items[0].fromTicket === true && s.items[1].fromTicket === false, 'suggest: past-ticket entries labelled');
|
||||||
|
s = await netkb.suggest('hi', { own }); ok(s.items.length === 0 && s.via === 'short', 'suggest: too short asks nothing');
|
||||||
|
|
||||||
|
// fail soft: slow hub -> null inside the timeout, then skipped for a while; down hub -> null; suggest falls back to BM25
|
||||||
|
netkb._matchReset(); delay = 2000;
|
||||||
|
let t0 = Date.now(); r = await netkb.route('anything', { own }); const took = Date.now() - t0;
|
||||||
|
ok(r === null && took < 1500, 'slow hub: null within the timeout (' + took + ' ms)');
|
||||||
|
delay = 0; t0 = Date.now(); r = await netkb.route('anything', { own });
|
||||||
|
ok(r === null && Date.now() - t0 < 50, 'after a failure the hub is skipped for a while (no wait)');
|
||||||
|
s = await netkb.suggest('my payout never arrived after a purchase', { own, fallback: async () => [{ entry: own[0] }, { entry: own[2] }] });
|
||||||
|
ok(s.via === 'bm25' && s.items.map(i => i.id).join() === 'c-split', 'suggest falls back to BM25 when the hub is skipped');
|
||||||
|
netkb._matchReset(); status = 503;
|
||||||
|
r = await netkb.route('anything', { own }); ok(r === null, 'hub 503: null');
|
||||||
|
netkb._matchReset(); status = 200;
|
||||||
|
process.env.NETKB_MATCH = '0'; r = await netkb.route('anything', { own }); ok(r === null, 'NETKB_MATCH=0: off'); delete process.env.NETKB_MATCH;
|
||||||
|
const v = netkb.view(); ok(v.matchErrors >= 2 && v.semAnswer >= 1 && typeof v.sem.answer === 'number', 'view carries the semantic counters');
|
||||||
|
|
||||||
|
hub.close();
|
||||||
|
console.log((fail ? 'FAILED ' : 'ok ') + pass + ' passed, ' + fail + ' failed' + (skip ? ', ' + skip + ' sibling files not here (skipped)' : ''));
|
||||||
|
process.exit(fail ? 1 : 0);
|
||||||
@@ -63,11 +63,31 @@ require('node:http').createServer(async (q, r) => { let b = ''; for await (const
|
|||||||
else if (j.email && HUBMAIL.has(j.email)) return r.end(JSON.stringify({ person: { id: 'h_' + '9'.repeat(16), username: HUBMAIL.get(j.email), wallet: null, sponsor: null, blocked: false } }));
|
else if (j.email && HUBMAIL.has(j.email)) return r.end(JSON.stringify({ person: { id: 'h_' + '9'.repeat(16), username: HUBMAIL.get(j.email), wallet: null, sponsor: null, blocked: false } }));
|
||||||
return r.end(JSON.stringify({ person: hubPerson(w) })); }
|
return r.end(JSON.stringify({ person: hubPerson(w) })); }
|
||||||
HUB.got.push({ route: q.url, body: JSON.parse(b) }); r.end(JSON.stringify({ id: 'p' + HUB.got.length })); }).listen(HUB_PORT, '127.0.0.1').unref();
|
HUB.got.push({ route: q.url, body: JSON.parse(b) }); r.end(JSON.stringify({ id: 'p' + HUB.got.length })); }).listen(HUB_PORT, '127.0.0.1').unref();
|
||||||
|
// stand-in LinkSpin partner API (/api/partner/bl/spins, the Banner Spins call): checks the NETWORK_SSO_SECRET signature and
|
||||||
|
// site 'vbb', answers like LinkSpin (account by wallet, else by network username; 125x125 + 250x250 spins only). LSA: wallet ->
|
||||||
|
// { username, spins: [{ id, name, code, size, paused, banners }] }; LS.tamper(use) may change a "use" answer (bad size, bad host).
|
||||||
|
const LS = { calls: [], badSig: 0, tamper: null }; const LSA = new Map(); const LS_PORT = PORT + 4, LS_HOST = 'rubav-standin.com';
|
||||||
|
require('node:http').createServer(async (q, r) => { let b = ''; for await (const c of q) b += c;
|
||||||
|
r.setHeader('Content-Type', 'application/json');
|
||||||
|
const ts = String(q.headers['x-net-ts'] || ''), want = crypto.createHmac('sha256', SSO_SECRET).update('net.v1.' + ts + '\n' + b).digest('hex');
|
||||||
|
if (q.url !== '/api/partner/bl/spins' || q.headers['x-net-sig'] !== want || Math.abs(Date.now() - Number(ts)) > 300000) { LS.badSig++; r.statusCode = 401; return r.end('{"error":"unauthorized"}'); }
|
||||||
|
const j = JSON.parse(b || '{}'); LS.calls.push(j);
|
||||||
|
let a = LSA.get(j.wallet); if (a && a.byName) a = null;
|
||||||
|
if (!a && j.username) a = [...LSA.values()].find(x => x.byName && x.username === j.username);
|
||||||
|
if (!a) return r.end('{"account":false}');
|
||||||
|
const sp = a.spins.filter(x => j.site === 'vbb' ? ['125x125', '250x250'].includes(x.size) : x.size === '468x60');
|
||||||
|
const out = { account: true, username: a.username, host: LS_HOST, spins: sp };
|
||||||
|
if (j.spinId != null) {
|
||||||
|
const x = sp.find(y => y.id === j.spinId); if (!x) { r.statusCode = 404; return r.end('{"error":"No such 125x125 (or 250x250) Banner Spin on this LinkSpin account."}'); }
|
||||||
|
out.use = { spinId: x.id, name: x.name, size: x.size, img: 'https://' + LS_HOST + '/i/' + x.code + '.gif', link: 'https://' + LS_HOST + '/c/' + x.code + '?clickid={clickid}&placement={spot}&s1={type}', otherSource: !!x.otherSource };
|
||||||
|
if (LS.tamper) LS.tamper(out.use);
|
||||||
|
}
|
||||||
|
r.end(JSON.stringify(out)); }).listen(LS_PORT, '127.0.0.1').unref();
|
||||||
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '',
|
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '',
|
||||||
LOOP_SIZE: '5', VISITORS_PER_SHIFT: '3', VIEWS_PER_CYCLE: '150', VISIT_SECONDS: '2', VISITS_PER_IP_DAY: '2', LINK_PROBE: '0', NETWORK_LOOKUP_URL: 'http://127.0.0.1:' + (PORT + 1) + '/api/network/member',
|
LOOP_SIZE: '5', VISITORS_PER_SHIFT: '3', VIEWS_PER_CYCLE: '150', VISIT_SECONDS: '2', VISITS_PER_IP_DAY: '2', LINK_PROBE: '0', NETWORK_LOOKUP_URL: 'http://127.0.0.1:' + (PORT + 1) + '/api/network/member',
|
||||||
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid',
|
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', LS_PARTNER_URL: 'http://127.0.0.1:' + LS_PORT, LS_SPINS_FIRST_MS: '300', LS_SPINS_EVERY_MS: '700',
|
||||||
CONTRACT_ADDRESS: SHOP, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200',
|
CONTRACT_ADDRESS: SHOP, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200',
|
||||||
HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_TICK_MS: '300', HUB_DOWN_MS: '400' });
|
HUB_ENABLED: '1', NETKB: '0', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_TICK_MS: '300', HUB_DOWN_MS: '400' });
|
||||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
let pass = 0, fail = 0; let srv = null;
|
let pass = 0, fail = 0; let srv = null;
|
||||||
const ok = (cond, what, extra) => { if (cond) { pass++; console.log(' ok ' + what); } else { fail++; console.log(' FAIL ' + what + (extra !== undefined ? ' -> ' + JSON.stringify(extra).slice(0, 400) : '')); } };
|
const ok = (cond, what, extra) => { if (cond) { pass++; console.log(' ok ' + what); } else { fail++; console.log(' FAIL ' + what + (extra !== undefined ? ' -> ' + JSON.stringify(extra).slice(0, 400) : '')); } };
|
||||||
@@ -166,10 +186,11 @@ async function main() {
|
|||||||
const kr = await anon.req('/api/promo-kit?u=smokeleader'); const k = await kr.json();
|
const kr = await anon.req('/api/promo-kit?u=smokeleader'); const k = await kr.json();
|
||||||
ok(kr.status === 200 && kr.headers.get('access-control-allow-origin') === '*', 'promo kit: GET /api/promo-kit 200 with CORS open', kr.status);
|
ok(kr.status === 200 && kr.headers.get('access-control-allow-origin') === '*', 'promo kit: GET /api/promo-kit 200 with CORS open', kr.status);
|
||||||
ok(k.username === 'smokeleader' && k.links.length === 3 && k.links.every(l => l.url.startsWith('https://viralbannerblitz.com/') && l.url.endsWith('?ref=smokeleader')), 'promo kit: every link carries ?ref=<username>', k.links);
|
ok(k.username === 'smokeleader' && k.links.length === 3 && k.links.every(l => l.url.startsWith('https://viralbannerblitz.com/') && l.url.endsWith('?ref=smokeleader')), 'promo kit: every link carries ?ref=<username>', k.links);
|
||||||
|
ok(k.links.every(l => /^https:\/\/linkspin\.app\/r\/nwvbb\?src=vbb&s1=smokeleader(&s2=[a-z]+)?$/.test(l.tracked)) && k.links[0].tracked.indexOf('&s2=') < 0 && /&s2=how$/.test(k.links[1].tracked), 'promo kit: every link has a LinkSpin-tracked twin (network link nwvbb, source vbb, the member as s1, the page as s2)', k.links.map(l => l.tracked));
|
||||||
ok(k.lines.length === 5 && k.headlines.length === 3 && k.posts.length === 2 && k.email && k.email.subject && k.email.body.includes('?ref=smokeleader'), 'promo kit: 5 lines, 3 headlines, 1 email, 2 posts, link filled in');
|
ok(k.lines.length === 5 && k.headlines.length === 3 && k.posts.length === 2 && k.email && k.email.subject && k.email.body.includes('?ref=smokeleader'), 'promo kit: 5 lines, 3 headlines, 1 email, 2 posts, link filled in');
|
||||||
const words = JSON.stringify([k.lines, k.headlines, k.email, k.posts, k.note, k.tagline]);
|
const words = JSON.stringify([k.lines, k.headlines, k.email, k.posts, k.note, k.tagline]);
|
||||||
ok(!/[—–]/.test(words) && !/\$50|passive income|guaranteed (income|returns|profit)|earn (cash|money)|make money/i.test(words) && /at least \$20/.test(words), 'promo kit copy: no dashes, no cap, no income promises, pot shown as at least $20');
|
ok(!/[—–]/.test(words) && !/\$50|passive income|guaranteed (income|returns|profit)|earn (cash|money)|make money/i.test(words) && /at least \$20/.test(words), 'promo kit copy: no dashes, no cap, no income promises, pot shown as at least $20');
|
||||||
ok(k.creatives.length === 21 && new Set(k.creatives.map(c => c.angle)).size === 3, 'promo kit: 21 creatives in 3 angles', k.creatives.length);
|
ok(k.creatives.length === 24 && new Set(k.creatives.map(c => c.angle)).size === 3, 'promo kit: 24 creatives in 3 angles', k.creatives.length);
|
||||||
const badName = k.creatives.filter(c => /\d{2,4}x\d{2,4}|banner|[-_/]ads?[-_./]/i.test(c.url.replace('https://viralbannerblitz.com', '')));
|
const badName = k.creatives.filter(c => /\d{2,4}x\d{2,4}|banner|[-_/]ads?[-_./]/i.test(c.url.replace('https://viralbannerblitz.com', '')));
|
||||||
ok(badName.length === 0, 'promo kit: creative paths are ad-blocker neutral (no size tokens, no banner/ad words)', badName.map(c => c.url));
|
ok(badName.length === 0, 'promo kit: creative paths are ad-blocker neutral (no size tokens, no banner/ad words)', badName.map(c => c.url));
|
||||||
let dimOk = true; const dimBad = [];
|
let dimOk = true; const dimBad = [];
|
||||||
@@ -188,8 +209,20 @@ async function main() {
|
|||||||
ok(r.status === 404 && /Back to the loop/.test(nf), '404 page served');
|
ok(r.status === 404 && /Back to the loop/.test(nf), '404 page served');
|
||||||
ok(/script-src[^;]*https:\/\/linkspin\.app/.test(r.headers.get('content-security-policy') || ''), 'CSP admits linkspin.app (network zones)');
|
ok(/script-src[^;]*https:\/\/linkspin\.app/.test(r.headers.get('content-security-policy') || ''), 'CSP admits linkspin.app (network zones)');
|
||||||
r = await anon.req('/sitemap.xml'); ok((await r.text()).includes('/promote'), 'sitemap lists /promote');
|
r = await anon.req('/sitemap.xml'); ok((await r.text()).includes('/promote'), 'sitemap lists /promote');
|
||||||
|
{ const sm = await (await anon.req('/sitemap.xml')).text(); const G = ['/guides', '/guides/is-it-legit', '/guides/free-account', '/guides/prize-boards', '/guides/faq']; // Guides (2026-11-17)
|
||||||
|
ok(G.every(g => sm.includes('viralbannerblitz.com' + g + '<')), 'sitemap lists every guide');
|
||||||
|
for (const g of G) { const gr = await anon.req(g); const gh = await gr.text(); ok(gr.status === 200 && gh.includes('<link rel="canonical" href="https://viralbannerblitz.com' + g + '">') && /<meta name="description" content="[^"]{60,}">/.test(gh) && /og:title/.test(gh) && (g === '/guides' || /href="\/guides"/.test(gh)) &&!/\$50|cap of|RM Circle|up to \$/i.test(gh), 'GET ' + g + ': 200, canonical, description, OG, links back to the guides, no cap or RM Circle', gr.status); }
|
||||||
|
const lg = await (await anon.req('/guides/is-it-legit')).text(); ok(/0x36F6ccc8752DcE1c84e06b65f07dF30e8a4707D7/.test(lg) && /30%/.test(lg) && /10%/.test(lg) && /60%/.test(lg) && /href="\/ledger"/.test(lg), 'legit guide: contract address, the 30/10/60 split, the ledger'); }
|
||||||
}
|
}
|
||||||
r = await anon.req('/api/my'); ok(r.status === 401, '/api/my needs sign-in');
|
r = await anon.req('/api/my'); ok(r.status === 401, '/api/my needs sign-in');
|
||||||
|
// the site assistant (2026-11-15): widget on every page, canned answers without AI, account problems hand off, admin KB behind the token
|
||||||
|
{ const home = await (await anon.req('/')).text();
|
||||||
|
ok(/<script src="\/assets\/chat\.js\?v=\d+" defer><\/script>/.test(home) && (await anon.req('/assets/chat.js')).status === 200 && (await anon.req('/assets/chat.css')).status === 200, 'chat widget on the page, its script and styles served'); }
|
||||||
|
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'How much are the packages?' }) }); const cj = await cr.json();
|
||||||
|
ok(cr.status === 200 && cj.canned && /\$3/.test(cj.reply) && /\$10/.test(cj.reply), 'chat: canned packages answer', cj); }
|
||||||
|
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'my credits did not show up' }) }); const cj = await cr.json();
|
||||||
|
ok(cj.handoff === true && /^https:\/\/instantadpay\.com\/support\?from=vbb/.test(cj.support || ''), 'chat: account problem hands off to network support', cj); }
|
||||||
|
ok((await anon.req('/api/admin/kb')).status === 401, 'admin KB needs the token');
|
||||||
|
|
||||||
console.log('4. members: wallet sign-in and network sign-in');
|
console.log('4. members: wallet sign-in and network sign-in');
|
||||||
const A = await walletMember();
|
const A = await walletMember();
|
||||||
@@ -372,6 +405,12 @@ async function main() {
|
|||||||
my = await V.json('/api/my'); ok(my.credits === credits0 + 60, 'another contract log is ignored; a second order (same tx, other log index) credits 40', my.credits);
|
my = await V.json('/api/my'); ok(my.credits === credits0 + 60, 'another contract log is ignored; a second order (same tx, other log index) credits 40', my.credits);
|
||||||
const ads = await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN });
|
const ads = await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN });
|
||||||
ok(ads.shop && ads.shop.watching && ads.shop.vouchers && ads.shop.purchases === 2 && ads.shop.creditsSold === 60 && ads.shop.dupes >= 2 && ads.shop.lastBlock === 12 && ads.shop.keeper === keeperAddr && !JSON.stringify(ads).includes(KEEPER_PK.slice(2, 12)), 'admin sees the watcher: 2 purchases, 60 credits, duplicates skipped, no key', ads.shop);
|
ok(ads.shop && ads.shop.watching && ads.shop.vouchers && ads.shop.purchases === 2 && ads.shop.creditsSold === 60 && ads.shop.dupes >= 2 && ads.shop.lastBlock === 12 && ads.shop.keeper === keeperAddr && !JSON.stringify(ads).includes(KEEPER_PK.slice(2, 12)), 'admin sees the watcher: 2 purchases, 60 credits, duplicates skipped, no key', ads.shop);
|
||||||
|
// the network hub's member lookup (2026-11-14, read-only)
|
||||||
|
const ml = await anon.json('/api/admin/member-lookup?q=' + V.address, undefined, { 'x-admin-token': ADMIN });
|
||||||
|
ok(ml._status === 200 && ml.known && ml.record && ml.purchases.length === 2 && ml.purchases.every(x => x.tx === tx1) && ml.credits === credits0 + 60 && ml.contract === ethers.getAddress(SHOP), 'admin member lookup by wallet: record, credits, 2 purchases with tx', ml);
|
||||||
|
const mls = await anon.json('/api/admin/member-lookup?q=' + spW, undefined, { 'x-admin-token': ADMIN });
|
||||||
|
ok(mls._status === 200 && mls.sponsored.length === 2 && !mls.record, 'admin member lookup: the sponsor wallet shows the sales it was paid on', mls);
|
||||||
|
r = await anon.req('/api/admin/member-lookup?q=' + V.address, { headers: { 'x-admin-token': 'wrong-token-x' } }); ok(r.status === 401, 'admin member lookup refuses a wrong token');
|
||||||
// restart: the dedupe marks survive, the replaying RPC still credits nothing
|
// restart: the dedupe marks survive, the replaying RPC still credits nothing
|
||||||
await sleep(1200); await stop(); await boot(); await sleep(900);
|
await sleep(1200); await stop(); await boot(); await sleep(900);
|
||||||
my = await V.json('/api/my'); ok(my.credits === credits0 + 60, 'after a restart the replayed logs still credit nothing', my.credits);
|
my = await V.json('/api/my'); ok(my.credits === credits0 + 60, 'after a restart the replayed logs still credit nothing', my.credits);
|
||||||
@@ -499,6 +538,21 @@ async function main() {
|
|||||||
ok((await pg.textContent('#kit')).includes('?ref=smokeleader') && (await pg.inputValue('#whoIn')) === 'smokeleader', name + ': Promote page shows the kit with the member links');
|
ok((await pg.textContent('#kit')).includes('?ref=smokeleader') && (await pg.inputValue('#whoIn')) === 'smokeleader', name + ': Promote page shows the kit with the member links');
|
||||||
ok(!!(await pg.$('nav a[href="/promote"]')), name + ': nav links to Promote');
|
ok(!!(await pg.$('nav a[href="/promote"]')), name + ': nav links to Promote');
|
||||||
await pg.waitForTimeout(600); await pg.screenshot({ path: path.join(OUT, 'promote-' + name + '.png'), fullPage: true });
|
await pg.waitForTimeout(600); await pg.screenshot({ path: path.join(OUT, 'promote-' + name + '.png'), fullPage: true });
|
||||||
|
// trust pack (2026-11-14): footer legal + proof links, company line, network line; ledger + contract + legal pages render
|
||||||
|
await pg.goto(BASE + '/how', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => /Earners Corner/.test((document.querySelector('footer .netline') || {}).textContent || ''), null, { timeout: 6000 }).catch(() => {});
|
||||||
|
const ft = await pg.textContent('footer.foot'); const hrefs = await pg.$$eval('footer.foot a', as => as.map(a => a.getAttribute('href')));
|
||||||
|
ok(['/terms', '/disclaimer', '/privacy', '/contract', '/ledger'].every(h => hrefs.includes(h)) && /Support/.test(ft) && /© 2026 TrustClickz/.test(ft) && !/Green Valley/.test(ft)
|
||||||
|
&& /Part of the network · One account across the network: InstantAdPay · LinkSpin · Downline Banners · Viral Banner Blitz · Stack POL · Earners Corner/.test(ft.replace(/\s+/g, ' ')) && !/RM Circle|rmcircle/i.test(ft)
|
||||||
|
&& (await pg.textContent('footer .netline .here')) === 'Viral Banner Blitz', name + ': footer: legal + proof links, company line, network line with VBB as current, never RM Circle', ft.slice(-400));
|
||||||
|
const sw = await pg.evaluate(() => document.documentElement.scrollWidth); ok(sw <= pg.viewportSize().width, name + ': footer fits the screen (no sideways scroll)', sw);
|
||||||
|
await pg.locator('footer.foot').screenshot({ path: path.join(OUT, 'footer-' + name + '.png') });
|
||||||
|
for (const lp of ['/terms', '/disclaimer', '/privacy']) { await pg.goto(BASE + lp, { waitUntil: 'domcontentloaded' }); ok((await pg.textContent('main')).includes('TrustClickz') && !!(await pg.$('footer.foot')), name + ': ' + lp + ' renders with the footer'); }
|
||||||
|
await pg.goto(BASE + '/ledger', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => !/Loading/.test(document.querySelector('#rows tbody').textContent), null, { timeout: 8000 }).catch(() => {});
|
||||||
|
ok(!!(await pg.$('#totals .stat')) && !/Loading/.test(await pg.textContent('#rows')), name + ': /ledger renders its totals and rows', (await pg.textContent('#rows')).slice(0, 200));
|
||||||
|
await pg.screenshot({ path: path.join(OUT, 'ledger-' + name + '.png'), fullPage: true });
|
||||||
|
await pg.goto(BASE + '/contract', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => !/Reading the contract/.test(document.getElementById('facts').textContent), null, { timeout: 8000 }).catch(() => {});
|
||||||
|
ok(!/Reading the contract/.test(await pg.textContent('#facts')) && /30%/.test(await pg.textContent('main')), name + ': /contract renders', (await pg.textContent('#facts')).slice(0, 200));
|
||||||
|
await pg.screenshot({ path: path.join(OUT, 'contract-' + name + '.png'), fullPage: true });
|
||||||
await pg.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); await pg.waitForTimeout(300);
|
await pg.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); await pg.waitForTimeout(300);
|
||||||
ok(!(await pg.$('script[src*="linkspin.app/z.js"]')), name + ': no network zone on the loop page');
|
ok(!(await pg.$('script[src*="linkspin.app/z.js"]')), name + ': no network zone on the loop page');
|
||||||
await ctx.close();
|
await ctx.close();
|
||||||
@@ -507,6 +561,265 @@ async function main() {
|
|||||||
await browser.close();
|
await browser.close();
|
||||||
} else console.log('13. page renders skipped (SKIP_UI or no Playwright at ' + PW + ')');
|
} else console.log('13. page renders skipped (SKIP_UI or no Playwright at ' + PW + ')');
|
||||||
|
|
||||||
|
// ---- 14. LinkSpin Banner Spins: post one as a banner, and members' spins fill empty space (never loop banners) ----
|
||||||
|
console.log('14. LinkSpin Banner Spins (stand-in LinkSpin)');
|
||||||
|
{ // unit: the fill picks (Downline Banners dedupe: one per member, no member already on the page, no image twice)
|
||||||
|
const lsu = require(path.join(APP, 'lsspins.js'));
|
||||||
|
lsu.set([{ owner: '0xa', img: 'https://h.com/i/aaa.gif', link: 'https://h.com/c/aaa', owner_name: 'a' }, { owner: '0xb', img: 'https://h.com/i/bbb.gif', link: 'https://h.com/c/bbb' },
|
||||||
|
{ owner: '0xc', img: 'https://h.com/i/bbb.gif', link: 'https://h.com/c/bbb' }, { owner: '0xd', img: 'https://h.com/i/ddd.gif', link: 'https://h.com/c/ddd' }, { owner: '0xe', img: 'https://h.com/i/eee.gif', link: 'https://h.com/c/eee' }]);
|
||||||
|
let f = lsu.fill({ openPlaces: 2, queueSlots: 8, pageOwners: ['0xa'], pageImgs: ['https://h.com/i/eee.gif'] }); const all = f.loop.concat(f.queue);
|
||||||
|
ok(f.loop.length === 2 && all.length === 2 && all.every(t => t.t === 'spin') && !all.some(t => /aaa|eee/.test(t.img)) && new Set(all.map(t => t.img)).size === all.length,
|
||||||
|
'fill: a member on the page and an image on the page are left out, the same image never twice', all.map(t => t.img));
|
||||||
|
f = lsu.fill({ openPlaces: 1, queueSlots: 8, pageOwners: [], pageImgs: [] });
|
||||||
|
ok(f.loop.length === 1 && f.queue.length === 3, 'fill: open places first, the rest into the empty waiting line (4 different images)', [f.loop.length, f.queue.length]);
|
||||||
|
ok(lsu.fill({ openPlaces: 0, queueSlots: 0, pageOwners: [], pageImgs: [] }).loop.length === 0, 'fill: no gap, no fill');
|
||||||
|
}
|
||||||
|
const SP1 = await walletMember(); await SP1.json('/api/my');
|
||||||
|
LSA.set(SP1.address, { username: 'spinner1', spins: [{ id: 11, name: 'Main spin', code: 'qk7spin1', size: '125x125', paused: false, banners: 2 }, { id: 12, name: 'Sharp spin', code: 'qk7spin2', size: '250x250', paused: false, banners: 1 },
|
||||||
|
{ id: 13, name: 'Wide spin', code: 'qk7wide1', size: '468x60', paused: false, banners: 3 }, { id: 14, name: 'Resting', code: 'qk7rest1', size: '125x125', paused: true, banners: 1 }] });
|
||||||
|
let ls = await SP1.json('/api/my/lsspins');
|
||||||
|
ok(ls._status === 200 && ls.account && ls.spins.length === 3 && ls.spins.every(x => ['125x125', '250x250'].includes(x.size)) && !JSON.stringify(ls).includes('qk7'), 'My Banners lists the 125x125 + 250x250 spins only (no codes sent to the browser)', ls);
|
||||||
|
ok(LS.badSig === 0 && LS.calls.length > 0 && LS.calls.every(c => c.site === 'vbb'), 'LinkSpin calls are signed with NETWORK_SSO_SECRET and say site vbb', { bad: LS.badSig, n: LS.calls.length });
|
||||||
|
const anonLs = await anon.json('/api/my/lsspins'); ok(anonLs._status === 401, 'the spin list needs a sign-in');
|
||||||
|
const NOLS = await walletMember(); await NOLS.json('/api/my'); ls = await NOLS.json('/api/my/lsspins');
|
||||||
|
ok(ls._status === 200 && ls.account === false, 'no LinkSpin account for this wallet: account false', ls);
|
||||||
|
const nc = LS.calls.filter(c => c.wallet === NOLS.address).slice(-1)[0] || {}; ok(nc.username && /^net[0-9a-f]{8}$/.test(nc.username), 'a network-verified member is also looked up by network username', nc);
|
||||||
|
// username fallback: LinkSpin knows this member by network username, not by this wallet
|
||||||
|
const UN = await walletMember(); await UN.json('/api/my'); LSA.set('0x' + 'f'.repeat(40), { username: 'net' + UN.address.slice(2, 10), byName: true, spins: [{ id: 31, name: 'By name', code: 'qk7name1', size: '125x125', paused: false, banners: 0 }] });
|
||||||
|
ls = await UN.json('/api/my/lsspins'); ok(ls.account === true && ls.spins.length === 1, 'LinkSpin finds the account by network username when no account holds the wallet', ls);
|
||||||
|
const STR = await walletMember({ stranger: true }); await STR.json('/api/my'); await STR.json('/api/my/lsspins');
|
||||||
|
const sc = LS.calls.filter(c => c.wallet === STR.address); ok(sc.length > 0 && sc.every(c => !c.username), 'a member the network does not know is looked up by wallet only', sc.slice(-1));
|
||||||
|
// posting a spin: one credit, image + link from LinkSpin, straight into the loop / the line like any banner
|
||||||
|
let cr0 = (await SP1.json('/api/my')).credits;
|
||||||
|
let ps = await SP1.json('/api/my/banners', { spinId: 13 }); ok(ps._status === 400 && /125x125/.test(ps.error), 'a 468x60 spin cannot be posted', ps);
|
||||||
|
ps = await SP1.json('/api/my/banners', { spinId: 99 }); ok(ps._status === 400 && /No such/.test(ps.error), 'an unknown spin is refused with LinkSpin\'s reason', ps);
|
||||||
|
LS.tamper = u => { u.size = '468x60'; }; ps = await SP1.json('/api/my/banners', { spinId: 11 }); ok(ps._status === 400 && /125x125/.test(ps.error), 'a wrong size in LinkSpin\'s answer is refused', ps);
|
||||||
|
LS.tamper = u => { u.img = 'https://elsewhere-images.com/x.gif'; }; ps = await SP1.json('/api/my/banners', { spinId: 11 }); ok(ps._status === 400, 'an image on another host than the spin link is refused', ps);
|
||||||
|
LS.tamper = u => { u.link = 'http://' + LS_HOST + '/c/x'; }; ps = await SP1.json('/api/my/banners', { spinId: 11 }); ok(ps._status === 400, 'a plain http spin link is refused', ps);
|
||||||
|
LS.tamper = null;
|
||||||
|
ok((await SP1.json('/api/my')).credits === cr0, 'refused spin posts use no credit', cr0);
|
||||||
|
ps = await SP1.json('/api/my/banners', { spinId: 11, img: 'https://evil-images.com/x.png', link: 'https://evil-target.com/' });
|
||||||
|
ok(ps.ok && ps.credits === cr0 - 1, 'posting a spin uses one credit', ps);
|
||||||
|
my = await SP1.json('/api/my'); const sb = my.banners.find(x => x.id === ps.banner.id);
|
||||||
|
ok(sb && sb.img === 'https://' + LS_HOST + '/i/qk7spin1.gif' && sb.link.startsWith('https://' + LS_HOST + '/c/qk7spin1?') && sb.spin && sb.spin.name === 'Main spin', 'the banner is the spin: its rotating image + click link (never what the browser sent)', sb);
|
||||||
|
ps = await SP1.json('/api/my/banners', { spinId: 12 }); ok(ps._status === 400 && /no post credits/i.test(ps.error), 'no credits left: a spin post is refused too', ps);
|
||||||
|
r = await anon.req('/go/' + sb.id); const gl = new URL(r.headers.get('location') || 'https://x/');
|
||||||
|
ok(r.status === 302 && gl.hostname === LS_HOST && /^[0-9a-f]{16}$/.test(gl.searchParams.get('clickid') || '') && gl.searchParams.get('placement') === String(sb.id) && ['loop', 'waiting'].includes(gl.searchParams.get('s1')),
|
||||||
|
'a click goes through the spin link with {clickid}, {spot} and {type} filled (counts in LinkSpin Reports)', r.headers.get('location'));
|
||||||
|
// fill: a bigger loop (restart with 40 places) leaves open places and nobody waiting
|
||||||
|
const SP2 = await walletMember(), SP3 = await walletMember(), SP4 = await walletMember(), SP5 = await walletMember();
|
||||||
|
for (const m of [SP2, SP3, SP4, SP5]) await m.json('/api/my');
|
||||||
|
LSA.set(SP2.address, { username: 'spinner2', spins: [{ id: 21, name: 'Two', code: 'qk7fill2', size: '125x125', paused: false, banners: 1 }] });
|
||||||
|
LSA.set(SP3.address, { username: 'spinner3', spins: [{ id: 22, name: 'Three', code: 'qk7fill2', size: '125x125', paused: false, banners: 1 }] }); // same image as SP2
|
||||||
|
LSA.set(SP4.address, { username: 'spinner4', spins: [{ id: 23, name: 'Four', code: 'qk7fill4', size: '250x250', paused: false, banners: 2 }] });
|
||||||
|
LSA.set(SP5.address, { username: 'spinner5', spins: [{ id: 24, name: 'Paused', code: 'qk7fill5', size: '125x125', paused: true, banners: 1 }] });
|
||||||
|
const loopBefore = (await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN }));
|
||||||
|
await sleep(1200); ENV.LOOP_SIZE = '40'; await stop(); await boot(); await sleep(1600);
|
||||||
|
sp = await anon.json('/api/splash'); const fl = (sp.fill || { loop: [], queue: [] }); const fall = fl.loop.concat(fl.queue);
|
||||||
|
ok(sp.loop.length < 39 && sp.waiting === 0, 'restart with 40 places: open places, nobody waiting', { loop: sp.loop.length, waiting: sp.waiting });
|
||||||
|
ok(fall.length === 2 && fall.every(t => t.t === 'spin' && t.img.includes(LS_HOST)) && fall.some(t => t.img.includes('qk7fill4')) && fall.some(t => t.img.includes('qk7fill2')),
|
||||||
|
'the gaps show members\' spins: one per image (SP2 and SP3 share one), none paused, none for a member with a banner on the page', fall.map(t => t.img + ' ' + t.owner));
|
||||||
|
ok(!fall.some(t => t.img.includes('qk7spin1')), 'SP1 has a banner in the loop, so no fill tile for SP1');
|
||||||
|
ok(fl.loop.length === 2 && fl.queue.length === 0, 'open loop places are filled first', [fl.loop.length, fl.queue.length]);
|
||||||
|
ok(fall.every(t => /\/c\/qk7fill\d\?placement=fill&s1=fill$/.test(t.href)), 'a fill tile clicks straight through the spin link (placement=fill)', fall.map(t => t.href));
|
||||||
|
ok(!sp.loop.some(t => fall.some(f => f.img === t.img)), 'fill tiles are not in the loop list');
|
||||||
|
let st0 = await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN });
|
||||||
|
ok(st0.loop.filled === sp.loop.length && st0.totals.cycles === loopBefore.totals.cycles && st0.lsSpins && st0.lsSpins.fill >= 2, 'fill never changes the loop, its size or the cycles; admin status counts the fill spins', { filled: st0.loop.filled, cyc: [loopBefore.totals.cycles, st0.totals.cycles], ls: st0.lsSpins });
|
||||||
|
const sp2 = await anon.json('/api/splash'); ok(JSON.stringify(sp2.fill) === JSON.stringify(sp.fill), 'the same fill on the next poll (no reshuffle every 8 seconds)');
|
||||||
|
if (!process.env.SKIP_UI && fs.existsSync(PW)) {
|
||||||
|
const { chromium } = require(PW); const browser = await chromium.launch(); const errs = [];
|
||||||
|
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/130.0 Safari/537.36 SmokeUI-spin' });
|
||||||
|
await ctx.route('https://' + LS_HOST + '/**', rt => rt.fulfill({ status: 200, contentType: 'image/png', body: png(125, 125, 4) })); // nothing leaves this machine
|
||||||
|
const pg = await ctx.newPage(); pg.on('pageerror', e => errs.push(e.message));
|
||||||
|
await pg.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('#loop .tile.fill', { timeout: 8000 }).catch(() => {});
|
||||||
|
const ft = await pg.$$eval('#loop .tile.fill', els => els.map(e => [e.querySelector('.pos') && e.querySelector('.pos').textContent, e.getAttribute('href')]));
|
||||||
|
ok(ft.length === 2 && ft.every(x => x[0] === 'SPIN' && x[1].includes(LS_HOST)), 'splash: open places show SPIN tiles', ft);
|
||||||
|
ok(await pg.isVisible('#fillNote') && /never shift it, never cycle and never earn/.test(await pg.textContent('#fillNote')), 'splash: the note says spins are not loop banners');
|
||||||
|
ok((await pg.$$eval('#loop .tile.open', els => els.length)) >= 1 && (await pg.textContent('#loop .tile.open')).includes('post yours'), 'splash: an open place still says "post yours"');
|
||||||
|
await pg.screenshot({ path: path.join(OUT, 'splash-spins.png'), fullPage: true });
|
||||||
|
await ctx.addCookies([{ name: 'vbb.sid', value: SP4.jar['vbb.sid'], url: BASE }]);
|
||||||
|
await pg.goto(BASE + '/my', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('#dash:not([hidden])', { timeout: 8000 });
|
||||||
|
await pg.click('#lsBtn'); await pg.waitForSelector('#lsPick button[data-spin]', { timeout: 8000 }).catch(() => {});
|
||||||
|
const bts = await pg.$$eval('#lsPick button[data-spin]', els => els.map(e => e.textContent));
|
||||||
|
ok(bts.length === 1 && /Four \(250x250, 2 images\)/.test(bts[0]), 'My Banners: "Use my LinkSpin Banner Spin" lists the spin', bts);
|
||||||
|
await pg.screenshot({ path: path.join(OUT, 'my-spins.png'), fullPage: true });
|
||||||
|
await pg.click('#lsPick button[data-spin]'); await pg.waitForFunction(() => /Posted\. Your Banner Spin/.test(document.body.textContent), null, { timeout: 8000 }).catch(() => {});
|
||||||
|
ok(/Posted\. Your Banner Spin went straight into the loop/.test(await pg.textContent('body')), 'My Banners: one tap posts the spin into the loop');
|
||||||
|
await pg.waitForSelector('.pill.spin', { timeout: 8000 }).catch(() => {});
|
||||||
|
ok(/LinkSpin Banner Spin: Four/.test(await pg.textContent('#mine')), 'My Banners: the banner shows as a Banner Spin');
|
||||||
|
ok(errs.length === 0, 'no page errors (spins)', errs);
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- 15. one swap per banner (members) + admin takedown / restore (Marty 2026-11-15) ----
|
||||||
|
console.log('15. one swap per banner + admin takedown and restore');
|
||||||
|
await sleep(1200); ENV.LOOP_SIZE = '5'; await stop(); await boot();
|
||||||
|
{
|
||||||
|
const ADM = (q, body) => anon.json(q, body, { 'x-admin-token': ADMIN });
|
||||||
|
const ids = v => v.loop.map(t => String(t.id));
|
||||||
|
const shiftOnce = async () => { const rs = await Promise.all([client(), client(), client()].map(c => visit(c))); return rs.some(x => x.shifted); };
|
||||||
|
const X = [];
|
||||||
|
for (let i = 0; i < 7; i++) { const m = await walletMember(); await m.json('/api/my'); const b = await postBanner(m, 20 + i, 'https://swap-member.com/p?i=' + i); m.bid = b.banner && b.banner.id; X.push(m); }
|
||||||
|
ok(X.every(m => m.bid), 'seven members posted a banner each', X.map(m => m.bid));
|
||||||
|
let shifted = 0; for (let i = 0; i < 3; i++) if (await shiftOnce()) shifted++;
|
||||||
|
let st = await ADM('/api/admin/status');
|
||||||
|
ok(shifted === 3 && st.loop.filled === 5 && st.queue.length >= 2, 'three shifts: loop full of 5, others waiting', { shifted, loop: st.loop.ids, q: st.queue.next });
|
||||||
|
const own = id => X.find(m => m.bid === id);
|
||||||
|
const Xa = own(st.loop.ids[2]), Xt = own(st.loop.ids[1]), Xq = own(st.queue.next[1]);
|
||||||
|
ok(!!(Xa && Xt && Xq), 'the new banners sit at loop places 1 to 3 and in the line', { loop: st.loop.ids, q: st.queue.next });
|
||||||
|
|
||||||
|
// -- the swap
|
||||||
|
let my = await Xa.json('/api/my'); let mb = my.banners.find(b => b.id === Xa.bid);
|
||||||
|
ok(mb && mb.canSwap === true && mb.swapUsed === false, 'My Banners: a banner in the loop can be swapped', mb);
|
||||||
|
const before = { place: mb.place, clicks: mb.clicks, img: mb.img, link: mb.link, progress: st.progress };
|
||||||
|
let r = await Xt.json('/api/my/banners/' + Xa.bid + '/swap', { link: 'https://other-member.com/' }); ok(r._status === 404, 'nobody can swap another member\'s banner', r);
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', {}); ok(r._status === 400 && /new image, a new link/.test(r.error), 'a swap with nothing new is refused', r);
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', { link: 'http://plain-http.com/' }); ok(r._status === 400 && /https/.test(r.error), 'swap: an http link is refused (same check as a new post)', r);
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', { link: 'https://bit.ly/abc' }); ok(r._status === 400 && /shortener/.test(r.error), 'swap: a shortener link is refused', r);
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', { img: 'http://swap-member.com/x.png' }); ok(r._status === 400 && /https/.test(r.error), 'swap: an http image address is refused', r);
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', { img: '/u/00000000-aaaaaaaaaaaa.png' }); ok(r._status === 400, 'swap: someone else\'s (or a missing) upload is refused', r);
|
||||||
|
my = await Xa.json('/api/my'); mb = my.banners.find(b => b.id === Xa.bid);
|
||||||
|
ok(mb.canSwap === true && mb.link === before.link && mb.img === before.img, 'refused swaps change nothing and do not use up the swap', mb);
|
||||||
|
const nu = await upload(Xa, png(125, 125, 7));
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', { img: nu.img, link: 'https://swapped-member.com/new' });
|
||||||
|
ok(r.ok && r.banner.id === Xa.bid && r.banner.img === nu.img && r.banner.link === 'https://swapped-member.com/new' && r.banner.state === 'loop' && r.banner.place === before.place, 'the swap changes image + link and keeps the id and the place', r);
|
||||||
|
my = await Xa.json('/api/my'); mb = my.banners.find(b => b.id === Xa.bid);
|
||||||
|
ok(mb.swapUsed === true && mb.canSwap === false && mb.swappedAt > 0 && mb.place === before.place && mb.clicks === before.clicks, 'after the swap: used, no second button, same place and clicks', mb);
|
||||||
|
st = await ADM('/api/admin/status'); ok(st.progress === before.progress && st.loop.ids[2] === Xa.bid, 'the swap leaves the bar and the loop order alone', { p: [before.progress, st.progress], loop: st.loop.ids });
|
||||||
|
let sp = await anon.json('/api/splash'); const tA = sp.loop.find(t => t.id === Xa.bid);
|
||||||
|
ok(tA && tA.img === nu.img, 'the splash shows the new image at once', tA);
|
||||||
|
r = await anon.req('/go/' + Xa.bid); ok(r.status === 302 && r.headers.get('location') === 'https://swapped-member.com/new', 'clicks go to the new link', r.headers.get('location'));
|
||||||
|
r = await Xa.json('/api/my/banners/' + Xa.bid + '/swap', { link: 'https://third-try.com/' }); ok(r._status === 400 && /already used its one swap/.test(r.error), 'a second swap is refused', r);
|
||||||
|
let ab = await ADM('/api/admin/banners?q=%23' + Xa.bid);
|
||||||
|
ok(ab.banners && ab.banners[0].swaps.length === 1 && ab.banners[0].swaps[0].old.link === before.link && ab.banners[0].swaps[0].new.link === 'https://swapped-member.com/new' && ab.banners[0].swaps[0].old.img === before.img && ab.banners[0].swaps[0].at > 0,
|
||||||
|
'the swap is logged on the banner (old + new link and image, time)', ab.banners && ab.banners[0].swaps);
|
||||||
|
// a waiting banner can swap its link only, and keeps its number in line
|
||||||
|
my = await Xq.json('/api/my'); mb = my.banners.find(b => b.id === Xq.bid); const qpos = mb.position;
|
||||||
|
r = await Xq.json('/api/my/banners/' + Xq.bid + '/swap', { link: 'https://queued-swap.com/' });
|
||||||
|
my = await Xq.json('/api/my'); mb = my.banners.find(b => b.id === Xq.bid);
|
||||||
|
ok(r.ok && mb.state === 'queued' && mb.position === qpos && mb.link === 'https://queued-swap.com/' && mb.swapUsed, 'a waiting banner swaps its link only and keeps its number in line', mb);
|
||||||
|
// a Banner Spin swaps to another of the member's own spins
|
||||||
|
const SPX = await walletMember(); await SPX.json('/api/my');
|
||||||
|
LSA.set(SPX.address, { username: 'spinswap', spins: [{ id: 41, name: 'First', code: 'qk7swp01', size: '125x125', paused: false, banners: 1 }, { id: 42, name: 'Second', code: 'qk7swp02', size: '250x250', paused: false, banners: 1 }, { id: 43, name: 'Wide', code: 'qk7swp03', size: '468x60', paused: false, banners: 1 }] });
|
||||||
|
const spb = await SPX.json('/api/my/banners', { spinId: 41 });
|
||||||
|
r = await SPX.json('/api/my/banners/' + spb.banner.id + '/swap', { spinId: 41 }); ok(r._status === 400 && /already shows/.test(r.error), 'swap to the same Banner Spin is refused', r);
|
||||||
|
r = await SPX.json('/api/my/banners/' + spb.banner.id + '/swap', { spinId: 43 }); ok(r._status === 400 && /125x125/.test(r.error), 'swap to a 468x60 spin is refused', r);
|
||||||
|
r = await SPX.json('/api/my/banners/' + spb.banner.id + '/swap', { link: 'https://half-swap.com/' }); ok(r._status === 400 && /Banner Spin/.test(r.error), 'a Banner Spin cannot swap its link alone', r);
|
||||||
|
r = await SPX.json('/api/my/banners/' + spb.banner.id + '/swap', { spinId: 42 });
|
||||||
|
my = await SPX.json('/api/my'); mb = my.banners.find(b => b.id === spb.banner.id);
|
||||||
|
ok(r.ok && mb.img.includes('qk7swp02') && mb.link.includes('/c/qk7swp02') && mb.spin && mb.spin.name === 'Second' && mb.swapUsed, 'a Banner Spin swaps to another of the member\'s own spins', mb);
|
||||||
|
|
||||||
|
// -- the takedown (credit back), the place stays
|
||||||
|
st = await ADM('/api/admin/status'); const loop0 = st.loop.ids.slice(); const T = Xt.bid; const ti = loop0.indexOf(T);
|
||||||
|
let tl = await ADM('/api/admin/member-lookup?q=%23' + T); const cr0 = tl.credits;
|
||||||
|
r = await anon.json('/api/admin/banners/' + T + '/takedown', { reason: 'Broken page', credit: 'back' }); ok(r._status === 401, 'takedown needs the admin token', r);
|
||||||
|
r = await ADM('/api/admin/banners/' + T + '/takedown', { credit: 'back' }); ok(r._status === 400 && /reason is required/.test(r.error), 'takedown without a reason is refused', r);
|
||||||
|
r = await ADM('/api/admin/banners/' + T + '/takedown', { reason: 'Broken landing page' }); ok(r._status === 400 && /credit/.test(r.error), 'takedown without the credit choice is refused', r);
|
||||||
|
r = await ADM('/api/admin/banners/' + T + '/takedown', { reason: 'Broken landing page', credit: 'back', by: 'marty' });
|
||||||
|
ok(r.ok && r.banner.down && r.banner.down.creditBack === true && r.ownerCredits === cr0 + 1, 'takedown with credit back: the owner gets the post credit', r);
|
||||||
|
r = await ADM('/api/admin/banners/' + T + '/takedown', { reason: 'again', credit: 'none' }); ok(r._status === 400 && /already/.test(r.error), 'a banner cannot be taken down twice', r);
|
||||||
|
sp = await anon.json('/api/splash');
|
||||||
|
ok(ids(sp)[ti] === 'h' + T && sp.loop[ti].house === true && !sp.loop.some(t => t.id === T) && !JSON.stringify(sp.loop).includes('"/go/' + T + '"'), 'the splash shows a house tile in its place, never the banner', sp.loop[ti]);
|
||||||
|
ok(JSON.stringify(ids(sp).filter((x, i) => i !== ti)) === JSON.stringify(loop0.filter((x, i) => i !== ti).map(String)), 'every other banner keeps its place', { before: loop0, after: ids(sp) });
|
||||||
|
ok(!sp.loop[ti].owner && sp.loop[ti].img === '/art/tile-house.svg', 'the house tile carries no owner, image or link of the banner', sp.loop[ti]);
|
||||||
|
r = await anon.req('/art/tile-house.svg'); ok(r.status === 200, 'the house tile image is served');
|
||||||
|
r = await anon.req('/go/' + T); ok(r.status === 302 && r.headers.get('location') === '/', 'its click relay goes home, not to the banner link', r.headers.get('location'));
|
||||||
|
my = await Xt.json('/api/my'); mb = my.banners.find(b => b.id === T);
|
||||||
|
ok(mb.state === 'down' && mb.downReason === 'Broken landing page' && mb.creditBack === true && mb.canSwap === false && my.credits === cr0 + 1, 'My Banners shows it taken down with the reason and the credit back', mb);
|
||||||
|
r = await Xt.json('/api/my/banners/' + T + '/swap', { link: 'https://sneaky-swap.com/' }); ok(r._status === 400 && /taken down/.test(r.error), 'a taken-down banner cannot be swapped', r);
|
||||||
|
r = await Xt.json('/api/my/order', { sku: 3, ref: T }); ok(r._status === 400 && /taken down/.test(r.error), 'a taken-down banner cannot get the banner look', r);
|
||||||
|
// restore: back in its place, the credit taken back
|
||||||
|
r = await ADM('/api/admin/banners/' + T + '/restore', { reason: 'page fixed, my mistake' });
|
||||||
|
ok(r.ok && r.creditReversed === true && r.ownerCredits === cr0 && !r.banner.down, 'restore: the banner is back and the credit given back is taken back', r);
|
||||||
|
sp = await anon.json('/api/splash'); ok(ids(sp)[ti] === String(T), 'restore: the banner shows in its own place again', ids(sp));
|
||||||
|
r = await ADM('/api/admin/banners/' + T + '/restore', {}); ok(r._status === 400, 'restoring a banner that is not down is refused', r);
|
||||||
|
// a waiting banner taken down with no credit: the line keeps its numbers
|
||||||
|
st = await ADM('/api/admin/status'); const q0 = st.queue.next.slice(); const Q = q0[0];
|
||||||
|
tl = await ADM('/api/admin/member-lookup?q=%23' + Q); const qc0 = tl.credits;
|
||||||
|
r = await ADM('/api/admin/banners/' + Q + '/takedown', { reason: 'Adult content', credit: 'none' });
|
||||||
|
ok(r.ok && r.banner.down.creditBack === false && r.ownerCredits === qc0, 'takedown with no credit: the owner\'s credits do not change', r);
|
||||||
|
sp = await anon.json('/api/splash');
|
||||||
|
ok(sp.queue[0].id === 'h' + Q && sp.queue.slice(1).map(t => t.id).join() === q0.slice(1, sp.queue.length).join(), 'the waiting line shows a house tile; nobody behind it moves', sp.queue.map(t => t.id));
|
||||||
|
// the back banner taken down rides out on time but never cycles or earns
|
||||||
|
st = await ADM('/api/admin/status'); const L = st.loop.nextOut; const cyc0 = st.totals.cycles; const led0 = (await ADM('/api/admin/ledger?n=2000')).entries.filter(e => e.bannerId === L).length;
|
||||||
|
r = await ADM('/api/admin/banners/' + L + '/takedown', { reason: 'Malware report', credit: 'none' }); ok(r.ok, 'the next-out banner is taken down', r);
|
||||||
|
const qBefore = st.queue.next.slice();
|
||||||
|
ok(await shiftOnce(), 'the loop shifts as usual');
|
||||||
|
st = await ADM('/api/admin/status'); ab = await ADM('/api/admin/banners?q=%23' + L);
|
||||||
|
ok(!st.loop.ids.includes(L) && ab.banners[0].state === 'ended' && st.totals.cycles === cyc0, 'its place rode out on time: state ended, no cycle counted', { state: ab.banners[0].state, cyc: [cyc0, st.totals.cycles] });
|
||||||
|
ok((await ADM('/api/admin/ledger?n=2000')).entries.filter(e => e.bannerId === L).length === led0, 'no network views recorded for it');
|
||||||
|
ok(st.loop.ids[0] === qBefore[0], 'the next waiting banner (the house tile of #' + qBefore[0] + ' too) entered at the front as usual', { loop: st.loop.ids, q: qBefore });
|
||||||
|
// restoring after it rode out records the cycle it would have had
|
||||||
|
r = await ADM('/api/admin/banners/' + L + '/restore', { reason: 'report was wrong' });
|
||||||
|
ok(r.ok && r.cycle && r.cycle.bannerId === L && r.cycle.note === 'restored' && r.banner.state === 'cycled', 'restore after it rode out: the cycle is recorded then', r);
|
||||||
|
r = await ADM('/api/admin/banners/' + Q + '/restore', {}); ok(r.ok && r.creditReversed === false && !r.banner.down, 'restore with no credit given: nothing to take back', r);
|
||||||
|
const acts = await ADM('/api/admin/actions');
|
||||||
|
const kinds = acts.actions.map(a => a.action + ':' + a.bannerId + ':' + a.credit);
|
||||||
|
ok(acts.actions.length === 6 && acts.actions.every(a => a.at > 0 && a.by && a.id) && kinds.includes('takedown:' + T + ':back') && kinds.includes('takedown:' + Q + ':none') && kinds.includes('restore:' + T + ':taken back')
|
||||||
|
&& acts.actions.find(a => a.action === 'takedown' && a.bannerId === T).reason === 'Broken landing page' && acts.actions.find(a => a.bannerId === T && a.action === 'takedown').by === 'marty',
|
||||||
|
'the admin ledger logs who, when, reason and the credit decision', acts.actions);
|
||||||
|
ab = await ADM('/api/admin/banners?q=%23' + T); ok(ab.banners[0].downs.length === 1 && ab.banners[0].downs[0].creditReversed === true, 'the banner keeps its takedown history', ab.banners[0].downs);
|
||||||
|
ab = await ADM('/api/admin/banners?q=' + Xa.address); ok(ab.banners && ab.banners.length === 1 && ab.banners[0].id === Xa.bid, 'admin finds banners by wallet', ab);
|
||||||
|
r = await ADM('/api/admin/banners?q=nobody-here-zz'); ok(r._status === 404, 'admin: no banner found answers 404');
|
||||||
|
r = await anon.req('/admin'); const ah2 = await r.text(); ok(/id="bnCard"/.test(ah2) && /id="aActions"/.test(ah2), 'the admin page has the takedown card and the admin ledger');
|
||||||
|
if (!process.env.SKIP_UI && fs.existsSync(PW)) {
|
||||||
|
const { chromium } = require(PW); const browser = await chromium.launch(); const errs = [];
|
||||||
|
const ctx = await browser.newContext({ viewport: { width: 390, height: 900 }, userAgent: 'Mozilla/5.0 (iPhone) AppleWebKit/605.1.15 Mobile Safari SmokeUI-swap' });
|
||||||
|
const pg = await ctx.newPage(); pg.on('pageerror', e => errs.push(e.message));
|
||||||
|
await ctx.addCookies([{ name: 'vbb.sid', value: Xt.jar['vbb.sid'], url: BASE }]);
|
||||||
|
await pg.goto(BASE + '/my', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('.swap-row button', { timeout: 8000 }).catch(() => {});
|
||||||
|
ok((await pg.textContent('.swap-row button').catch(() => '')) === 'Swap image or link', 'My Banners (phone): the "Swap image or link" button shows');
|
||||||
|
await pg.click('.swap-row button'); ok(await pg.isVisible('.swap-box .sw-link'), 'tapping it opens the swap form');
|
||||||
|
await pg.fill('.swap-box .sw-link', 'https://ui-swapped.com/'); await pg.click('.swap-box .sw-go');
|
||||||
|
await pg.waitForFunction(() => /Swap used/.test(document.querySelector('#mine').textContent), null, { timeout: 8000 }).catch(() => {});
|
||||||
|
ok(/Swap used/.test(await pg.textContent('#mine')) && /Swapped\. Banner #/.test(await pg.textContent('#status')), 'the swap goes through and the button turns into "Swap used"');
|
||||||
|
ok((await pg.evaluate(() => document.documentElement.scrollWidth)) <= 390, 'no sideways scroll on a phone');
|
||||||
|
await pg.screenshot({ path: path.join(OUT, 'my-swap.png'), fullPage: true });
|
||||||
|
await ADM('/api/admin/banners/' + T + '/takedown', { reason: 'Adult content', credit: 'none' });
|
||||||
|
await pg.goto(BASE + '/my', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('.pill.down', { timeout: 8000 }).catch(() => {});
|
||||||
|
ok(/Taken down/i.test(await pg.textContent('#mine')) && /Adult content/.test(await pg.textContent('#mine')), 'My Banners shows "Taken down" with the reason');
|
||||||
|
await pg.screenshot({ path: path.join(OUT, 'my-down.png'), fullPage: true });
|
||||||
|
ok(errs.length === 0, 'no page errors (swap)', errs);
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('16. network hub events (sign out everywhere, block, erase end sessions here)');
|
||||||
|
{ const admin = (p, body) => client().json(p, body, { 'x-admin-token': ADMIN }); let hseq = 900000;
|
||||||
|
const signAs = async w => { const c = client(); NET.add(w.address.toLowerCase()); const ch = await c.json('/api/auth/challenge', { address: w.address });
|
||||||
|
const v = await c.json('/api/auth/verify', { address: w.address, signature: await w.signMessage(ch.message) });
|
||||||
|
c.address = w.address.toLowerCase(); c.wallet = w; c.hubId = hubId(c.address); c.ok = v.ok === true && !!c.jar['vbb.sid']; return c; };
|
||||||
|
const walletMember = o => signAs((o && o.wallet) || ethers.Wallet.createRandom()); const signedIn = async c => (await c.json('/api/me')).signedIn === true;
|
||||||
|
const hook = async (events, o = {}) => { const raw = JSON.stringify({ events }); const ts = String(o.ts || Date.now());
|
||||||
|
const sig = o.sig || crypto.createHmac('sha256', o.secret || HUB_SECRET).update(ts + '\n' + raw).digest('hex');
|
||||||
|
const r = await fetch(BASE + '/api/hub/events', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Hub-Ts': ts, 'X-Hub-Sig': sig }, body: raw }); return r.status; };
|
||||||
|
const ev = (type, personId, data, at) => ({ seq: ++hseq, at: at || Date.now(), type, personId, data: data || {} });
|
||||||
|
const H1 = await walletMember({ hub: { username: 'hookone' } }); const H1b = await walletMember({ wallet: H1.wallet }); const H2 = await walletMember({ hub: { username: 'hooktwo' } });
|
||||||
|
const H3 = await walletMember({ hub: { username: 'hookthree' } }); const H4 = await walletMember({ hub: { username: 'hookfour' } });
|
||||||
|
ok(H1.ok && H1b.ok && H2.ok && H3.ok && H4.ok && await signedIn(H1) && await signedIn(H1b), 'setup: hub members signed in here (one of them in two browsers)');
|
||||||
|
ok(await hook([ev('member.signedout', H1.hubId)], { secret: 'x'.repeat(40) }) === 401 && await hook([ev('member.signedout', H1.hubId)], { ts: Date.now() - 600000 }) === 401, 'a hook signed with another key, or 10 minutes old, is refused (401)');
|
||||||
|
ok(await signedIn(H1), 'a refused hook ends nothing');
|
||||||
|
const so = ev('member.signedout', H1.hubId);
|
||||||
|
ok(await hook([so]) === 200 && !(await signedIn(H1)) && !(await signedIn(H1b)) && await signedIn(H2), 'member.signedout: every session of that wallet ends (both browsers), nobody else\'s');
|
||||||
|
const H1c = await walletMember({ wallet: H1.wallet });
|
||||||
|
ok(await hook([so]) === 200 && await signedIn(H1c), 'the same event sent twice: applied once, a fresh sign-in stays');
|
||||||
|
ok(await hook([ev('member.signedout', H1.hubId, {}, Date.now() - 60000)]) === 200 && await signedIn(H1c), 'an event older than a session never ends it (only sessions made before the event)');
|
||||||
|
ok(await hook([ev('member.blocked', H2.hubId)]) === 200 && !(await signedIn(H2)) && await signedIn(H3), 'member.blocked: that member is signed out here');
|
||||||
|
const wh = crypto.createHash('sha256').update(H3.address).digest('hex'); NET.delete(H3.address);
|
||||||
|
ok(await hook([ev('member.erased', H3.hubId, { emailHash: 'a'.repeat(64), walletHashes: [wh] })]) === 200 && !(await signedIn(H3)) && await signedIn(H4), 'member.erased: found by the wallet hash in the event (the hub no longer knows them), signed out');
|
||||||
|
ok(await hook([ev('member.joined', H4.hubId), ev('member.signedout', 'h_' + 'f'.repeat(16))]) === 200 && await signedIn(H4), 'other events and unknown people are ignored');
|
||||||
|
HUB.down = true; const late = ev('member.signedout', H4.hubId);
|
||||||
|
ok(await hook([late]) === 503 && await signedIn(H4), 'the hub lookup failing answers 503 (the hub sends it again), nothing ended');
|
||||||
|
HUB.down = false; ok(await hook([late]) === 200 && !(await signedIn(H4)), 'resent once the hub answers: signed out');
|
||||||
|
const E1 = await walletMember({ hub: { username: 'hookfive' } }); const E2 = await walletMember({ wallet: E1.wallet }); const g0 = HUB.got.length;
|
||||||
|
const eo = await E1.json('/api/auth/logout-everywhere', {});
|
||||||
|
const call = HUB.got.slice(g0).find(x => x.route === '/v1/sso/signout');
|
||||||
|
ok(eo.ok && eo.everywhere === true && !(await signedIn(E1)) && !(await signedIn(E2)) && call && call.body.wallet === E1.address, 'Sign out everywhere: the hub is told (signed, by wallet) and every session of that wallet here ends', { eo, call });
|
||||||
|
ok(/id="outAllBtn"[^>]*>Sign out everywhere</.test(await (await client().req('/my')).text()), '/my has a Sign out everywhere button next to Sign out');
|
||||||
|
const st2 = await admin('/api/admin/status');
|
||||||
|
ok(st2.hubEvents && st2.hubEvents.on && st2.hubEvents.stats.ended >= 5 && st2.hubEvents.stats.refused >= 2 && !JSON.stringify(st2.hubEvents).includes(HUB_SECRET), 'admin status shows the hub events (counts only, no secret)', st2.hubEvents);
|
||||||
|
}
|
||||||
|
|
||||||
await stop();
|
await stop();
|
||||||
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
||||||
fs.writeFileSync(path.join(OUT, 'smoke.txt'), new Date().toISOString() + ' ' + pass + ' passed, ' + fail + ' failed\n');
|
fs.writeFileSync(path.join(OUT, 'smoke.txt'), new Date().toISOString() + ' ' + pass + ' passed, ' + fail + ' failed\n');
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// Network Weekend checks (Marty 2026-11-17): node qa/weekend.test.mjs. No network: a stand-in Polygon RPC for skus().
|
||||||
|
// Every date gate runs on the WEEKEND_NOW test clock, never the machine clock.
|
||||||
|
import http from 'node:http'; import os from 'node:os'; import fs from 'node:fs'; import path from 'node:path';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const { Interface } = require('ethers');
|
||||||
|
let pass = 0, fail = 0; const ok = (c, m) => { if (c) pass++; else { fail++; console.log('FAIL', m); } };
|
||||||
|
process.env.DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'vbbwk-')); delete process.env.DOCSTORE_URL; process.env.NETKB = '0'; delete process.env.OPENROUTER_API_KEY;
|
||||||
|
const I = new Interface(['function skus(uint256) view returns (uint64 usdCents, uint64 units, bool active)']);
|
||||||
|
const SKUS = { 1: [300, 10, true], 2: [1000, 40, true], 3: [200, 0, true] }; let down = false;
|
||||||
|
const rpc = http.createServer((q, r) => { let b = ''; q.on('data', c => { b += c; }); q.on('end', () => { const j = JSON.parse(b);
|
||||||
|
if (down) { r.writeHead(500); return r.end('x'); }
|
||||||
|
const sku = Number(I.decodeFunctionData('skus', j.params[0].data)[0]);
|
||||||
|
r.setHeader('Content-Type', 'application/json'); r.end(JSON.stringify({ jsonrpc: '2.0', id: j.id, result: I.encodeFunctionResult('skus', SKUS[sku] || [0, 0, false]) })); }); });
|
||||||
|
await new Promise(r => rpc.listen(0, r));
|
||||||
|
process.env.CHAIN_RPC = 'http://127.0.0.1:' + rpc.address().port; process.env.CONTRACT_ADDRESS = '0x00000000000000000000000000000000000B0B05';
|
||||||
|
const C = require('../config.js').get();
|
||||||
|
const weekend = require('../weekend.js'); const chainskus = require('../chainskus.js'); const netdeals = require('../netdeals.js');
|
||||||
|
const at = iso => { process.env.WEEKEND_NOW = iso; };
|
||||||
|
|
||||||
|
// 1. the date gate, exact Central midnights both ways
|
||||||
|
for (const [iso, want] of [['2026-11-26T18:00:00-06:00', false], ['2026-11-26T23:59:59-06:00', false], ['2026-11-27T00:00:00-06:00', true], ['2026-11-28T12:00:00-06:00', true],
|
||||||
|
['2026-11-30T23:59:59-06:00', true], ['2026-12-01T00:00:00-06:00', false], ['2026-12-02T09:00:00-06:00', false]]) {
|
||||||
|
at(iso); ok(weekend.on() === want, 'on() at ' + iso + ' = ' + want); ok(weekend.freePerDay(1) === (want ? 2 : 1), 'free credits at ' + iso);
|
||||||
|
}
|
||||||
|
ok(C.freeCreditsPerDay === 1, 'the setting stays 1 (FREE_CREDITS_PER_DAY untouched)');
|
||||||
|
|
||||||
|
// 2. live SKU values: env until the first read, then the chain; RPC down keeps the last good read
|
||||||
|
chainskus.init(C, [1, 2, 3]); ok(chainskus.packs(C)[1].credits === 40, 'env 40 before/at first read');
|
||||||
|
await chainskus.refresh(); ok(chainskus.packs(C)[1].credits === 40 && chainskus.packs(C)[1].usd === 10, 'chain 40 for $10');
|
||||||
|
SKUS[2] = [1000, 50, true]; await chainskus.refresh(); ok(chainskus.packs(C)[1].credits === 50, 'owner set 50: pages show 50');
|
||||||
|
ok(chainskus.packs(C)[0].credits === 10 && chainskus.packs(C)[0].usd === 3, '$3 pack untouched');
|
||||||
|
down = true; await chainskus.refresh(); ok(chainskus.packs(C)[1].credits === 50, 'RPC down: last good read stays'); down = false;
|
||||||
|
SKUS[2] = [1000, 40, false]; await chainskus.refresh(); ok(chainskus.packs(C)[1].credits === 40, 'inactive SKU on chain: env values');
|
||||||
|
|
||||||
|
// 3. the ribbon line follows the chain and the clock; nothing wrong if the signature is late
|
||||||
|
const deal = { site: 'vbb', name: 'Viral Banner Blitz', text: 'hub text', byDay: { x: 'y' } };
|
||||||
|
SKUS[2] = [1000, 40, true]; await chainskus.refresh();
|
||||||
|
at('2026-11-20T12:00:00-06:00'); ok(weekend.dealLine(C, deal) === null, 'before: no VBB line');
|
||||||
|
at('2026-11-27T00:05:00-06:00'); let d = weekend.dealLine(C, deal);
|
||||||
|
ok(d && d.text === 'Network members get 2 free post credits a day.' && !d.byDay, 'late signature: free credits only, no 50: ' + (d && d.text));
|
||||||
|
SKUS[2] = [1000, 50, true]; await chainskus.refresh(); d = weekend.dealLine(C, deal);
|
||||||
|
ok(d && d.text === 'The $10 pack carries 50 credits instead of 40, and network members get 2 free post credits a day.', 'signed: ' + (d && d.text));
|
||||||
|
at('2026-12-01T00:00:00-06:00'); d = weekend.dealLine(C, deal); ok(d && /50 credits/.test(d.text) && !/free/.test(d.text), 'revert not signed yet Tuesday: the line says what the chain charges');
|
||||||
|
netdeals.setLocal(x => weekend.dealLine(C, x));
|
||||||
|
netdeals._set({ events: [{ id: 'e', name: 'Network Weekend', startsAt: '2026-11-27T06:00:00.000Z', endsAt: '2026-12-01T06:00:00.000Z', deals: [deal, { site: 'dlb', name: 'DLB', text: 't' }] }] });
|
||||||
|
let body = ''; const res = { writeHead() {}, end(s) { body = s; } }; SKUS[2] = [1000, 40, true]; await chainskus.refresh(); at('2026-11-20T00:00:00-06:00');
|
||||||
|
netdeals.handle({}, res, 'vbb'); ok(JSON.parse(body).events[0].deals.map(x => x.site).join() === 'dlb', 'feed: VBB line dropped when there is nothing true to say');
|
||||||
|
|
||||||
|
// 4. chatbot: live packs and the weekend fact only inside the window
|
||||||
|
const bot = require('../chatbot.js');
|
||||||
|
at('2026-11-20T12:00:00-06:00'); ok(!/NETWORK WEEKEND/.test(bot.FACTS()), 'no weekend fact before');
|
||||||
|
ok(/1 free post credit each day/.test(bot.FACTS()), 'normal free credit fact');
|
||||||
|
SKUS[2] = [1000, 50, true]; await chainskus.refresh(); at('2026-11-28T09:00:00-06:00');
|
||||||
|
const F = bot.FACTS(); ok(/NETWORK WEEKEND/.test(F) && /50 credits instead of 40/.test(F) && /2 free post credits/.test(F), 'weekend fact from live values');
|
||||||
|
ok(/40 post credits for \$10/.test(bot.render('x 10 post credits for $3 or 40 post credits for $10 y')) === false && /50 post credits for \$10/.test(bot.render('10 post credits for $3 or 40 post credits for $10')), 'canned packs rendered live');
|
||||||
|
ok(/get 2 free post credits each day they sign in during Network Weekend/.test(bot.render('Network members get one free post credit each day they sign in.')), 'canned free credit rendered for the weekend');
|
||||||
|
at('2026-12-01T00:00:01-06:00'); ok(bot.render('get one free post credit each day they sign in') === 'get one free post credit each day they sign in', 'after: canned free credit unchanged');
|
||||||
|
ok(!/\u2014/.test(F) && !/up to/i.test(F.split('\n').find(l => /WEEKEND/.test(l))), 'no em dashes, no up-to in the weekend fact');
|
||||||
|
rpc.close(); console.log('weekend: ' + pass + ' passed, ' + fail + ' failed'); process.exit(fail ? 1 : 0);
|
||||||
@@ -69,11 +69,15 @@ function privateIp(ip) {
|
|||||||
if (s.startsWith('::ffff:')) return privateIp(s.slice(7));
|
if (s.startsWith('::ffff:')) return privateIp(s.slice(7));
|
||||||
return s === '::' || s === '::1' || s.startsWith('fc') || s.startsWith('fd') || s.startsWith('fe80') || s.startsWith('ff');
|
return s === '::' || s === '::1' || s.startsWith('fc') || s.startsWith('fd') || s.startsWith('fe80') || s.startsWith('ff');
|
||||||
}
|
}
|
||||||
|
// Node 20's https agent asks for every address (opts.all, for happy eyeballs) and expects an array back; answering with one
|
||||||
|
// address broke every link check (2026-11-15: no text ad could be posted). Answer in the shape asked for, private ones refused.
|
||||||
function safeLookup(host, opts, cb) {
|
function safeLookup(host, opts, cb) {
|
||||||
dns.lookup(host, Object.assign({}, opts, { all: false }), (err, addr, fam) => {
|
if (typeof opts === 'function') { cb = opts; opts = {}; }
|
||||||
|
dns.lookup(host, Object.assign({}, opts, { all: true }), (err, list) => {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (privateIp(addr)) return cb(new Error('private address'));
|
if (!list.length || list.some(a => privateIp(a.address))) return cb(new Error('private address'));
|
||||||
cb(null, addr, fam);
|
if (opts && opts.all) return cb(null, list);
|
||||||
|
cb(null, list[0].address, list[0].family);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// GET with a size cap, a timeout and no redirects followed (a redirect is reported so the caller can decide)
|
// GET with a size cap, a timeout and no redirects followed (a redirect is reported so the caller can decide)
|
||||||
|
|||||||
@@ -21,8 +21,15 @@ const safety = require('./safety');
|
|||||||
const networksso = require('./networksso');
|
const networksso = require('./networksso');
|
||||||
const shop = require('./shop');
|
const shop = require('./shop');
|
||||||
const promokit = require('./promokit'); // promo kit feed /api/promo-kit + the /promote page (2026-11-14)
|
const promokit = require('./promokit'); // promo kit feed /api/promo-kit + the /promote page (2026-11-14)
|
||||||
|
const chatbot = require('./chatbot'); // the site assistant (2026-11-15): chatcore.js + kb.js + the network knowledge base (netkb.js)
|
||||||
const hubreport = require('./hubreport'); // network hub report by wallet (off unless HUB_ENABLED)
|
const hubreport = require('./hubreport'); // network hub report by wallet (off unless HUB_ENABLED)
|
||||||
const prize = require('./prize');
|
const prize = require('./prize');
|
||||||
|
const proof = require('./proof'); // trust pack: /ledger, /contract, Telegram card per purchase + line per prize payout (2026-11-14)
|
||||||
|
const netsites = require('./netsites'); // footer network list from the hub (2026-11-14)
|
||||||
|
const netdeals = require('./netdeals'); // Network Weekend ribbon feed from the hub (2026-11-17)
|
||||||
|
const weekend = require('./weekend'); // Network Weekend date gate: 2 free credits a day, Fri 11-27 00:00 CT to Tue 12-01 00:00 CT
|
||||||
|
const chainskus = require('./chainskus'); // live VBBShop SKU credits and prices for every page and the chatbot (2026-11-17)
|
||||||
|
const lsspins = require('./lsspins'); // LinkSpin Banner Spins: post one as a banner, and fill the splash's open places (2026-11-14)
|
||||||
|
|
||||||
const PUB = path.join(__dirname, 'public');
|
const PUB = path.join(__dirname, 'public');
|
||||||
const UPL = path.join(C.dataDir, 'uploads');
|
const UPL = path.join(C.dataDir, 'uploads');
|
||||||
@@ -39,9 +46,9 @@ const hash = s => crypto.createHmac('sha256', SECRET).update(s).digest('hex').sl
|
|||||||
|
|
||||||
// ---- http helpers ----
|
// ---- http helpers ----
|
||||||
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'text/javascript', '.png': 'image/png', '.jpg': 'image/jpeg',
|
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'text/javascript', '.png': 'image/png', '.jpg': 'image/jpeg',
|
||||||
'.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml' };
|
'.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml', '.mp4': 'video/mp4', '.webm': 'video/webm' };
|
||||||
const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://linkspin.app; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; "
|
const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://linkspin.app https://polhunter.com; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; "
|
||||||
+ "img-src 'self' data: blob: https:; connect-src 'self' https://linkspin.app https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org "
|
+ "img-src 'self' data: blob: https:; connect-src 'self' https://linkspin.app https://polhunter.com https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org "
|
||||||
+ "https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com; "
|
+ "https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com; "
|
||||||
+ "font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: 'self'";
|
+ "font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: 'self'";
|
||||||
function headers(extra) { return Object.assign({ 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin' }, extra || {}); }
|
function headers(extra) { return Object.assign({ 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin' }, extra || {}); }
|
||||||
@@ -54,6 +61,19 @@ function sendFile(res, file, extra) {
|
|||||||
res.end(data);
|
res.end(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// video needs byte ranges (Safari will not play it without them); tutorial videos 2026-11-18
|
||||||
|
function sendMedia(req, res, file) {
|
||||||
|
fs.stat(file, (err, st) => {
|
||||||
|
if (err || !st.isFile()) { res.writeHead(404, headers({ 'Content-Type': 'text/plain' })); return res.end('Not found'); }
|
||||||
|
const base = { 'Content-Type': MIME[path.extname(file).toLowerCase()], 'Accept-Ranges': 'bytes', 'Cache-Control': 'public, max-age=86400' };
|
||||||
|
const m = /^bytes=(\d*)-(\d*)$/.exec(req.headers.range || '');
|
||||||
|
if (!m || (!m[1] && !m[2])) { res.writeHead(200, headers(Object.assign(base, { 'Content-Length': st.size }))); return fs.createReadStream(file).pipe(res); }
|
||||||
|
let a = m[1] ? +m[1] : Math.max(0, st.size - +m[2]), b = m[1] && m[2] ? Math.min(+m[2], st.size - 1) : st.size - 1;
|
||||||
|
if (a > b || a >= st.size) { res.writeHead(416, headers({ 'Content-Range': 'bytes */' + st.size })); return res.end(); }
|
||||||
|
res.writeHead(206, headers(Object.assign(base, { 'Content-Range': 'bytes ' + a + '-' + b + '/' + st.size, 'Content-Length': b - a + 1 })));
|
||||||
|
fs.createReadStream(file, { start: a, end: b }).pipe(res);
|
||||||
|
});
|
||||||
|
}
|
||||||
function readRaw(req, max) {
|
function readRaw(req, max) {
|
||||||
return new Promise((resolve, reject) => { const ch = []; let n = 0;
|
return new Promise((resolve, reject) => { const ch = []; let n = 0;
|
||||||
req.on('data', c => { n += c.length; if (n > max * 8) { req.destroy(); return; } if (n <= max) ch.push(c); });
|
req.on('data', c => { n += c.length; if (n > max * 8) { req.destroy(); return; } if (n <= max) ch.push(c); });
|
||||||
@@ -89,6 +109,7 @@ const isAdmin = req => { const t = String(process.env.ADMIN_TOKEN || ''); const
|
|||||||
// The network hub answers first (hubpeople.js, signed as vbb, cached 5 minutes); InstantAdPay's /api/network/member only when
|
// The network hub answers first (hubpeople.js, signed as vbb, cached 5 minutes); InstantAdPay's /api/network/member only when
|
||||||
// the hub is unreachable. A person the hub does not know is unknown here too (never "verified" on InstantAdPay's word alone).
|
// the hub is unreachable. A person the hub does not know is unknown here too (never "verified" on InstantAdPay's word alone).
|
||||||
const hubpeople = require('./hubpeople');
|
const hubpeople = require('./hubpeople');
|
||||||
|
const hubevents = require('./hubevents'); // network hub hook (2026-11-16): sign-out-everywhere, block and erase end sessions here
|
||||||
const netCache = new Map();
|
const netCache = new Map();
|
||||||
async function netMember(q) {
|
async function netMember(q) {
|
||||||
const h = q.u ? await hubpeople.byRef(q.u) : await hubpeople.byWallet(q.a);
|
const h = q.u ? await hubpeople.byRef(q.u) : await hubpeople.byWallet(q.a);
|
||||||
@@ -156,21 +177,27 @@ function grantDaily(m) {
|
|||||||
if (!netVerified(m)) return false;
|
if (!netVerified(m)) return false;
|
||||||
const day = store.ctDay(); if (m.freeDay === day) return false;
|
const day = store.ctDay(); if (m.freeDay === day) return false;
|
||||||
m.freeDay = day; let granted = false;
|
m.freeDay = day; let granted = false;
|
||||||
const add = Math.min(C.freeCreditsPerDay, Math.max(0, C.freeCreditCap - m.credits));
|
const add = Math.min(weekend.freePerDay(C.freeCreditsPerDay), Math.max(0, C.freeCreditCap - m.credits));
|
||||||
if (add > 0) { m.credits += add; granted = true; }
|
if (add > 0) { m.credits += add; granted = true; }
|
||||||
store.save(); return granted;
|
store.save(); return granted;
|
||||||
}
|
}
|
||||||
function myData(addr) {
|
function myData(addr) {
|
||||||
const m = store.member(addr);
|
const m = store.member(addr);
|
||||||
const banners = store.bannersOf(addr).slice().reverse().map(b => Object.assign({ id: b.id, img: b.img, link: b.link, createdAt: b.createdAt, cycledAt: b.cycledAt || null, clicks: b.clicks || 0,
|
const banners = store.bannersOf(addr).slice().reverse().map(b => Object.assign({ id: b.id, img: b.img, link: b.link, createdAt: b.createdAt, cycledAt: b.cycledAt || null, clicks: b.clicks || 0,
|
||||||
look: !!b.look, teaser: b.look ? (b.teaser || '') : '', teaserDefault: loop.hostOf(b.link) }, loop.placeOf(b)));
|
look: !!b.look, teaser: b.look ? (b.teaser || '') : '', teaserDefault: b.spin ? b.spin.name : loop.hostOf(b.link), spin: b.spin ? { name: b.spin.name, size: b.spin.size } : null,
|
||||||
|
swapUsed: swapUsed(b), swappedAt: swapUsed(b) ? b.swaps[b.swaps.length - 1].at : null, canSwap: canSwap(b) }, loop.memberPlace(b)));
|
||||||
const rewards = store.ledger().filter(e => e.owner === m.address);
|
const rewards = store.ledger().filter(e => e.owner === m.address);
|
||||||
const shareName = m.username || m.address;
|
const shareName = m.username || m.address;
|
||||||
return { address: m.address, username: m.username, credits: m.credits, freeCreditCap: C.freeCreditCap, freeToday: m.freeDay === store.ctDay(), netVerified: netVerified(m),
|
return { address: m.address, username: m.username, credits: m.credits, freeCreditCap: C.freeCreditCap, freePerDay: weekend.freePerDay(C.freeCreditsPerDay), freeToday: m.freeDay === store.ctDay(), netVerified: netVerified(m),
|
||||||
maxQueued: C.maxQueuedPerMember, banners, rewards: rewards.slice(-50).reverse(), rewardViews: rewards.reduce((t, e) => t + e.views, 0),
|
maxQueued: C.maxQueuedPerMember, banners, rewards: rewards.slice(-50).reverse(), rewardViews: rewards.reduce((t, e) => t + e.views, 0),
|
||||||
week: loop.memberWeek(m.address), share: 'https://' + C.site + '/?ref=' + encodeURIComponent(shareName) };
|
week: loop.memberWeek(m.address), share: 'https://' + C.site + '/?ref=' + encodeURIComponent(shareName) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// one swap per banner (Marty 2026-11-15: "allow the member to swap it only, and they can only do it one time"): image and/or link,
|
||||||
|
// while the banner is waiting or in the loop and not taken down. No withdraw, no removal, no refund for members.
|
||||||
|
const swapUsed = b => Array.isArray(b.swaps) && b.swaps.length > 0;
|
||||||
|
const canSwap = b => !swapUsed(b) && !b.down && (b.state === 'queued' || b.state === 'loop');
|
||||||
|
|
||||||
// ---- visit tickets: issued on page load, redeemed after the page has been visible for visitSeconds ----
|
// ---- visit tickets: issued on page load, redeemed after the page has been visible for visitSeconds ----
|
||||||
const tickets = new Map();
|
const tickets = new Map();
|
||||||
const srcHost = raw => { try { const u = new URL(String(raw || '')); if (!/^https?:$/.test(u.protocol)) return ''; const h = u.hostname.toLowerCase().replace(/^www\./, ''); return h === C.site || h.endsWith('.' + C.site) || !h.includes('.') ? '' : h.slice(0, 80); } catch (e) { return ''; } };
|
const srcHost = raw => { try { const u = new URL(String(raw || '')); if (!/^https?:$/.test(u.protocol)) return ''; const h = u.hostname.toLowerCase().replace(/^www\./, ''); return h === C.site || h.endsWith('.' + C.site) || !h.includes('.') ? '' : h.slice(0, 80); } catch (e) { return ''; } };
|
||||||
@@ -190,6 +217,8 @@ networksso.init({ self: 'vbb', peer: 'iap', peerBase: () => C.iapBase, from: { i
|
|||||||
return cookie('vbb.sid', store.mintSession(v.wallet), store.SESSION_TTL / 1000, true);
|
return cookie('vbb.sid', store.mintSession(v.wallet), store.SESSION_TTL / 1000, true);
|
||||||
},
|
},
|
||||||
landing: to => to, signinPath: to => to });
|
landing: to => to, signinPath: to => to });
|
||||||
|
// the hub's member.signedout / member.blocked / member.erased: that person's sessions here end (by any of their wallets)
|
||||||
|
hubevents.init({ dataDir: C.dataDir, site: 'vbb', end: who => store.endSessions(x => who.match(x) || who.match(store.member(x.address)), who.before) });
|
||||||
|
|
||||||
// old site links (2026-11-14, the Downline Banners pattern): the old YFW site's referral links were /?<old username>,
|
// old site links (2026-11-14, the Downline Banners pattern): the old YFW site's referral links were /?<old username>,
|
||||||
// /splashpg.php?pid=N&r=<old username> and /lcp.php?pid=N&r=<old username>. An old username maps to the same person's network
|
// /splashpg.php?pid=N&r=<old username> and /lcp.php?pid=N&r=<old username>. An old username maps to the same person's network
|
||||||
@@ -212,9 +241,11 @@ function oldLink(u) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// network ad zone on the 404 page (LinkSpin zone on Marty's account, 300x250; the page zones live in public/assets/common.js ZONES). '' = none
|
// network ad zone on the 404 page (LinkSpin zone on Marty's account, 300x250; the page zones live in public/assets/common.js ZONES). '' = none
|
||||||
const ZONE_404 = '';
|
const ZONE_404 = 'ls-d83484'; // LinkSpin zone "VBB not found" (2026-11-14)
|
||||||
|
|
||||||
const PAGES = { '/': 'index.html', '/my': 'my.html', '/leaders': 'leaders.html', '/how': 'how.html', '/packages': 'packages.html', '/admin': 'admin.html' };
|
const PAGES = { '/': 'index.html', '/my': 'my.html', '/leaders': 'leaders.html', '/how': 'how.html', '/packages': 'packages.html', '/admin': 'admin.html',
|
||||||
|
'/contract': 'contract.html', '/ledger': 'ledger.html', '/terms': 'terms.html', '/disclaimer': 'disclaimer.html', '/privacy': 'privacy.html', // trust pack 2026-11-14
|
||||||
|
'/guides': 'guides.html', '/guides/is-it-legit': 'guide-legit.html', '/guides/free-account': 'guide-free.html', '/guides/prize-boards': 'guide-prizes.html', '/guides/faq': 'guide-faq.html' }; // Guides (Marty 2026-11-17)
|
||||||
const challenges = new Map();
|
const challenges = new Map();
|
||||||
const clickSeen = new Map();
|
const clickSeen = new Map();
|
||||||
|
|
||||||
@@ -223,8 +254,10 @@ const server = http.createServer(async (req, res) => {
|
|||||||
{ const host = String(req.headers.host || '').toLowerCase().split(':')[0];
|
{ const host = String(req.headers.host || '').toLowerCase().split(':')[0];
|
||||||
if (C.isProd && host !== C.site && host.endsWith('.' + C.site)) { res.writeHead(301, { Location: 'https://' + C.site + req.url, 'Cache-Control': 'no-store' }); return res.end(); } }
|
if (C.isProd && host !== C.site && host.endsWith('.' + C.site)) { res.writeHead(301, { Location: 'https://' + C.site + req.url, 'Cache-Control': 'no-store' }); return res.end(); } }
|
||||||
try {
|
try {
|
||||||
|
if (req.method === 'GET' && await networksso.page(req, res, u)) return; // network hub: daily activity ping + the hub sign-in push (2026-11-15)
|
||||||
if (req.method === 'GET' && (p.startsWith('/sso/') || p === '/api/sso/status') && await networksso.handle(req, res, u)) return;
|
if (req.method === 'GET' && (p.startsWith('/sso/') || p === '/api/sso/status') && await networksso.handle(req, res, u)) return;
|
||||||
if ((p === '/api/promo-kit' || p === '/promote') && promokit.handle(req, res, u, sendFile)) return;
|
if ((p === '/api/promo-kit' || p === '/promote') && promokit.handle(req, res, u, sendFile)) return;
|
||||||
|
if ((p.startsWith('/api/chat') || p.startsWith('/api/admin/kb')) && await chatbot.handle(req, res, p, u, { json, readBody, isAdmin })) return;
|
||||||
|
|
||||||
if (req.method === 'GET' || req.method === 'HEAD') {
|
if (req.method === 'GET' || req.method === 'HEAD') {
|
||||||
if (p === '/health') return json(res, 200, { ok: true, store: docstore.isOn() ? 'mysql' : 'files' });
|
if (p === '/health') return json(res, 200, { ok: true, store: docstore.isOn() ? 'mysql' : 'files' });
|
||||||
@@ -239,13 +272,14 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (/^\/r\/[^/]+$/.test(p)) { res.writeHead(302, { Location: '/?ref=' + encodeURIComponent(decodeURIComponent(p.slice(3))) }); return res.end(); }
|
if (/^\/r\/[^/]+$/.test(p)) { res.writeHead(302, { Location: '/?ref=' + encodeURIComponent(decodeURIComponent(p.slice(3))) }); return res.end(); }
|
||||||
if (p === '/sitemap.xml') {
|
if (p === '/sitemap.xml') {
|
||||||
const day = new Date().toISOString().slice(0, 10);
|
const day = new Date().toISOString().slice(0, 10);
|
||||||
const urls = ['/', '/leaders', '/how', '/packages', '/promote'].map(x => '<url><loc>https://' + C.site + x + '</loc><lastmod>' + day + '</lastmod></url>').join('');
|
const urls = ['/', '/leaders', '/how', '/packages', '/promote', '/contract', '/ledger', '/guides', '/guides/is-it-legit', '/guides/free-account', '/guides/prize-boards', '/guides/faq', '/terms', '/disclaimer', '/privacy'].map(x => '<url><loc>https://' + C.site + x + '</loc><lastmod>' + day + '</lastmod></url>').join('');
|
||||||
res.writeHead(200, headers({ 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, max-age=3600' }));
|
res.writeHead(200, headers({ 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, max-age=3600' }));
|
||||||
return res.end('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + urls + '</urlset>');
|
return res.end('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + urls + '</urlset>');
|
||||||
}
|
}
|
||||||
if (p === '/robots.txt') { res.writeHead(200, headers({ 'Content-Type': 'text/plain; charset=utf-8' })); return res.end('User-agent: *\nAllow: /\nDisallow: /my\nDisallow: /admin\nDisallow: /api/\nDisallow: /go/\nDisallow: /sso/\n\nSitemap: https://' + C.site + '/sitemap.xml\n'); }
|
if (p === '/robots.txt') { res.writeHead(200, headers({ 'Content-Type': 'text/plain; charset=utf-8' })); return res.end('User-agent: *\nAllow: /\nDisallow: /my\nDisallow: /admin\nDisallow: /api/\nDisallow: /go/\nDisallow: /sso/\n\nSitemap: https://' + C.site + '/sitemap.xml\n'); }
|
||||||
if (p.startsWith('/assets/') || p.startsWith('/art/') || p === '/favicon.ico') {
|
if (p.startsWith('/assets/') || p.startsWith('/art/') || p === '/favicon.ico') {
|
||||||
const f = path.normalize(path.join(PUB, p === '/favicon.ico' ? '/art/icon-192.png' : p)); if (!f.startsWith(PUB + path.sep)) { res.writeHead(400); return res.end(); }
|
const f = path.normalize(path.join(PUB, p === '/favicon.ico' ? '/art/icon-192.png' : p)); if (!f.startsWith(PUB + path.sep)) { res.writeHead(400); return res.end(); }
|
||||||
|
if (/\.(mp4|webm)$/i.test(f)) return sendMedia(req, res, f);
|
||||||
return sendFile(res, f);
|
return sendFile(res, f);
|
||||||
}
|
}
|
||||||
if (p.startsWith('/u/')) {
|
if (p.startsWith('/u/')) {
|
||||||
@@ -255,12 +289,12 @@ const server = http.createServer(async (req, res) => {
|
|||||||
// click relay: /go/<bannerId> counts one click per visitor per banner per hour, then sends the visitor to the banner's link
|
// click relay: /go/<bannerId> counts one click per visitor per banner per hour, then sends the visitor to the banner's link
|
||||||
const gm = /^\/go\/(\d{1,9})$/.exec(p);
|
const gm = /^\/go\/(\d{1,9})$/.exec(p);
|
||||||
if (gm) {
|
if (gm) {
|
||||||
const b = store.banner(gm[1]); if (!b) { res.writeHead(302, { Location: '/' }); return res.end(); }
|
const b = store.banner(gm[1]); if (!b || b.down) { res.writeHead(302, { Location: '/' }); return res.end(); } // taken down: never sends anyone to it
|
||||||
if (!isBot(req)) {
|
if (!isBot(req)) {
|
||||||
const k = visitorKey(req) + ':' + b.id; const t = clickSeen.get(k);
|
const k = visitorKey(req) + ':' + b.id; const t = clickSeen.get(k);
|
||||||
if (!t || Date.now() - t > 3600000) { clickSeen.set(k, Date.now()); if (clickSeen.size > 100000) clickSeen.clear(); b.clicks = (b.clicks || 0) + 1; store.saveBanner(b); store.bump('clicks'); }
|
if (!t || Date.now() - t > 3600000) { clickSeen.set(k, Date.now()); if (clickSeen.size > 100000) clickSeen.clear(); b.clicks = (b.clicks || 0) + 1; store.saveBanner(b); store.bump('clicks'); }
|
||||||
}
|
}
|
||||||
res.writeHead(302, { Location: b.link, 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
|
res.writeHead(302, { Location: clickLink(b), 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +304,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/api/config' && req.method === 'GET') {
|
if (p === '/api/config' && req.method === 'GET') {
|
||||||
return json(res, 200, { site: C.site, siteName: C.siteName, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId,
|
return json(res, 200, { site: C.site, siteName: C.siteName, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId,
|
||||||
loopSize: C.loopSize, perShift: C.perShift, viewsPerCycle: C.viewsPerCycle, visitSeconds: C.visitSeconds, freeCreditCap: C.freeCreditCap, maxQueued: C.maxQueuedPerMember,
|
loopSize: C.loopSize, perShift: C.perShift, viewsPerCycle: C.viewsPerCycle, visitSeconds: C.visitSeconds, freeCreditCap: C.freeCreditCap, maxQueued: C.maxQueuedPerMember,
|
||||||
freeCreditsPerDay: C.freeCreditsPerDay, packs: C.packs, lookUsd: C.lookUsd, lookSku: C.lookSku, prizes: prizes(), sso: networksso.enabled(),
|
freeCreditsPerDay: weekend.freePerDay(C.freeCreditsPerDay), packs: livePacks(), lookUsd: liveLookUsd(), weekend: weekend.on(), lookSku: C.lookSku, prizes: prizes(), sso: networksso.enabled(),
|
||||||
shop: { live: shop.watching(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer });
|
shop: { live: shop.watching(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer });
|
||||||
}
|
}
|
||||||
// buying: the live price, gas fees for the wallet, and the confirmation wait (the Downline Banners endpoints)
|
// buying: the live price, gas fees for the wallet, and the confirmation wait (the Downline Banners endpoints)
|
||||||
@@ -287,8 +321,13 @@ const server = http.createServer(async (req, res) => {
|
|||||||
try { return json(res, 200, await shop.receipt(p.slice(8))); } catch (e) { return json(res, 200, { found: false }); }
|
try { return json(res, 200, await shop.receipt(p.slice(8))); } catch (e) { return json(res, 200, { found: false }); }
|
||||||
}
|
}
|
||||||
// past weeks' prize winners with their transactions (paid weeks only)
|
// past weeks' prize winners with their transactions (paid weeks only)
|
||||||
|
// trust pack (2026-11-14): the public ledger (purchases with their split, prize payouts), the live contract facts, the network list
|
||||||
|
if (p === '/api/ledger' && req.method === 'GET') return json(res, 200, proof.ledger(u.searchParams.get('n')), { 'Cache-Control': 'public, max-age=10' });
|
||||||
|
if (p === '/api/contract' && req.method === 'GET') { if (limited(req, 'contract', 600, 3600000)) return json(res, 429, { error: 'Too many requests' }); return json(res, 200, await proof.contract(), { 'Cache-Control': 'public, max-age=60' }); }
|
||||||
|
if (p === '/api/network-sites' && req.method === 'GET') return netsites.handle(req, res);
|
||||||
|
if (p === '/api/network-deals' && req.method === 'GET') return netdeals.handle(req, res, 'vbb');
|
||||||
if (p === '/api/prizes' && req.method === 'GET') return json(res, 200, { current: prizes(), week: store.ctWeek(), past: prize.history(12), explorer: C.explorer }, { 'Cache-Control': 'public, max-age=30' });
|
if (p === '/api/prizes' && req.method === 'GET') return json(res, 200, { current: prizes(), week: store.ctWeek(), past: prize.history(12), explorer: C.explorer }, { 'Cache-Control': 'public, max-age=30' });
|
||||||
if (p === '/api/splash' && req.method === 'GET') return json(res, 200, loop.view(24), { 'Cache-Control': 'no-store' });
|
if (p === '/api/splash' && req.method === 'GET') { const v = loop.view(24); v.fill = splashFill(); return json(res, 200, v, { 'Cache-Control': 'no-store' }); }
|
||||||
if (p === '/api/leaders' && req.method === 'GET') {
|
if (p === '/api/leaders' && req.method === 'GET') {
|
||||||
const out = loop.leaders(null, 10);
|
const out = loop.leaders(null, 10);
|
||||||
const fmt = r => ({ name: r.username ? '@' + r.username : r.address.slice(0, 6) + '...' + r.address.slice(-4), visitors: r.visitors, sources: r.sources });
|
const fmt = r => ({ name: r.username ? '@' + r.username : r.address.slice(0, 6) + '...' + r.address.slice(-4), visitors: r.visitors, sources: r.sources });
|
||||||
@@ -348,6 +387,17 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const s = session(req); if (s) store.dropSession(s.token);
|
const s = session(req); if (s) store.dropSession(s.token);
|
||||||
return json(res, 200, { ok: true }, { 'Set-Cookie': [cookie('vbb.sid', '', 0, true), networksso.offCookie()] });
|
return json(res, 200, { ok: true }, { 'Set-Cookie': [cookie('vbb.sid', '', 0, true), networksso.offCookie()] });
|
||||||
}
|
}
|
||||||
|
// "Sign out everywhere" (2026-11-16): the hub ends every network sign-in of this member and tells every hooked site; every
|
||||||
|
// session of this wallet here ends now. Same-origin POST only (SameSite=Lax session cookie).
|
||||||
|
if (p === '/api/auth/logout-everywhere' && req.method === 'POST') {
|
||||||
|
const s = session(req); let hub = { ok: false };
|
||||||
|
if (s) { hub = await networksso.signOutEverywhere(s); store.endSessions(x => x.address === s.address, Date.now() + 1000); }
|
||||||
|
return json(res, 200, { ok: true, everywhere: !!hub.ok }, { 'Set-Cookie': [cookie('vbb.sid', '', 0, true), networksso.offCookie()] });
|
||||||
|
}
|
||||||
|
if (p === '/api/hub/events' && req.method === 'POST') {
|
||||||
|
let raw = ''; try { raw = (await readRaw(req, 256 * 1024)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
|
||||||
|
const r = await hubevents.receive(req.headers, raw); return json(res, r.status, r.body);
|
||||||
|
}
|
||||||
if (p === '/api/me' && req.method === 'GET') {
|
if (p === '/api/me' && req.method === 'GET') {
|
||||||
const s = session(req); if (!s) return json(res, 200, { signedIn: false });
|
const s = session(req); if (!s) return json(res, 200, { signedIn: false });
|
||||||
const m = store.member(s.address);
|
const m = store.member(s.address);
|
||||||
@@ -380,6 +430,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (sku === C.lookSku) {
|
if (sku === C.lookSku) {
|
||||||
const bn = store.banner(b.ref);
|
const bn = store.banner(b.ref);
|
||||||
if (!bn || bn.owner !== me) return json(res, 400, { error: 'That banner is not yours.' });
|
if (!bn || bn.owner !== me) return json(res, 400, { error: 'That banner is not yours.' });
|
||||||
|
if (bn.down) return json(res, 400, { error: 'That banner was taken down.' });
|
||||||
if (bn.look) return json(res, 400, { error: 'That banner already has the look.' });
|
if (bn.look) return json(res, 400, { error: 'That banner already has the look.' });
|
||||||
if (bn.state === 'cycled') return json(res, 400, { error: 'That banner has already cycled. Add the look to a banner that is waiting or in the loop.' });
|
if (bn.state === 'cycled') return json(res, 400, { error: 'That banner has already cycled. Add the look to a banner that is waiting or in the loop.' });
|
||||||
if (qty !== 1) return json(res, 400, { error: 'One look per banner.' });
|
if (qty !== 1) return json(res, 400, { error: 'One look per banner.' });
|
||||||
@@ -399,11 +450,55 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const tm = /^\/api\/my\/banners\/(\d{1,9})\/teaser$/.exec(p);
|
const tm = /^\/api\/my\/banners\/(\d{1,9})\/teaser$/.exec(p);
|
||||||
if (tm && req.method === 'POST') {
|
if (tm && req.method === 'POST') {
|
||||||
const bn = store.banner(tm[1]); if (!bn || bn.owner !== me) return json(res, 404, { error: 'Not found' });
|
const bn = store.banner(tm[1]); if (!bn || bn.owner !== me) return json(res, 404, { error: 'Not found' });
|
||||||
|
if (bn.down) return json(res, 400, { error: 'That banner was taken down.' });
|
||||||
if (!bn.look) return json(res, 400, { error: 'Add the banner look first.' });
|
if (!bn.look) return json(res, 400, { error: 'Add the banner look first.' });
|
||||||
const t = String((await readBody(req)).teaser || '').replace(/[\u0000-\u001f\u007f<>]/g, '').replace(/\s+/g, ' ').trim();
|
const t = String((await readBody(req)).teaser || '').replace(/[\u0000-\u001f\u007f<>]/g, '').replace(/\s+/g, ' ').trim();
|
||||||
if (t.length > 40) return json(res, 400, { error: 'Keep the teaser to 40 characters.' });
|
if (t.length > 40) return json(res, 400, { error: 'Keep the teaser to 40 characters.' });
|
||||||
bn.teaser = t; store.saveBanner(bn); return json(res, 200, { ok: true, teaser: t || loop.hostOf(bn.link) });
|
bn.teaser = t; store.saveBanner(bn); return json(res, 200, { ok: true, teaser: t || loop.hostOf(bn.link) });
|
||||||
}
|
}
|
||||||
|
// the member's LinkSpin Banner Spins in a size the loop shows (125x125, or 250x250 for sharp screens)
|
||||||
|
if (p === '/api/my/lsspins' && req.method === 'GET') {
|
||||||
|
if (limited(req, 'lsspins', 120, 3600000)) return json(res, 429, { error: 'Too many requests this hour.' });
|
||||||
|
const r = await lsspins.list(me, lsName(me)); if (r.error) return json(res, 502, r);
|
||||||
|
return json(res, 200, { account: !!r.account, username: r.username || null, spins: (r.spins || []).filter(x => ['125x125', '250x250'].includes(x.size)).map(x => ({ id: x.id, name: x.name, size: x.size || null, paused: !!x.paused, banners: x.banners || 0 })) });
|
||||||
|
}
|
||||||
|
// swap the image and/or link of a banner that is waiting or in the loop, once per banner. The banner keeps its id, place, clicks
|
||||||
|
// and cycle progress. The new image and link get exactly the checks a new post gets. A Banner Spin swap ({ spinId }) takes the
|
||||||
|
// image + link from LinkSpin's signed answer for another of the member's own 125x125/250x250 spins. Logged on the banner.
|
||||||
|
const sw = /^\/api\/my\/banners\/(\d{1,9})\/swap$/.exec(p);
|
||||||
|
if (sw && req.method === 'POST') {
|
||||||
|
if (limited(req, 'swap', 20, 3600000)) return json(res, 429, { error: 'Too many tries this hour.' });
|
||||||
|
const bn = store.banner(sw[1]); if (!bn || bn.owner !== me) return json(res, 404, { error: 'Not found' });
|
||||||
|
if (swapUsed(bn)) return json(res, 400, { error: 'This banner already used its one swap.' });
|
||||||
|
if (bn.down) return json(res, 400, { error: 'That banner was taken down.' });
|
||||||
|
if (bn.state !== 'queued' && bn.state !== 'loop') return json(res, 400, { error: 'Only a banner that is waiting or in the loop can be swapped.' });
|
||||||
|
const b = await readBody(req); let next;
|
||||||
|
if (b.spinId != null) {
|
||||||
|
const r = await lsspins.use(me, lsName(me), b.spinId);
|
||||||
|
if (r.error || !r.use) return json(res, 400, { error: r.error || (r.account === false ? 'No LinkSpin account holds this wallet yet.' : 'Could not use that Banner Spin.') });
|
||||||
|
if (!['125x125', '250x250'].includes(r.use.size)) return json(res, 400, { error: 'Use a 125x125 (or 250x250) Banner Spin.' });
|
||||||
|
const ic = safety.checkLink(r.use.img, 'Banner Spin image'); const sl = safety.checkLink(r.use.link, 'Banner Spin link');
|
||||||
|
if (ic.error || sl.error || new URL(ic.url).hostname !== new URL(sl.url).hostname) return json(res, 400, { error: 'LinkSpin sent a link we cannot use. Try again in a minute.' });
|
||||||
|
next = { img: ic.url, link: sl.url, spin: { id: Number(r.use.spinId), name: String(r.use.name || '').slice(0, 60), size: r.use.size } };
|
||||||
|
if (bn.spin && bn.spin.id === next.spin.id) return json(res, 400, { error: 'That is the Banner Spin this banner already shows. Pick another one.' });
|
||||||
|
} else {
|
||||||
|
const hasImg = String(b.img || '').trim() !== '', hasLink = String(b.link || '').trim() !== '';
|
||||||
|
if (!hasImg && !hasLink) return json(res, 400, { error: 'Add a new image, a new link, or both.' });
|
||||||
|
if (bn.spin && !(hasImg && hasLink)) return json(res, 400, { error: 'A Banner Spin swaps to another Banner Spin, or to your own image and link together.' });
|
||||||
|
let link = bn.link, img = bn.img;
|
||||||
|
if (hasLink) { const lk = safety.checkLink(b.link, 'Target link'); if (lk.error) return json(res, 400, lk); link = lk.url; }
|
||||||
|
if (hasImg) { const im = await checkedImage(me, b.img); if (im.error) return json(res, 400, im); img = im.img; }
|
||||||
|
if (hasLink && C.linkProbe) { const pr = await safety.probeLink(link); if (pr.error) return json(res, 400, pr); }
|
||||||
|
if (link === bn.link && img === bn.img) return json(res, 400, { error: 'That is the image and link the banner already has.' });
|
||||||
|
next = { img, link, spin: null };
|
||||||
|
}
|
||||||
|
const cur = store.banner(sw[1]); // re-checked after the awaits (another tab, or the admin, may have acted meanwhile)
|
||||||
|
if (swapUsed(cur) || !canSwap(cur)) return json(res, 400, { error: swapUsed(cur) ? 'This banner already used its one swap.' : 'This banner can no longer be swapped.' });
|
||||||
|
cur.swaps = [{ at: Date.now(), old: { img: cur.img, link: cur.link, spin: cur.spin || null }, new: { img: next.img, link: next.link, spin: next.spin } }];
|
||||||
|
cur.img = next.img; cur.link = next.link; if (next.spin) cur.spin = next.spin; else delete cur.spin;
|
||||||
|
store.saveBanner(cur);
|
||||||
|
return json(res, 200, { ok: true, banner: Object.assign({ id: cur.id, img: cur.img, link: cur.link, spin: cur.spin ? { name: cur.spin.name, size: cur.spin.size } : null, swapUsed: true }, loop.placeOf(cur)) });
|
||||||
|
}
|
||||||
if (p === '/api/my/upload' && req.method === 'POST') {
|
if (p === '/api/my/upload' && req.method === 'POST') {
|
||||||
if (limited(req, 'upload', 40, 3600000)) return json(res, 429, { error: 'Too many uploads this hour.' });
|
if (limited(req, 'upload', 40, 3600000)) return json(res, 429, { error: 'Too many uploads this hour.' });
|
||||||
let buf; try { buf = await readRaw(req, safety.MAX_UPLOAD + 1); } catch (e) { return json(res, 400, { error: 'The file is over 100 KB.' }); }
|
let buf; try { buf = await readRaw(req, safety.MAX_UPLOAD + 1); } catch (e) { return json(res, 400, { error: 'The file is over 100 KB.' }); }
|
||||||
@@ -414,17 +509,25 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (limited(req, 'post', 30, 3600000)) return json(res, 429, { error: 'Too many posts this hour.' });
|
if (limited(req, 'post', 30, 3600000)) return json(res, 429, { error: 'Too many posts this hour.' });
|
||||||
const b = await readBody(req); const m = store.member(me);
|
const b = await readBody(req); const m = store.member(me);
|
||||||
if (m.credits < 1) return json(res, 400, { error: 'You have no post credits. A free credit arrives each day you sign in.' });
|
if (m.credits < 1) return json(res, 400, { error: 'You have no post credits. A free credit arrives each day you sign in.' });
|
||||||
const waiting = store.bannersOf(me).filter(x => x.state === 'queued').length;
|
const waiting = store.bannersOf(me).filter(x => x.state === 'queued' && !x.down).length;
|
||||||
if (waiting >= C.maxQueuedPerMember) return json(res, 400, { error: 'You already have ' + waiting + ' banners waiting. Post again when one enters the loop.' });
|
if (waiting >= C.maxQueuedPerMember) return json(res, 400, { error: 'You already have ' + waiting + ' banners waiting. Post again when one enters the loop.' });
|
||||||
const lk = safety.checkLink(b.link, 'Target link'); if (lk.error) return json(res, 400, lk);
|
// a LinkSpin Banner Spin (2026-11-14): image + link come from LinkSpin's signed answer, never from the browser. The image is the
|
||||||
let img = String(b.img || '').trim();
|
// spin's rotating image on LinkSpin (not copied: it changes on every view) and the link its click link (clicks count in
|
||||||
if (/^\/u\/[a-z0-9-]+\.(png|jpg|gif)$/.test(img)) {
|
// LinkSpin Reports); LinkSpin checked the spin's images and links, so the frame probe (it would count a click) is skipped.
|
||||||
if (!img.slice(3).startsWith(me.slice(2, 10) + '-') || !fs.existsSync(path.join(UPL, img.slice(3)))) return json(res, 400, { error: 'Upload the image again.' });
|
if (b.spinId != null) {
|
||||||
} else {
|
const r = await lsspins.use(me, lsName(me), b.spinId);
|
||||||
const ic = safety.checkLink(img, 'Image address'); if (ic.error) return json(res, 400, ic);
|
if (r.error || !r.use) return json(res, 400, { error: r.error || (r.account === false ? 'No LinkSpin account holds this wallet yet.' : 'Could not use that Banner Spin.') });
|
||||||
const f = await safety.fetchImage(ic.url); if (f.error) return json(res, 400, f);
|
if (!['125x125', '250x250'].includes(r.use.size)) return json(res, 400, { error: 'Use a 125x125 (or 250x250) Banner Spin.' });
|
||||||
img = saveUpload(me, f.buf, f.info.ext);
|
const ic = safety.checkLink(r.use.img, 'Banner Spin image'); const sl = safety.checkLink(r.use.link, 'Banner Spin link');
|
||||||
|
if (ic.error || sl.error || new URL(ic.url).hostname !== new URL(sl.url).hostname) return json(res, 400, { error: 'LinkSpin sent a link we cannot use. Try again in a minute.' });
|
||||||
|
if (store.member(me).credits < 1) return json(res, 400, { error: 'You have no post credits.' });
|
||||||
|
m.credits -= 1;
|
||||||
|
const nb = loop.post(me, ic.url, sl.url, 'credit', { id: Number(r.use.spinId), name: String(r.use.name || '').slice(0, 60), size: r.use.size });
|
||||||
|
return json(res, 200, { ok: true, banner: Object.assign({ id: nb.id }, loop.placeOf(nb)), credits: m.credits, otherSource: !!r.use.otherSource });
|
||||||
}
|
}
|
||||||
|
const lk = safety.checkLink(b.link, 'Target link'); if (lk.error) return json(res, 400, lk);
|
||||||
|
const im = await checkedImage(me, b.img); if (im.error) return json(res, 400, im);
|
||||||
|
const img = im.img;
|
||||||
if (C.linkProbe) { const pr = await safety.probeLink(lk.url); if (pr.error) return json(res, 400, pr); }
|
if (C.linkProbe) { const pr = await safety.probeLink(lk.url); if (pr.error) return json(res, 400, pr); }
|
||||||
if (store.member(me).credits < 1) return json(res, 400, { error: 'You have no post credits.' }); // spent meanwhile by another tab
|
if (store.member(me).credits < 1) return json(res, 400, { error: 'You have no post credits.' }); // spent meanwhile by another tab
|
||||||
m.credits -= 1;
|
m.credits -= 1;
|
||||||
@@ -440,12 +543,12 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/api/admin/status' && req.method === 'GET') {
|
if (p === '/api/admin/status' && req.method === 'GET') {
|
||||||
const S = store.state(); const L = store.ledger(); const t = store.today();
|
const S = store.state(); const L = store.ledger(); const t = store.today();
|
||||||
const byStatus = {}; for (const e of L) byStatus[e.status] = (byStatus[e.status] || 0) + e.views;
|
const byStatus = {}; for (const e of L) byStatus[e.status] = (byStatus[e.status] || 0) + e.views;
|
||||||
return json(res, 200, { day: store.ctDay(), week: store.ctWeek(), config: { split: C.split, packs: C.packs, lookUsd: C.lookUsd, prizePot: C.prizePot, prizes: prizes(), freeCreditsPerDay: C.freeCreditsPerDay, loopSize: C.loopSize, perShift: C.perShift, viewsPerCycle: C.viewsPerCycle, visitSeconds: C.visitSeconds, perIpDay: C.perIpDay, freeCreditCap: C.freeCreditCap, maxQueued: C.maxQueuedPerMember },
|
return json(res, 200, { day: store.ctDay(), week: store.ctWeek(), config: { split: C.split, packs: livePacks(), lookUsd: liveLookUsd(), prizePot: C.prizePot, prizes: prizes(), freeCreditsPerDay: weekend.freePerDay(C.freeCreditsPerDay), loopSize: C.loopSize, perShift: C.perShift, viewsPerCycle: C.viewsPerCycle, visitSeconds: C.visitSeconds, perIpDay: C.perIpDay, freeCreditCap: C.freeCreditCap, maxQueued: C.maxQueuedPerMember },
|
||||||
loop: { filled: S.loop.length, size: C.loopSize, ids: S.loop, nextOut: S.loop.length ? S.loop[S.loop.length - 1] : null },
|
loop: { filled: S.loop.length, size: C.loopSize, ids: S.loop, nextOut: S.loop.length ? S.loop[S.loop.length - 1] : null },
|
||||||
queue: { length: S.queue.length, next: S.queue.slice(0, 20) }, progress: S.progress, held: S.progress >= C.perShift && !S.queue.length,
|
queue: { length: S.queue.length, next: S.queue.slice(0, 20) }, progress: S.progress, held: S.progress >= C.perShift && !S.queue.length,
|
||||||
today: { visits: t.visits || 0, shifts: t.shifts || 0, cycles: t.cycles || 0, posts: t.posts || 0, clicks: t.clicks || 0 },
|
today: { visits: t.visits || 0, shifts: t.shifts || 0, cycles: t.cycles || 0, posts: t.posts || 0, clicks: t.clicks || 0 },
|
||||||
totals: S.totals, ledger: { entries: L.length, views: L.reduce((x, e) => x + e.views, 0), viewsByStatus: byStatus, credited: 0 },
|
totals: S.totals, ledger: { entries: L.length, views: L.reduce((x, e) => x + e.views, 0), viewsByStatus: byStatus, credited: 0 },
|
||||||
members: store.members().length, banners: S.banners.length, visitsKept: store.visits().length, shop: shop.view(), prize: prize.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
members: store.members().length, banners: S.banners.length, visitsKept: store.visits().length, shop: shop.view(), prize: prize.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), hubEvents: hubevents.view(), lsSpins: lsspins.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
||||||
}
|
}
|
||||||
// old username -> network username map for the old-link redirects: { oldrefs: { old: network } } replaces the whole map
|
// old username -> network username map for the old-link redirects: { oldrefs: { old: network } } replaces the whole map
|
||||||
if (p === '/api/admin/oldrefs' && req.method === 'POST') {
|
if (p === '/api/admin/oldrefs' && req.method === 'POST') {
|
||||||
@@ -472,6 +575,64 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const per = {}; for (const e of L) { const k = e.owner; const r = per[k] || (per[k] = { address: k, username: e.username, cycles: 0, views: 0 }); r.cycles++; r.views += e.views; if (e.username) r.username = e.username; }
|
const per = {}; for (const e of L) { const k = e.owner; const r = per[k] || (per[k] = { address: k, username: e.username, cycles: 0, views: 0 }); r.cycles++; r.views += e.views; if (e.username) r.username = e.username; }
|
||||||
return json(res, 200, { entries: L.slice(-n).reverse(), members: Object.values(per).sort((a, b) => b.views - a.views), note: 'v1 records rewards only; nothing has been credited to InstantAdPay or LinkSpin.' });
|
return json(res, 200, { entries: L.slice(-n).reverse(), members: Object.values(per).sort((a, b) => b.views - a.views), note: 'v1 records rewards only; nothing has been credited to InstantAdPay or LinkSpin.' });
|
||||||
}
|
}
|
||||||
|
// ---- banner takedown (Marty 2026-11-15: "Admin takes down the option to credit back or none") ----
|
||||||
|
// GET ?q=#<id> | <id> | <wallet> | <username>: the banners with their swap + takedown history
|
||||||
|
if (p === '/api/admin/banners' && req.method === 'GET') {
|
||||||
|
const q = String(u.searchParams.get('q') || '').trim(); let list = [];
|
||||||
|
if (/^#?\d{1,9}$/.test(q)) { const b = store.banner(Number(q.replace('#', ''))); if (b) list = [b]; }
|
||||||
|
else if (ADDR_RE.test(q)) list = store.bannersOf(q);
|
||||||
|
else if (NAME_RE.test(q.replace(/^@/, ''))) { const m = store.memberByName(q.replace(/^@/, '')); if (m) list = store.bannersOf(m.address); }
|
||||||
|
if (!list.length) return json(res, 404, { error: 'No banner found for that.' });
|
||||||
|
return json(res, 200, { banners: list.slice().reverse().slice(0, 100).map(adminBanner) });
|
||||||
|
}
|
||||||
|
const tk = /^\/api\/admin\/banners\/(\d{1,9})\/(takedown|restore)$/.exec(p);
|
||||||
|
if (tk && req.method === 'POST') {
|
||||||
|
const bn = store.banner(tk[1]); if (!bn) return json(res, 404, { error: 'No such banner.' });
|
||||||
|
const b = await readBody(req); const by = String(b.by || 'admin').replace(/[^\w .@-]/g, '').slice(0, 40) || 'admin';
|
||||||
|
const reason = String(b.reason || '').replace(/[\u0000-\u001f\u007f<>]/g, '').replace(/\s+/g, ' ').trim();
|
||||||
|
const m = store.member(bn.owner);
|
||||||
|
if (tk[2] === 'takedown') {
|
||||||
|
if (bn.down) return json(res, 400, { error: 'That banner is already taken down.' });
|
||||||
|
if (bn.state !== 'queued' && bn.state !== 'loop') return json(res, 400, { error: 'Only a banner that is waiting or in the loop can be taken down (this one is ' + bn.state + ').' });
|
||||||
|
if (reason.length < 3 || reason.length > 300) return json(res, 400, { error: 'A reason is required (3 to 300 characters). The owner sees it.' });
|
||||||
|
if (b.credit !== 'back' && b.credit !== 'none') return json(res, 400, { error: 'Choose credit: "back" (the owner gets the post credit back) or "none".' });
|
||||||
|
const back = b.credit === 'back' && !!m;
|
||||||
|
bn.down = { at: Date.now(), by, reason, creditBack: back, slot: bn.state };
|
||||||
|
if (back) { m.credits += 1; store.save(); }
|
||||||
|
store.saveBanner(bn);
|
||||||
|
const e = adminLog({ action: 'takedown', bannerId: bn.id, owner: bn.owner, username: (m && m.username) || null, by, reason, credit: back ? 'back' : 'none', slot: bn.state });
|
||||||
|
return json(res, 200, { ok: true, banner: adminBanner(bn), log: e, ownerCredits: m ? m.credits : null });
|
||||||
|
}
|
||||||
|
// restore a mistaken takedown: the banner shows again; a credit that was given back is taken back
|
||||||
|
if (!bn.down) return json(res, 400, { error: 'That banner is not taken down.' });
|
||||||
|
const was = bn.down; let reversed = false, short = false, cycle = null;
|
||||||
|
if (was.creditBack && m) { if (m.credits >= 1) { m.credits -= 1; reversed = true; store.save(); } else short = true; }
|
||||||
|
(bn.downs || (bn.downs = [])).push(Object.assign({}, was, { restoredAt: Date.now(), restoredBy: by, restoreReason: reason || null, creditReversed: reversed }));
|
||||||
|
delete bn.down;
|
||||||
|
// its place rode out while it was down: it gets the cycle it would have had
|
||||||
|
if (bn.state === 'ended') { bn.state = 'cycled'; bn.cycledAt = Date.now(); delete bn.endedAt; cycle = loop.recordCycle(bn, { note: 'restored' }); }
|
||||||
|
store.saveBanner(bn);
|
||||||
|
const e = adminLog({ action: 'restore', bannerId: bn.id, owner: bn.owner, username: (m && m.username) || null, by, reason: reason || null,
|
||||||
|
credit: was.creditBack ? (reversed ? 'taken back' : 'already used, not taken back') : 'none given', cycleRecorded: !!cycle });
|
||||||
|
return json(res, 200, { ok: true, banner: adminBanner(bn), log: e, creditReversed: reversed, creditAlreadyUsed: short, cycle, ownerCredits: m ? m.credits : null });
|
||||||
|
}
|
||||||
|
if (p === '/api/admin/actions' && req.method === 'GET') {
|
||||||
|
const n = Math.min(500, Math.max(1, Number(u.searchParams.get('n')) || 100));
|
||||||
|
return json(res, 200, { actions: (store.state().adminLog || []).slice(-n).reverse() });
|
||||||
|
}
|
||||||
|
// the network hub's member lookup (Marty 2026-11-14, read-only). GET ?q=<wallet> | #<banner id> | <username>. No email lives here.
|
||||||
|
if (p === '/api/admin/member-lookup' && req.method === 'GET') {
|
||||||
|
const q = String(u.searchParams.get('q') || '').trim(); let a = null, via = null;
|
||||||
|
if (ADDR_RE.test(q)) { a = q.toLowerCase(); via = 'wallet'; }
|
||||||
|
else if (/^#?\d{1,9}$/.test(q)) { const b = store.banner(Number(q.replace('#', ''))); a = b ? b.owner : null; via = 'banner'; }
|
||||||
|
else if (NAME_RE.test(q)) { const m = store.memberByName(q); a = m ? m.address : null; via = 'username'; }
|
||||||
|
if (!a) return json(res, 404, { error: 'not found' });
|
||||||
|
const P = Object.entries(store.state().purchases || {}).map(([k, x]) => Object.assign({ tx: k.split(':')[0], logIndex: Number(k.split(':')[1]) }, x));
|
||||||
|
const purchases = P.filter(x => x.buyer === a).sort((x, y) => (y.at || 0) - (x.at || 0)); const sponsored = P.filter(x => x.sponsor === a).sort((x, y) => (y.at || 0) - (x.at || 0));
|
||||||
|
const m = store.member(a);
|
||||||
|
return json(res, 200, Object.assign(m ? myData(a) : { address: a, banners: [], credits: 0 }, { via, known: !!m || purchases.length > 0 || sponsored.length > 0, record: m || null,
|
||||||
|
purchases: purchases.slice(0, 100), sponsored: sponsored.slice(0, 100), contract: C.contractAddress, explorer: C.explorer }));
|
||||||
|
}
|
||||||
return json(res, 404, { error: 'Not found' });
|
return json(res, 404, { error: 'Not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,8 +645,50 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (!res.headersSent) json(res, 500, { error: 'Server error' });
|
if (!res.headersSent) json(res, 500, { error: 'Server error' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// the network username LinkSpin may look the member up by when no LinkSpin account holds this wallet: network-verified members only
|
||||||
|
const lsName = addr => { const m = store.member(addr); return m && netVerified(m) && m.username ? m.username : null; };
|
||||||
|
// admin views of a banner + the admin action ledger (takedowns and restores: who, when, reason, credit decision)
|
||||||
|
function adminBanner(b) { const m = store.member(b.owner);
|
||||||
|
return Object.assign({ id: b.id, owner: b.owner, username: (m && m.username) || null, img: b.img, link: b.link, spin: b.spin || null, createdAt: b.createdAt, clicks: b.clicks || 0, look: !!b.look,
|
||||||
|
swaps: b.swaps || [], down: b.down || null, downs: b.downs || [], cycledAt: b.cycledAt || null, endedAt: b.endedAt || null }, loop.placeOf(b)); }
|
||||||
|
function adminLog(e) { const S = store.state(); const L = S.adminLog || (S.adminLog = []);
|
||||||
|
e.id = 'a' + (S.seq.admin = (S.seq.admin || 0) + 1); e.at = Date.now(); L.push(e); if (L.length > 5000) L.splice(0, L.length - 5000); store.save(); return e; }
|
||||||
|
// a banner image from the browser: one of this member's uploads (/u/...), or an https image address fetched once and checked like an upload
|
||||||
|
async function checkedImage(me, raw) {
|
||||||
|
const img = String(raw || '').trim();
|
||||||
|
if (/^\/u\/[a-z0-9-]+\.(png|jpg|gif)$/.test(img)) {
|
||||||
|
if (!img.slice(3).startsWith(me.slice(2, 10) + '-') || !fs.existsSync(path.join(UPL, img.slice(3)))) return { error: 'Upload the image again.' };
|
||||||
|
return { img };
|
||||||
|
}
|
||||||
|
const ic = safety.checkLink(img, 'Image address'); if (ic.error) return ic;
|
||||||
|
const f = await safety.fetchImage(ic.url); if (f.error) return f;
|
||||||
|
return { img: saveUpload(me, f.buf, f.info.ext) };
|
||||||
|
}
|
||||||
|
// tracking macros in a banner link, filled on every click: {clickid} a fresh id, {spot} the banner number, {type} loop or waiting
|
||||||
|
const MACRO = /\{(clickid|spot|type)\}|%7B(clickid|spot|type)%7D/gi;
|
||||||
|
function clickLink(b) {
|
||||||
|
const l = String(b.link || ''); if (!l.match(MACRO)) return l;
|
||||||
|
const v = { clickid: crypto.randomBytes(8).toString('hex'), spot: String(b.id), type: b.state === 'queued' ? 'waiting' : 'loop' };
|
||||||
|
return l.replace(MACRO, (x, a, c) => v[(a || c).toLowerCase()]);
|
||||||
|
}
|
||||||
|
// members' Banner Spins on the splash: the loop's open places (one place always stays "post yours") and, while nobody waits, the
|
||||||
|
// waiting line. Never in the loop list: no shift, no cycle, no reward. Same picks for 2 minutes, so the page does not reshuffle.
|
||||||
|
let fillCache = { key: '', at: 0, out: { loop: [], queue: [] } };
|
||||||
|
function splashFill() {
|
||||||
|
const S = store.state(); const ids = S.loop.concat(S.queue.slice(0, 24)); const bs = ids.map(id => store.banner(id)).filter(b => b && !b.down);
|
||||||
|
const open = Math.max(0, C.loopSize - S.loop.length - 1), queueSlots = S.queue.length ? 0 : 8;
|
||||||
|
const key = ids.join(',') + '|' + open + '|' + queueSlots + '|' + lsspins.view().fill + '|' + lsspins.view().at;
|
||||||
|
if (fillCache.key === key && Date.now() - fillCache.at < 120000) return fillCache.out;
|
||||||
|
const out = lsspins.fill({ openPlaces: open, queueSlots, pageOwners: bs.map(b => b.owner), pageImgs: bs.map(b => b.img) });
|
||||||
|
fillCache = { key, at: Date.now(), out }; return out;
|
||||||
|
}
|
||||||
const validSku = sku => sku === C.lookSku || C.packs.some(x => x.sku === sku);
|
const validSku = sku => sku === C.lookSku || C.packs.some(x => x.sku === sku);
|
||||||
const skuUsd = sku => sku === C.lookSku ? C.lookUsd : (C.packs.find(x => x.sku === sku) || {}).usd || 0;
|
const skuUsd = sku => sku === C.lookSku ? liveLookUsd() : (livePacks().find(x => x.sku === sku) || {}).usd || 0;
|
||||||
|
// the packs as the contract holds them right now (chainskus.js, read every 60 s); the env values until the first read answers
|
||||||
|
const livePacks = () => chainskus.packs(C);
|
||||||
|
const liveLookUsd = () => chainskus.lookUsd(C);
|
||||||
|
// the ribbon's VBB line from live values (weekend.js dealLine): no line while the chain still holds the normal pack (a late signature)
|
||||||
|
netdeals.setLocal(d => weekend.dealLine(C, d));
|
||||||
function saveUpload(owner, buf, ext) {
|
function saveUpload(owner, buf, ext) {
|
||||||
const name = owner.slice(2, 10) + '-' + crypto.randomBytes(6).toString('hex') + ext;
|
const name = owner.slice(2, 10) + '-' + crypto.randomBytes(6).toString('hex') + ext;
|
||||||
fs.writeFileSync(path.join(UPL, name), buf); // uploads stay files on the volume (docstore keeps the uploads folder on disk)
|
fs.writeFileSync(path.join(UPL, name), buf); // uploads stay files on the volume (docstore keeps the uploads folder on disk)
|
||||||
@@ -499,9 +702,16 @@ function saveUpload(owner, buf, ext) {
|
|||||||
loop.init({ onCycle: (b, e) => console.log('cycle', 'banner #' + b.id, e.views + ' network views recorded') });
|
loop.init({ onCycle: (b, e) => console.log('cycle', 'banner #' + b.id, e.views + ' network views recorded') });
|
||||||
store.pruneVisits(); loop.rebuildIndex();
|
store.pruneVisits(); loop.rebuildIndex();
|
||||||
hubreport.init({ dataDir: C.dataDir, purchases: () => Object.entries((store.state() || {}).purchases || {}).map(([key, x]) => Object.assign({ key }, x)) });
|
hubreport.init({ dataDir: C.dataDir, purchases: () => Object.entries((store.state() || {}).purchases || {}).map(([key, x]) => Object.assign({ key }, x)) });
|
||||||
|
proof.init(C, { shop, prize, nameOf: async a => { const m = await netMember({ a }).catch(() => null); return m && m.address === a ? m.username : null; } });
|
||||||
|
shop.setHook(proof.onPurchase); prize.setHook(proof.onPrize); // before the watcher's first scan
|
||||||
shop.init(C); // inert without CONTRACT_ADDRESS + CHAIN_RPC (watcher) / KEEPER_KEY (vouchers)
|
shop.init(C); // inert without CONTRACT_ADDRESS + CHAIN_RPC (watcher) / KEEPER_KEY (vouchers)
|
||||||
|
chainskus.init(C, C.packs.map(p => p.sku).concat([C.lookSku])); // live pack values for pages + chatbot (2026-11-17)
|
||||||
prize.init(C); // prepares last week's payout plan; pays only on an admin's approval (PRIZE_KEY)
|
prize.init(C); // prepares last week's payout plan; pays only on an admin's approval (PRIZE_KEY)
|
||||||
|
// fill spins: members seen in the last 60 days (most recent 400), one LinkSpin call each every 10 minutes
|
||||||
|
lsspins.init({ base: () => C.lsPartnerBase, members: () => store.members().filter(m => Date.now() - (m.lastSeen || m.joinedAt || 0) < 60 * 86400000)
|
||||||
|
.sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0)).slice(0, 400) });
|
||||||
setInterval(() => { if (store.pruneVisits()) loop.rebuildIndex(); }, 3600000).unref();
|
setInterval(() => { if (store.pruneVisits()) loop.rebuildIndex(); }, 3600000).unref();
|
||||||
|
chatbot.init(); // after docstore.init: kb.json is a MySQL document
|
||||||
server.listen(C.port, () => console.log('Viral Banner Blitz on :' + C.port + ' loop ' + C.loopSize + ', ' + C.perShift + ' visitors per shift, store: ' + (docstore.isOn() ? 'MySQL documents' : 'files (prototype mode)')));
|
server.listen(C.port, () => console.log('Viral Banner Blitz on :' + C.port + ' loop ' + C.loopSize + ', ' + C.perShift + ' visitors per shift, store: ' + (docstore.isOn() ? 'MySQL documents' : 'files (prototype mode)')));
|
||||||
})().catch(e => { console.error('start failed:', e.message); process.exit(1); });
|
})().catch(e => { console.error('start failed:', e.message); process.exit(1); });
|
||||||
process.on('SIGINT', () => { store.flush(); process.exit(0); });
|
process.on('SIGINT', () => { store.flush(); process.exit(0); });
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ const CALLS = new Interface(['function quoteWei(uint256 sku, uint256 qty) view r
|
|||||||
const TYPES = { Voucher: [{ name: 'buyer', type: 'address' }, { name: 'sponsor', type: 'address' }, { name: 'deadline', type: 'uint256' }] };
|
const TYPES = { Voucher: [{ name: 'buyer', type: 'address' }, { name: 'sponsor', type: 'address' }, { name: 'deadline', type: 'uint256' }] };
|
||||||
const st = { polls: 0, credited: 0, dupes: 0, ignored: 0, errors: 0, lastError: null, head: null };
|
const st = { polls: 0, credited: 0, dupes: 0, ignored: 0, errors: 0, lastError: null, head: null };
|
||||||
let C = null, keeper = null, busy = false, timer = null;
|
let C = null, keeper = null, busy = false, timer = null;
|
||||||
|
const hooks = { onPurchase: null }; // proof.js: ledger split + Telegram card per newly credited purchase (2026-11-14)
|
||||||
|
function setHook(fn) { hooks.onPurchase = typeof fn === 'function' ? fn : null; }
|
||||||
|
|
||||||
function init(cfg) {
|
function init(cfg) {
|
||||||
C = cfg; keeper = null;
|
C = cfg; keeper = null;
|
||||||
@@ -53,6 +55,7 @@ function apply(ev) {
|
|||||||
P[key] = { at: Date.now(), blockAt: ev.blockAt || null, block: ev.block, orderId: ev.orderId, buyer: a, sku: ev.sku, qty: ev.qty, ref: ev.ref, credits: ev.credits, usdCents: ev.usdCents,
|
P[key] = { at: Date.now(), blockAt: ev.blockAt || null, block: ev.block, orderId: ev.orderId, buyer: a, sku: ev.sku, qty: ev.qty, ref: ev.ref, credits: ev.credits, usdCents: ev.usdCents,
|
||||||
weiPaid: ev.weiPaid, sponsor: ev.sponsor, sponsorPaid: ev.sponsorPaid, applied };
|
weiPaid: ev.weiPaid, sponsor: ev.sponsor, sponsorPaid: ev.sponsorPaid, applied };
|
||||||
store.save(); st.credited++;
|
store.save(); st.credited++;
|
||||||
|
if (hooks.onPurchase) { try { hooks.onPurchase(P[key], String(ev.txHash).toLowerCase()); } catch (e) {} }
|
||||||
console.log('shop: order', ev.orderId, 'sku', ev.sku, 'x' + ev.qty, a, applied === 'credits' ? '+' + ev.credits + ' credits' : applied);
|
console.log('shop: order', ev.orderId, 'sku', ev.sku, 'x' + ev.qty, a, applied === 'credits' ? '+' + ev.credits + ' credits' : applied);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -146,4 +149,4 @@ function view() {
|
|||||||
return Object.assign({ contract: C ? C.contractAddress || null : null, watching: watching(), vouchers: voucherOn(), keeper: keeper ? keeper.address : null,
|
return Object.assign({ contract: C ? C.contractAddress || null : null, watching: watching(), vouchers: voucherOn(), keeper: keeper ? keeper.address : null,
|
||||||
lastBlock: ((store.state() || {}).shop || {}).lastBlock ?? null, purchases: list.length, creditsSold: list.reduce((t, x) => t + (x.credits || 0), 0), unmatched: list.filter(x => x.applied === 'unmatched').length }, st);
|
lastBlock: ((store.state() || {}).shop || {}).lastBlock ?? null, purchases: list.length, creditsSold: list.reduce((t, x) => t + (x.credits || 0), 0), unmatched: list.filter(x => x.applied === 'unmatched').length }, st);
|
||||||
}
|
}
|
||||||
module.exports = { init, voucher, voucherOn, watching, apply, poll, view, quote, order, receipt, fees, nudge, call, rpc, weekSales, TOPIC, IFACE, TYPES, CALLS };
|
module.exports = { setHook, init, voucher, voucherOn, watching, apply, poll, view, quote, order, receipt, fees, nudge, call, rpc, weekSales, TOPIC, IFACE, TYPES, CALLS };
|
||||||
|
|||||||
@@ -106,6 +106,8 @@ const SESSION_TTL = 7 * 24 * 3600000;
|
|||||||
function mintSession(address) { const token = crypto.randomBytes(32).toString('hex'); S.sessions[token] = { address: address.toLowerCase(), expires: Date.now() + SESSION_TTL }; save(); return token; }
|
function mintSession(address) { const token = crypto.randomBytes(32).toString('hex'); S.sessions[token] = { address: address.toLowerCase(), expires: Date.now() + SESSION_TTL }; save(); return token; }
|
||||||
function session(token) { const s = token && S.sessions[token]; return s && s.expires > Date.now() ? Object.assign({ token }, s) : null; }
|
function session(token) { const s = token && S.sessions[token]; return s && s.expires > Date.now() ? Object.assign({ token }, s) : null; }
|
||||||
function dropSession(token) { delete S.sessions[token]; save(); }
|
function dropSession(token) { delete S.sessions[token]; save(); }
|
||||||
|
// network hub events (hubevents.js, 2026-11-16): end every session `match` names that was made before `before` -> how many
|
||||||
|
function endSessions(match, before) { let n = 0; for (const [k, x] of Object.entries(S.sessions)) if (x.expires - SESSION_TTL <= before && match(x)) { delete S.sessions[k]; n++; } if (n) save(); return n; }
|
||||||
|
|
||||||
module.exports = { SPLITS, load, flush, save, state, ctDay, ctWeek, bump, today, banner, addBanner, saveBanner, bannersOf, addLedger, ledger,
|
module.exports = { SPLITS, load, flush, save, state, ctDay, ctWeek, bump, today, banner, addBanner, saveBanner, bannersOf, addLedger, ledger,
|
||||||
addVisit, visits, pruneVisits, member, upsertMember, memberByName, members, mintSession, session, dropSession, SESSION_TTL };
|
addVisit, visits, pruneVisits, member, upsertMember, memberByName, members, mintSession, session, dropSession, endSessions, SESSION_TTL };
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
// Promo kit art for Downline Banners and Viral Banner Blitz (2026-11-14). Renders every creative from HTML with Playwright so
|
// Promo kit art for Downline Banners and Viral Banner Blitz (2026-11-14). Renders every creative from HTML with Playwright so
|
||||||
// the text is crisp, at the exact pixel size of each slot. Same file in both repos (banner-line/app/tools, vbb/app/tools).
|
// the text is crisp, at the exact pixel size of each slot. Same file in both repos (banner-line/app/tools, vbb/app/tools).
|
||||||
// node tools/kit-art.mjs dlb|vbb|all
|
// node tools/kit-art.mjs dlb|vbb|all [shape,shape...] (a shape list renders only those shapes, e.g. panel,pillar)
|
||||||
|
// Env DLB_APP / VBB_APP = the app folder to read the mark from and write into (default the repos under D:/Projects/HighRisk).
|
||||||
|
// Shapes per site: DLB also has pillar (120x600, Marty 2026-11-16); panel (336x280) on both; wide (600x300) and small
|
||||||
|
// (250x250) on both (member request 2026-11-18). sm = the short headline for the small square (6 words max).
|
||||||
// Output: <app>/public/art/kit/<site>-<angle>-<shape>.png. Neutral names on purpose: no IAB size tokens, no "banner"/"ad"
|
// Output: <app>/public/art/kit/<site>-<angle>-<shape>.png. Neutral names on purpose: no IAB size tokens, no "banner"/"ad"
|
||||||
// (EasyList hides those). The copy here must match the facts in each app (DLB SPEC.md + contract, VBB config.js + how.html).
|
// (EasyList hides those). The copy here must match the facts in each app (DLB SPEC.md + contract, VBB config.js + how.html).
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
@@ -10,34 +13,36 @@ const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_
|
|||||||
const pwm = await import(pathToFileURL(PW).href); const chromium = pwm.chromium || (pwm.default && pwm.default.chromium);
|
const pwm = await import(pathToFileURL(PW).href); const chromium = pwm.chromium || (pwm.default && pwm.default.chromium);
|
||||||
|
|
||||||
const ROOT = 'D:/Projects/HighRisk';
|
const ROOT = 'D:/Projects/HighRisk';
|
||||||
const SHAPES = { tile: [125, 125], strip: [468, 60], leader: [728, 90], box: [300, 250], tower: [160, 600], social: [1200, 630], square: [1080, 1080] };
|
const SHAPES = { tile: [125, 125], strip: [468, 60], leader: [728, 90], box: [300, 250], panel: [336, 280], tower: [160, 600], pillar: [120, 600], social: [1200, 630], square: [1080, 1080], wide: [600, 300], small: [250, 250] };
|
||||||
|
const SITE_SHAPES = { dlb: Object.keys(SHAPES), vbb: Object.keys(SHAPES).filter(k => k !== 'pillar') };
|
||||||
|
const APPS = { dlb: process.env.DLB_APP || ROOT + '/banner-line/app', vbb: process.env.VBB_APP || ROOT + '/vbb/app' };
|
||||||
|
|
||||||
const SITES = {
|
const SITES = {
|
||||||
dlb: {
|
dlb: {
|
||||||
out: ROOT + '/banner-line/app/public/art/kit', domain: 'downlinebanners.com', name: ['Downline', 'Banners'],
|
out: APPS.dlb + '/public/art/kit', domain: 'downlinebanners.com', name: ['Downline', 'Banners'],
|
||||||
mark: fs.readFileSync(ROOT + '/banner-line/app/public/art/mark.svg', 'utf8'),
|
mark: fs.readFileSync(APPS.dlb + '/public/art/mark.svg', 'utf8'),
|
||||||
fonts: 'family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Inter:wght@500;600;700',
|
fonts: 'family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Inter:wght@500;600;700',
|
||||||
angles: {
|
angles: {
|
||||||
spot: { eyebrow: '$5 spot', h1: 'A $5 spot.', h2: '300 guaranteed views.', line: 'A $5 spot. 300 guaranteed views.', sub: 'Your banner on the board, paid on-chain on Polygon.', cta: 'Get a spot', tA: '$5 spot', tB: '300 views', chips: ['$5 spot', '300 guaranteed views', 'Paid on-chain'] },
|
spot: { eyebrow: '$5 spot', h1: 'A $5 spot.', h2: '300 guaranteed views.', line: 'A $5 spot. 300 guaranteed views.', sub: 'Your banner on the board, paid on-chain on Polygon.', cta: 'Get a spot', tA: '$5 spot', tB: '300 views', sm: ['A $5 spot.', '300 guaranteed views.'], chips: ['$5 spot', '300 guaranteed views', 'Paid on-chain'] },
|
||||||
line: { eyebrow: '10 levels', h1: '10 levels pay', h2: 'as spots sell after yours.', line: '10 levels pay as spots sell after yours', sub: 'Sponsor 30%. Each of 10 levels 5.5%. Fixed in the contract.', cta: 'See the line', tA: '10 levels', tB: 'paid on-chain', chips: ['Sponsor 30%', '10 levels x 5.5%', 'Splits fixed on-chain'] },
|
line: { eyebrow: '10 levels', h1: '10 levels pay', h2: 'as spots sell after yours.', line: '10 levels pay as spots sell after yours', sub: 'Sponsor 30%. Each of 10 levels 5.5%. Fixed in the contract.', cta: 'See the line', tA: '10 levels', tB: 'paid on-chain', sm: ['10 levels', 'paid on chain.'], chips: ['Sponsor 30%', '10 levels x 5.5%', 'Splits fixed on-chain'] },
|
||||||
instant: { eyebrow: 'Nothing to withdraw', h1: 'No withdrawals.', h2: 'Paid in the same transaction.', line: 'No withdrawals. Paid in the same transaction.', sub: 'A Polygon contract splits every $5 spot the moment it sells.', cta: 'See how', tA: 'No withdrawals', tB: 'paid same tx', chips: ['Same-transaction payouts', 'Verified contract', '$5 spot'] }
|
instant: { eyebrow: 'Nothing to withdraw', h1: 'No withdrawals.', h2: 'Paid in the same transaction.', line: 'No withdrawals. Paid in the same transaction.', sub: 'A Polygon contract splits every $5 spot the moment it sells.', cta: 'See how', tA: 'No withdrawals', tB: 'paid same tx', sm: ['No withdrawals.', 'Paid as it sells.'], chips: ['Same-transaction payouts', 'Verified contract', '$5 spot'] }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
vbb: {
|
vbb: {
|
||||||
out: ROOT + '/vbb/app/public/art/kit', domain: 'viralbannerblitz.com', name: ['Viral Banner', 'Blitz'],
|
out: APPS.vbb + '/public/art/kit', domain: 'viralbannerblitz.com', name: ['Viral Banner', 'Blitz'],
|
||||||
mark: fs.readFileSync(ROOT + '/vbb/app/public/art/mark.svg', 'utf8'),
|
mark: fs.readFileSync(APPS.vbb + '/public/art/mark.svg', 'utf8'),
|
||||||
fonts: 'family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@500;700&family=Space+Mono:wght@700',
|
fonts: 'family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@500;700&family=Space+Mono:wght@700',
|
||||||
angles: {
|
angles: {
|
||||||
free: { eyebrow: 'Free daily post', h1: 'Post a banner', h2: 'free every day.', line: 'Post a banner free every day', sub: 'InstantAdPay and LinkSpin members get a free post credit each day they sign in.', cta: 'Post yours', tA: 'FREE', tB: 'daily post', chips: ['125x125 banners', 'Free daily post', 'No subscription'] },
|
free: { eyebrow: 'Free daily post', h1: 'Post a banner', h2: 'free every day.', line: 'Post a banner free every day', sub: 'InstantAdPay and LinkSpin members get a free post credit each day they sign in.', cta: 'Post yours', tA: 'FREE', tB: 'daily post', sm: ['Post a banner', 'free every day.'], chips: ['125x125 banners', 'Free daily post', 'No subscription'] },
|
||||||
loop: { eyebrow: 'Real visitors only', h1: 'Every visitor', h2: 'pushes the loop.', line: 'Every visitor pushes the loop', sub: 'Real visitors move every banner forward. Ride out and earn network ad views.', cta: 'Join the loop', tA: 'Every visit', tB: 'moves it', chips: ['Verified visitors', 'Bots do not count', 'Network ad views'] },
|
loop: { eyebrow: 'Real visitors only', h1: 'Every visitor', h2: 'pushes the loop.', line: 'Every visitor pushes the loop', sub: 'Real visitors move every banner forward. Ride out and earn network ad views.', cta: 'Join the loop', tA: 'Every visit', tB: 'moves it', sm: ['Every visitor', 'pushes the loop.'], chips: ['Verified visitors', 'Bots do not count', 'Network ad views'] },
|
||||||
prize: { eyebrow: 'Weekly leaderboards', h1: 'Send visitors.', h2: 'Climb the weekly board.', line: 'Weekly prizes, at least $20 a week', sub: 'Prize pot of at least $20 a week, paid in POL to the top three on each board.', cta: 'See the leaders', tA: 'Weekly', tB: 'prizes', chips: ['At least $20 a week', 'Paid in POL', 'Two leaderboards'] }
|
prize: { eyebrow: 'Weekly leaderboards', h1: 'Send visitors.', h2: 'Climb the weekly board.', line: 'Weekly prizes, at least $20 a week', sub: 'Prize pot of at least $20 a week, paid in POL to the top three on each board.', wsub: 'A weekly prize pot, paid in POL to the top three on each board.', cta: 'See the leaders', tA: 'Weekly', tB: 'prizes', sm: ['Send visitors.', 'Climb the board.'], chips: ['At least $20 a week', 'Paid in POL', 'Two leaderboards'] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||||
// shrink every .fit element until its text fits its box (one line or the box height)
|
// shrink every .fit element until its text fits its box (one line or the box height); .wfit (wrapping) until its longest word fits
|
||||||
const FIT = `<script>window.__fit=()=>{document.querySelectorAll('.fit').forEach(el=>{let s=parseFloat(getComputedStyle(el).fontSize);let n=0;while((el.scrollWidth>el.clientWidth+1||el.scrollHeight>el.clientHeight+s*0.2)&&s>6&&n++<200){s-=0.5;el.style.fontSize=s+'px';}});};</script>`;
|
const FIT = `<script>window.__fit=()=>{document.querySelectorAll('.fit').forEach(el=>{let s=parseFloat(getComputedStyle(el).fontSize);let n=0;while((el.scrollWidth>el.clientWidth+1||el.scrollHeight>el.clientHeight+s*0.2)&&s>6&&n++<200){s-=0.5;el.style.fontSize=s+'px';}});document.querySelectorAll('.wfit').forEach(el=>{let s=parseFloat(getComputedStyle(el).fontSize);let n=0;while(el.scrollWidth>el.clientWidth+1&&s>8&&n++<100){s-=0.5;el.style.fontSize=s+'px';}});};</script>`;
|
||||||
|
|
||||||
function dlbCss() {
|
function dlbCss() {
|
||||||
return `
|
return `
|
||||||
@@ -121,6 +126,25 @@ function body(site, a, shape) {
|
|||||||
.b .sub{font-size:12.5px;line-height:1.35}
|
.b .sub{font-size:12.5px;line-height:1.35}
|
||||||
.b .cta{font-size:15px;padding:10px 16px;margin-top:auto;align-self:flex-start} ${d ? '' : 'body{--edge:3px;--stroke:.5px;--ts:1.5px}'}
|
.b .cta{font-size:15px;padding:10px 16px;margin-top:auto;align-self:flex-start} ${d ? '' : 'body{--edge:3px;--stroke:.5px;--ts:1.5px}'}
|
||||||
</style><div class="b"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2.replace('<span class="', '<span class="') }</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)} →</span></div>`;
|
</style><div class="b"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2.replace('<span class="', '<span class="') }</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)} →</span></div>`;
|
||||||
|
case 'panel': return `<style>
|
||||||
|
.b{position:absolute;inset:0;display:flex;flex-direction:column;padding:18px 20px;gap:10px}
|
||||||
|
.b .top{display:flex;align-items:center;gap:9px} .b .mark{width:38px;height:38px;flex:none} .b .wm{font-size:19px}
|
||||||
|
.b .eb{font-size:11px;padding:4px 10px;align-self:flex-start}
|
||||||
|
.b .h{font-size:31px;width:100%;white-space:normal;max-height:68px} .b .h span{display:block;white-space:nowrap}
|
||||||
|
.b .sub{font-size:14px;line-height:1.35}
|
||||||
|
.b .bot{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:10px}
|
||||||
|
.b .cta{font-size:16px;padding:10px 17px} .b .dom{font-size:11.5px;font-weight:700;opacity:.8;white-space:nowrap}
|
||||||
|
${d ? '' : 'body{--edge:3px;--stroke:.5px;--ts:1.5px}'}
|
||||||
|
</style><div class="b"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><div class="bot"><span class="cta">${esc(a.cta)} →</span><span class="dom">${esc(S.domain)}</span></div></div>`;
|
||||||
|
case 'pillar': return `<style>
|
||||||
|
.v{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;text-align:center;padding:18px 8px 16px;gap:11px}
|
||||||
|
.v .mark{width:52px;height:52px} .v .wm{font-size:15px;white-space:normal;line-height:1.05}
|
||||||
|
.v .eb{font-size:8px;padding:4px 6px;letter-spacing:.06em;max-width:104px;white-space:normal;line-height:1.2}
|
||||||
|
.v .h{font-size:24px;line-height:1.05;white-space:normal;width:106px;overflow:hidden;overflow-wrap:normal} .v .h span{display:block}
|
||||||
|
.v .sub{font-size:12px;line-height:1.38}
|
||||||
|
.v .cta{font-size:13px;padding:9px 11px;margin-top:auto} .v .dom{font-size:9px;font-weight:700;opacity:.8}
|
||||||
|
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px} .v .wm b{display:block}'}
|
||||||
|
</style><div class="v">${m}${d ? '<span class="wm">Downline<br><span class="g">Banners</span></span>' : '<span class="wm">Viral Banner <b>Blitz</b></span>'}<span class="eb">${esc(a.eyebrow)}</span><div class="h disp wfit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)}</span><div class="dom">${esc(S.domain)}</div></div>`;
|
||||||
case 'tower': return `<style>
|
case 'tower': return `<style>
|
||||||
.v{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;text-align:center;padding:22px 12px 20px;gap:12px}
|
.v{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;text-align:center;padding:22px 12px 20px;gap:12px}
|
||||||
.v .mark{width:64px;height:64px} .v .wm{font-size:17px;white-space:normal;line-height:1.05}
|
.v .mark{width:64px;height:64px} .v .wm{font-size:17px;white-space:normal;line-height:1.05}
|
||||||
@@ -130,6 +154,23 @@ function body(site, a, shape) {
|
|||||||
.v .cta{font-size:15px;padding:11px 14px;margin-top:auto} .v .dom{font-size:10.5px;font-weight:700;opacity:.8}
|
.v .cta{font-size:15px;padding:11px 14px;margin-top:auto} .v .dom{font-size:10.5px;font-weight:700;opacity:.8}
|
||||||
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px} .v .wm b{display:block}'}
|
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px} .v .wm b{display:block}'}
|
||||||
</style><div class="v">${m}${d ? '<span class="wm">Downline<br><span class="g">Banners</span></span>' : '<span class="wm">Viral Banner <b>Blitz</b></span>'}<span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)}</span><div class="dom">${esc(S.domain)}</div></div>`;
|
</style><div class="v">${m}${d ? '<span class="wm">Downline<br><span class="g">Banners</span></span>' : '<span class="wm">Viral Banner <b>Blitz</b></span>'}<span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.sub)}</div><span class="cta">${esc(a.cta)}</span><div class="dom">${esc(S.domain)}</div></div>`;
|
||||||
|
case 'wide': return `<style>
|
||||||
|
.w2{position:absolute;inset:0;display:flex;flex-direction:column;padding:24px 28px;gap:11px;${d ? '' : 'width:420px'}}
|
||||||
|
.w2 .top{display:flex;align-items:center;gap:10px} .w2 .mark{width:40px;height:40px;flex:none} .w2 .wm{font-size:21px}
|
||||||
|
.w2 .eb{font-size:11px;padding:4px 11px;align-self:flex-start}
|
||||||
|
.w2 .h{font-size:40px;width:${d ? 544 : 370}px;white-space:normal;max-height:88px} .w2 .h span{display:block;white-space:nowrap}
|
||||||
|
.w2 .sub{font-size:15px;line-height:1.35;max-width:${d ? 520 : 360}px}
|
||||||
|
.w2 .bot{margin-top:auto;display:flex;align-items:center;gap:16px}
|
||||||
|
.w2 .cta{font-size:17px;padding:10px 18px} .w2 .dom{font-size:12.5px;font-weight:700;opacity:.8;white-space:nowrap}
|
||||||
|
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px} .tiles{right:-26px;top:34px;width:200px;--tg:12px} .tiles i{border-radius:10px;box-shadow:4px 4px 0 var(--ink)}'}
|
||||||
|
</style>${d ? '' : vTiles(9)}<div class="w2"><div class="top">${m}${wm}</div><span class="eb">${esc(a.eyebrow)}</span><div class="h disp fit"><span>${esc(a.h1)}</span>${h2}</div><div class="sub">${esc(a.wsub || a.sub)}</div><div class="bot"><span class="cta">${esc(a.cta)} →</span><span class="dom">${esc(S.domain)}</span></div></div>`;
|
||||||
|
case 'small': return `<style>
|
||||||
|
.q2{position:absolute;inset:0;display:flex;flex-direction:column;padding:16px 17px;gap:12px}
|
||||||
|
.q2 .top{display:flex;align-items:center;gap:8px} .q2 .mark{width:30px;height:30px;flex:none} .q2 .wm{font-size:16px}
|
||||||
|
.q2 .h{font-size:29px;width:216px;white-space:normal;margin-top:4px;line-height:1.04} .q2 .h span{display:block}
|
||||||
|
.q2 .cta{font-size:16px;padding:10px 16px;margin-top:auto;align-self:flex-start}
|
||||||
|
${d ? '' : 'body{--edge:3px;--stroke:.6px;--ts:2px}'}
|
||||||
|
</style><div class="q2"><div class="top">${m}${wm}</div><div class="h disp wfit"><span>${esc(a.sm[0])}</span>${d ? '<span class="g">' + esc(a.sm[1]) + '</span>' : '<span class="hot">' + esc(a.sm[1]) + '</span>'}</div><span class="cta">${esc(a.cta)} →</span></div>`;
|
||||||
case 'social': return d ? `<style>
|
case 'social': return d ? `<style>
|
||||||
.o{position:absolute;inset:0;padding:64px 80px;display:flex;flex-direction:column}
|
.o{position:absolute;inset:0;padding:64px 80px;display:flex;flex-direction:column}
|
||||||
.o .top{display:flex;align-items:center;gap:26px} .o .mark{width:118px;height:118px} .o .wm{font-size:60px}
|
.o .top{display:flex;align-items:center;gap:26px} .o .mark{width:118px;height:118px} .o .wm{font-size:60px}
|
||||||
@@ -176,12 +217,14 @@ function page(site, angle, shape) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const which = process.argv[2] || 'all';
|
const which = process.argv[2] || 'all';
|
||||||
|
const only = process.argv[3] ? process.argv[3].split(',') : null;
|
||||||
const browser = await chromium.launch();
|
const browser = await chromium.launch();
|
||||||
const made = []; let file0;
|
const made = []; let file0;
|
||||||
for (const site of Object.keys(SITES)) {
|
for (const site of Object.keys(SITES)) {
|
||||||
if (which !== 'all' && which !== site) continue;
|
if (which !== 'all' && which !== site) continue;
|
||||||
const S = SITES[site]; fs.mkdirSync(S.out, { recursive: true });
|
const S = SITES[site]; fs.mkdirSync(S.out, { recursive: true });
|
||||||
for (const angle of Object.keys(S.angles)) for (const shape of Object.keys(SHAPES)) {
|
for (const angle of Object.keys(S.angles)) for (const shape of SITE_SHAPES[site]) {
|
||||||
|
if (only && !only.includes(shape)) continue;
|
||||||
const [w, h] = SHAPES[shape];
|
const [w, h] = SHAPES[shape];
|
||||||
const pg = await browser.newPage({ viewport: { width: w, height: h }, deviceScaleFactor: 1 });
|
const pg = await browser.newPage({ viewport: { width: w, height: h }, deviceScaleFactor: 1 });
|
||||||
await pg.setContent(page(site, angle, shape), { waitUntil: 'networkidle' });
|
await pg.setContent(page(site, angle, shape), { waitUntil: 'networkidle' });
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// Telegram proof cards for Viral Banner Blitz (trust pack 2026-11-14): three 1200x630 images in the VBB pop-art look, rotated by
|
||||||
|
// proof.js per purchase post (the live numbers go in the caption). Neutral file names (no "banner"/"ad"/size tokens).
|
||||||
|
// node tools/proof-art.mjs -> public/art/proof/vbb-proof-{pink,blue,yellow}.png
|
||||||
|
import { pathToFileURL } from 'url';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright/index.js';
|
||||||
|
const pwm = await import(pathToFileURL(PW).href); const chromium = pwm.chromium || (pwm.default && pwm.default.chromium);
|
||||||
|
const APP = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, '$1')), '..');
|
||||||
|
const OUT = path.join(APP, 'public', 'art', 'proof'); fs.mkdirSync(OUT, { recursive: true });
|
||||||
|
const mark = fs.readFileSync(path.join(APP, 'public', 'art', 'mark.svg'), 'utf8');
|
||||||
|
const V = { pink: ['#ff2d87', '#fff', '#ffd400'], blue: ['#2b59ff', '#fff', '#14d9a0'], yellow: ['#ffd400', '#14121f', '#ff2d87'] };
|
||||||
|
const COLORS = ['#ff2d87', '#2b59ff', '#ffd400', '#14d9a0', '#ffffff', '#ff2d87', '#14d9a0', '#2b59ff', '#ffd400'];
|
||||||
|
const html = ([acc, accInk, acc2]) => `<!doctype html><html><head><meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=DM+Sans:wght@500;700&family=Space+Mono:wght@700&display=swap">
|
||||||
|
<style>
|
||||||
|
*{box-sizing:border-box;margin:0;padding:0} html,body{width:1200px;height:630px;overflow:hidden}
|
||||||
|
body{font-family:"DM Sans",sans-serif;color:#14121f;background:#fff4dc;position:relative;
|
||||||
|
background-image:radial-gradient(rgba(255,45,135,.18) 1.4px,transparent 1.6px),radial-gradient(rgba(43,89,255,.13) 1.4px,transparent 1.6px);background-size:22px 22px,22px 22px;background-position:0 0,11px 11px}
|
||||||
|
body::after{content:"";position:absolute;inset:0;border:6px solid #14121f}
|
||||||
|
.top{position:absolute;left:56px;top:46px;display:flex;align-items:center;gap:14px}
|
||||||
|
.top .m{width:62px;height:62px} .top .m svg{width:100%;height:100%}
|
||||||
|
.wm{font:800 34px "Bricolage Grotesque";letter-spacing:-.03em} .wm b{color:#ff2d87;-webkit-text-stroke:1px #14121f}
|
||||||
|
.eb{position:absolute;left:56px;top:142px;font:700 18px "Space Mono";letter-spacing:.1em;text-transform:uppercase;background:#14d9a0;border:3px solid #14121f;border-radius:999px;padding:9px 18px;box-shadow:4px 4px 0 #14121f;transform:rotate(-1.5deg)}
|
||||||
|
h1{position:absolute;left:56px;top:205px;width:700px;font:800 82px/0.98 "Bricolage Grotesque";letter-spacing:-.035em}
|
||||||
|
h1 em{font-style:normal;color:${acc};-webkit-text-stroke:2px #14121f;text-shadow:5px 5px 0 ${acc2}}
|
||||||
|
.split{position:absolute;left:56px;bottom:62px;display:flex;gap:14px}
|
||||||
|
.split span{font:800 24px "Bricolage Grotesque";border:3px solid #14121f;border-radius:14px;padding:12px 18px;box-shadow:5px 5px 0 #14121f;background:#fff}
|
||||||
|
.split span:nth-child(1){background:${acc};color:${accInk}} .split span:nth-child(2){background:#dbe4ff} .split span:nth-child(3){background:#c9f7e6}
|
||||||
|
.tiles{position:absolute;right:58px;top:118px;display:grid;grid-template-columns:repeat(3,112px);gap:16px}
|
||||||
|
.tiles i{display:block;width:112px;height:112px;border:3.5px solid #14121f;border-radius:14px;box-shadow:6px 6px 0 #14121f}
|
||||||
|
.url{position:absolute;right:58px;bottom:62px;font:700 20px "Space Mono";background:#14121f;color:#fff;border-radius:10px;padding:10px 14px}
|
||||||
|
</style></head><body>
|
||||||
|
<div class="top"><div class="m">${mark}</div><span class="wm">Viral Banner <b>Blitz</b></span></div>
|
||||||
|
<span class="eb">New purchase · paid on-chain</span>
|
||||||
|
<h1>Split in the <em>same transaction.</em></h1>
|
||||||
|
<div class="split"><span>30% sponsor</span><span>10% weekly prizes</span><span>60% VBB</span></div>
|
||||||
|
<div class="tiles">${COLORS.map((c, i) => `<i style="background:${c};transform:rotate(${((i * 37) % 7) - 3}deg)"></i>`).join('')}</div>
|
||||||
|
<span class="url">viralbannerblitz.com/ledger</span>
|
||||||
|
</body></html>`;
|
||||||
|
const b = await chromium.launch(); const pg = await b.newPage({ viewport: { width: 1200, height: 630 } });
|
||||||
|
for (const [k, v] of Object.entries(V)) {
|
||||||
|
await pg.setContent(html(v), { waitUntil: 'networkidle' }); await pg.evaluate(() => document.fonts.ready);
|
||||||
|
const f = path.join(OUT, 'vbb-proof-' + k + '.png'); await pg.screenshot({ path: f }); console.log('wrote', f, fs.statSync(f).size);
|
||||||
|
}
|
||||||
|
await b.close();
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// Network Weekend (Marty 2026-11-17): Black Friday to Cyber Monday 2026, Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, exact instants
|
||||||
|
// (late November is CST, UTC-6). Switches on and off by itself; nothing to flip on the server.
|
||||||
|
// On this site: 2 free post credits a day for network members (FREE_CREDITS_PER_DAY stays the normal value, 1).
|
||||||
|
// The $10 pack's 50 credits are NOT here: that is the VBBShop SKU the owner wallet sets (see chainskus.js, the pages read it live).
|
||||||
|
// WEEKEND_NOW (ISO time) is the test clock: tests only, never set it on the server.
|
||||||
|
'use strict';
|
||||||
|
const START = Date.parse('2026-11-27T06:00:00Z'); // Fri 11-27 00:00 CT
|
||||||
|
const END = Date.parse('2026-12-01T06:00:00Z'); // Tue 12-01 00:00 CT
|
||||||
|
const FREE_PER_DAY = 2;
|
||||||
|
function now() { const o = process.env.WEEKEND_NOW; const t = o ? Date.parse(o) : NaN; return Number.isNaN(t) ? Date.now() : t; }
|
||||||
|
function on(ms) { ms = ms == null ? now() : ms; return ms >= START && ms < END; }
|
||||||
|
// free post credits per Central day: the weekend number while it runs, else the normal setting
|
||||||
|
function freePerDay(base, ms) { return on(ms) ? Math.max(Number(base) || 0, FREE_PER_DAY) : Number(base) || 0; }
|
||||||
|
// the ribbon's VBB deal line from live values: the biggest pack's credits as the contract holds them (chainskus.js) against the
|
||||||
|
// normal CREDIT_PACKS number, and today's free credits. Nothing true to say (the owner has not switched the SKU yet and it is not
|
||||||
|
// the weekend) = null, so the ribbon shows no VBB line rather than a wrong one.
|
||||||
|
function dealLine(C, d) {
|
||||||
|
const live = require('./chainskus').packs(C);
|
||||||
|
const big = live.slice().sort((a, b) => b.usd - a.usd)[0]; const base = (C.packs.slice().sort((a, b) => b.usd - a.usd)[0] || {}).credits;
|
||||||
|
const free = freePerDay(C.freeCreditsPerDay); const parts = [];
|
||||||
|
if (big && base && big.credits > base) parts.push('The $' + big.usd + ' pack carries ' + big.credits + ' credits instead of ' + base);
|
||||||
|
if (free > C.freeCreditsPerDay) parts.push((parts.length ? 'and network' : 'Network') + ' members get ' + free + ' free post credits a day');
|
||||||
|
if (!parts.length) return null;
|
||||||
|
const x = Object.assign({}, d, { text: parts.join(', ') + '.' }); delete x.byDay; return x;
|
||||||
|
}
|
||||||
|
module.exports = { START, END, FREE_PER_DAY, now, on, freePerDay, dealLine };
|
||||||