From 3e0dee517d48f0a4c28fb4e18d0c0507c5086142 Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 17 Nov 2026 07:26:05 -0600 Subject: [PATCH] Network Weekend (Marty 2026-11-17): 2 free post credits a day Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, live VBBShop SKU values on every page and in the chatbot, the network ribbon weekend.js: the date gate (WEEKEND_NOW test clock), FREE_CREDITS_PER_DAY stays 1. chainskus.js: skus() read every 60 s, so the $10 pack shows what the contract credits (50 once the owner signs setSku, 40 before or after). netdeals.js + /assets/netweekend.js: /api/network-deals and the ribbon; the VBB line is built from live values and drops itself if there is nothing true to say. chatcore render hook, chatbot FACTS/CANNED from live values with a dated weekend fact. qa/weekend.test.mjs 33 pass, chatbot 182, smoke 268. common.js?v=10, my.js?v=6, packages.js?v=2. Co-Authored-By: Claude Opus 5.5 --- chainskus.js | 37 ++++++++++++++++++++ chatbot.js | 36 ++++++++++++++++---- chatcore.js | 8 +++-- netdeals.js | 54 ++++++++++++++++++++++++++++++ public/admin.html | 2 +- public/assets/common.js | 2 ++ public/assets/my.js | 4 +-- public/assets/netweekend.js | 67 +++++++++++++++++++++++++++++++++++++ public/assets/packages.js | 2 ++ public/contract.html | 2 +- public/disclaimer.html | 2 +- public/how.html | 2 +- public/index.html | 2 +- public/leaders.html | 2 +- public/ledger.html | 2 +- public/my.html | 4 +-- public/packages.html | 6 ++-- public/privacy.html | 2 +- public/promote.html | 2 +- public/terms.html | 2 +- qa/weekend.test.mjs | 60 +++++++++++++++++++++++++++++++++ server.js | 20 ++++++++--- weekend.js | 26 ++++++++++++++ 23 files changed, 314 insertions(+), 32 deletions(-) create mode 100644 chainskus.js create mode 100644 netdeals.js create mode 100644 public/assets/netweekend.js create mode 100644 qa/weekend.test.mjs create mode 100644 weekend.js diff --git a/chainskus.js b/chainskus.js new file mode 100644 index 0000000..f9d7af3 --- /dev/null +++ b/chainskus.js @@ -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 }) }; diff --git a/chatbot.js b/chatbot.js index 2c5531f..5c789e7 100644 --- a/chatbot.js +++ b/chatbot.js @@ -13,11 +13,16 @@ const core = require('./chatcore'); const C = require('./config').get(); -const KNOWLEDGE_DATE = '2026-11-15'; +const KNOWLEDGE_DATE = '2026-11-17'; 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 packs = C.packs.map(p => p.credits + ' post credits for $' + p.usd).join(' or '); +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 = [ @@ -83,21 +88,38 @@ const 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 1 free post credit 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.', + '- 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): ' + packs + '; 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.', + '- 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.', '- PAGES: / (the loop), /how, /packages, /my (My Banners), /leaders, /promote, /ledger, /contract, /terms, /disclaimer, /privacy. 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 -].join('\n'); +].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, + 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 }; +module.exports = { init, handle: core.handle, answer: core.answer, KNOWLEDGE_DATE, CANNED, FAQ, SITE, FACTS, render }; diff --git a/chatcore.js b/chatcore.js index df23ff4..724599e 100644 --- a/chatcore.js +++ b/chatcore.js @@ -28,6 +28,8 @@ function key() { 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() { @@ -129,14 +131,14 @@ async function answerRaw(message, historyText) { 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: hit.answer, canned: true, kb: hit.id, handoff: true }; + 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: 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: c.a, canned: true }, c.handoff ? { handoff: true } : {}); + 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; diff --git a/netdeals.js b/netdeals.js new file mode 100644 index 0000000..e708583 --- /dev/null +++ b/netdeals.js @@ -0,0 +1,54 @@ +// 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). +function handle(req, res, self) { + 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: [] } }; } }; diff --git a/public/admin.html b/public/admin.html index 5587317..309c8c0 100644 --- a/public/admin.html +++ b/public/admin.html @@ -39,7 +39,7 @@ - + diff --git a/public/assets/common.js b/public/assets/common.js index e9148c2..9546a47 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,5 +1,7 @@ // Shared page helpers (VBB namespace, modelled on Downline Banners' common.js): nav, footer, toasts, fetch helpers. 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; const $ = id => document.getElementById(id); const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); diff --git a/public/assets/my.js b/public/assets/my.js index 417814b..d878e4f 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -160,8 +160,8 @@ 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)]] .map(x => '
' + esc(x[1]) + '' + esc(x[0]) + '
').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. ' : '') - + '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.'; + $('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. ' : '') + + ((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; $('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.' : ''); $('mine').innerHTML = d.banners.length ? '' : '

No banners yet. Post your first one above.

'; diff --git a/public/assets/netweekend.js b/public/assets/netweekend.js new file mode 100644 index 0000000..7bbb5d3 --- /dev/null +++ b/public/assets/netweekend.js @@ -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 +})(); diff --git a/public/assets/packages.js b/public/assets/packages.js index 41ec9f9..8a9ce80 100644 --- a/public/assets/packages.js +++ b/public/assets/packages.js @@ -5,6 +5,8 @@ const c = await VBB.getConfig().catch(() => ({})); const money = v => '$' + (Number.isInteger(v) ? v : Number(v).toFixed(2)); 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); 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); }); diff --git a/public/contract.html b/public/contract.html index 01d7119..73cadb4 100644 --- a/public/contract.html +++ b/public/contract.html @@ -50,7 +50,7 @@ - + diff --git a/public/disclaimer.html b/public/disclaimer.html index 19ff9f7..26bd7bc 100644 --- a/public/disclaimer.html +++ b/public/disclaimer.html @@ -34,7 +34,7 @@

Your decision

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.

Contact

Questions, problems or a request about your data: network support (TrustClickz).

- + diff --git a/public/how.html b/public/how.html index 5b1eabd..44e2313 100644 --- a/public/how.html +++ b/public/how.html @@ -55,7 +55,7 @@ - + diff --git a/public/index.html b/public/index.html index aaefc59..17ac8d7 100644 --- a/public/index.html +++ b/public/index.html @@ -56,7 +56,7 @@ - + diff --git a/public/leaders.html b/public/leaders.html index 258bde8..106cbaf 100644 --- a/public/leaders.html +++ b/public/leaders.html @@ -33,7 +33,7 @@ - + diff --git a/public/ledger.html b/public/ledger.html index 2a9b9fd..a91297f 100644 --- a/public/ledger.html +++ b/public/ledger.html @@ -35,7 +35,7 @@ - + diff --git a/public/my.html b/public/my.html index 10496f1..08a13c2 100644 --- a/public/my.html +++ b/public/my.html @@ -78,10 +78,10 @@ - + - + diff --git a/public/packages.html b/public/packages.html index 39f1b6c..c2b1a9e 100644 --- a/public/packages.html +++ b/public/packages.html @@ -40,13 +40,13 @@

Tokens

Network visits

Each token is a visit to your site from the network, at the InstantAdPay visit rate.

Coming soon

Where your payment goes

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.

-

Every network member (InstantAdPay or LinkSpin) also gets one free post credit each day they sign in.

Use my free credit
+

Every network member (InstantAdPay or LinkSpin) also gets one free post credit each day they sign in.

Use my free credit
- + - + diff --git a/public/privacy.html b/public/privacy.html index eae4bb3..e5a76d2 100644 --- a/public/privacy.html +++ b/public/privacy.html @@ -35,7 +35,7 @@

Your choices

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.

Contact

Questions, problems or a request about your data: network support (TrustClickz).

- + diff --git a/public/promote.html b/public/promote.html index b890593..6ab4944 100644 --- a/public/promote.html +++ b/public/promote.html @@ -34,7 +34,7 @@

Loading the kit...

- + diff --git a/public/terms.html b/public/terms.html index 4c14279..a26a759 100644 --- a/public/terms.html +++ b/public/terms.html @@ -40,7 +40,7 @@

Limits

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.

Contact

Questions, problems or a request about your data: network support (TrustClickz).

- + diff --git a/qa/weekend.test.mjs b/qa/weekend.test.mjs new file mode 100644 index 0000000..6415d1b --- /dev/null +++ b/qa/weekend.test.mjs @@ -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); diff --git a/server.js b/server.js index f312845..08a2ea3 100644 --- a/server.js +++ b/server.js @@ -26,6 +26,9 @@ const hubreport = require('./hubreport'); // network hub report by wallet (off u 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'); @@ -161,7 +164,7 @@ function grantDaily(m) { if (!netVerified(m)) return false; const day = store.ctDay(); if (m.freeDay === day) return 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; } store.save(); return granted; } @@ -172,7 +175,7 @@ function myData(addr) { 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 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), week: loop.memberWeek(m.address), share: 'https://' + C.site + '/?ref=' + encodeURIComponent(shareName) }; } @@ -286,7 +289,7 @@ const server = http.createServer(async (req, res) => { 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, 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 }); } // buying: the live price, gas fees for the wallet, and the confirmation wait (the Downline Banners endpoints) @@ -307,6 +310,7 @@ const server = http.createServer(async (req, res) => { 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/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') { @@ -524,7 +528,7 @@ const server = http.createServer(async (req, res) => { if (p === '/api/admin/status' && req.method === 'GET') { 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; - 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 }, 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 }, @@ -664,7 +668,12 @@ function splashFill() { fillCache = { key, at: Date.now(), out }; return out; } 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) { 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) @@ -681,6 +690,7 @@ function saveUpload(owner, buf, ext) { 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) + 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) // 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) diff --git a/weekend.js b/weekend.js new file mode 100644 index 0000000..68774ec --- /dev/null +++ b/weekend.js @@ -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 };