Network Weekend (Marty 2026-11-17): +3 board days per Boost bought Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, ribbon, chatbot facts

weekend.js (WEEKEND_BOOST_DAYS=0 off, WEEKEND_NOW test clock); wire.js stacks SKU days + the bonus by the purchase's chain time,
so it needs no contract change (the SKU holds 7 board days; a Boost is days, not views). /api/config, quote, order show the
weekend days. netdeals.js + /assets/netweekend.js ribbon via common.js (not admin, never framed), common.js?v=3. Chatbot FACTS line
and chatcore finish hook while live. qa/weekend.test.cjs; e2e 63/63.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 07:30:55 -06:00
parent def20f8ffe
commit 325d2273de
23 changed files with 200 additions and 22 deletions
+5 -1
View File
@@ -10,6 +10,7 @@ const core = require('./chatcore');
const C = require('./config').get();
const KNOWLEDGE_DATE = '2026-11-17';
const weekend = require('./weekend'); // Network Weekend: +3 board days per Boost, Fri 11-27 00:00 CT to Tue 12-01 00:00 CT
const URL_ = 'https://' + C.site;
const SUPPORT = 'https://instantadpay.com/support';
const B = C.boost, SP = C.split, R = C.reward, CR = C.credits;
@@ -56,15 +57,18 @@ const FAQ = [
const FACTS = () => [
'- WHAT IT IS: ViralAdSource (' + URL_ + '): "Every ad has a source. Watch yours travel." One free text ad per network member (headline ' + C.ad.headline + ', two lines of ' + C.ad.line + ', an https link or the member\'s own LinkSpin spin link). Anyone reshares an ad with their own unique reshare link /s/<code>; each reshare is a branch; the owner\'s dashboard shows the family tree: branch, step, reshares under it, views, clicks, sign-ups.',
'- REWARDS (results only, never a bare share; members earn for free: no Boost needed, only a network sign-in and a linked wallet): L1 Boost through a branch: resharer cut ' + pct(SP.resharerBps) + ' paid by the VASShop contract in the same transaction. L2 verified brand-new network member through a branch: $' + (R.cents / 100).toFixed(2) + ' in POL from the reward pot, cap ' + R.dailyCap + ' a day per resharer; checks: hub-new, confirmed email, not the resharer\'s device/IP/wallet, no throwaway email, daily cap, fraud score; payouts currently ' + (R.payouts ? 'ON' : 'OFF (rewards wait in the pending ledger)') + '. L3 verified views: ' + CR.per + ' ad credits per ' + CR.views + ' verified views through the resharer\'s links, spent on their own ad, never paid out.',
(weekend.live() ? '- NETWORK WEEKEND (live now, Black Friday to Cyber Monday, Fri 11-27 to Mon 11-30, midnight to midnight Central): every Boost bought in the window stays on top of the reshare board ' + weekend.extra() + ' extra days per unit (' + (B.days + weekend.extra()) + ' days instead of ' + B.days + '), same $' + B.usd + ' price and the same split. This overrides the ' + B.days + '-day figure below until Tuesday 12-01 00:00 Central. Every network deal: https://instantadpay.com/weekend' : null),
'- BOOST: one-time $' + B.usd + ' = a ' + B.days + '-day board spot (top of the reshare board) per unit, placement only, never needed to earn, 1 to ' + B.maxQty + ' per purchase. Split: resharer ' + pct(SP.resharerBps) + ', reward pot ' + pct(SP.potBps) + ', sponsor levels ' + SP.levelBps.map(pct).join('/') + ' to the 5 nearest eligible people in the sponsor line (network sign-in + linked wallet; the ineligible are skipped and the share passes up), company the rest plus any level or resharer cut with nobody to pay. The split is immutable. The pot can only pay sign-up rewards, never more than it holds, at most $' + (R.potDailyCents / 100).toFixed(2) + ' a day across everyone.',
'- AI AD WRITER: on the ad form at ' + URL_ + '/my, put your link in the Your link box (a page or your own LinkSpin spin link) and tap "Write my ad from my link": it reads that page and suggests 3 ads using only what the page says (no made-up claims, numbers or income promises); tapping one fills the headline and first line to edit, nothing is posted until you save; ' + require('./adwriter').dailyCap() + ' writes a day per member (reset at midnight Central), the same page again within 24 hours is free.',
'- VERIFIED VIEWS: page visible ' + C.visitSeconds + ' s, one view per visitor per ad per 24 h, never the owner\'s own, max ' + C.perIpDay + ' browsers per connection a day.',
'- TRUST: ' + URL_ + '/ledger, ' + URL_ + '/contract, toasts of real events. Terms ' + URL_ + '/terms, Earnings Disclaimer ' + URL_ + '/disclaimer, Privacy ' + URL_ + '/privacy. Run by TrustClickz. SUPPORT: ' + SUPPORT
].join('\n');
].filter(Boolean).join('\n');
const SITE = {
id: 'viraladsource', hubSite: 'viraladsource', netId: 'viraladsource', name: 'ViralAdSource', url: URL_, supportUrl: SUPPORT, knowledgeDate: KNOWLEDGE_DATE,
dataDir: C.dataDir, canned: CANNED, faq: FAQ, facts: FACTS,
// Network Weekend: stored instant answers say the SKU's days; while the weekend is live a Boost answer also says the bonus
finish: r => (weekend.live() && /board spot|reshare board/.test(r) && /Boost/i.test(r) ? r + ' Network Weekend (through Monday 11-30, midnight Central): every Boost bought now gets ' + weekend.extra() + ' extra board days per unit, ' + (B.days + weekend.extra()) + ' days in all, same price.' : r),
intro: 'You are the assistant on ViralAdSource (' + URL_ + '): free text ads that spread by reshares, each ad with its own family tree, and rewards only for verified results. It is part of a network of sites that share one account.',
quickTopics: ['How does resharing work?', 'How are resharers rewarded?', 'What are ad credits?', 'What is a Boost?']
};
+1
View File
@@ -165,6 +165,7 @@ async function handle(req, res, p, u, h) {
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.reply && typeof S.finish === 'function') { try { r.reply = S.finish(r.reply); } catch (e) {} } // site hook: date-gated wording (Network Weekend 2026-11-17)
if (r.handoff) r.support = supportLink(b.message);
h.json(res, r.error ? 400 : 200, r); return true;
}
+54
View File
@@ -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: [] } }; } };
+1 -1
View File
@@ -36,7 +36,7 @@
</div>
<section id="featured" hidden style="margin-top:32px"><h2 style="font-size:24px">Featured with credits</h2><div class="ads"></div></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/adpage.js?v=2"></script>
</body>
+1 -1
View File
@@ -26,7 +26,7 @@
<section class="panel" style="margin-top:18px" id="testBox"><h2 style="font-size:22px">Staging: mark a test member</h2><p class="muted">Staging only. Lets a wallet post and reshare without a real network account.</p>
<div class="row"><input type="text" id="tAddr" placeholder="0x wallet" style="max-width:420px"><input type="text" id="tName" placeholder="username" style="max-width:200px"><button class="btn sm" id="tGo" type="button">Mark</button></div><p id="status" class="note" hidden></p></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/admin.js?v=20261117a"></script>
</body>
+7
View File
@@ -122,3 +122,10 @@ window.VAS = (function () {
};
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); else boot();
})();
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub through
// /api/network-deals). Not on the admin page, never inside a frame.
(function () {
if (/^\/admin/.test(location.pathname)) return;
try { if (window.top !== window) return; } catch (e) { return; }
var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117'; s.defer = true; s.setAttribute('data-site', 'viraladsource'); document.head.appendChild(s);
})();
+67
View File
@@ -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
})();
+1 -1
View File
@@ -36,7 +36,7 @@
</div>
</div></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/wallet.js?v=2"></script>
<script src="/assets/buy.js?v=2"></script>
+1 -1
View File
@@ -22,7 +22,7 @@
<p id="status" class="note">One moment...</p>
<div class="row" style="margin-top:16px"><a class="btn ink" href="/my">Sign in</a><a class="btn" href="/">Front page</a></div>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/join.js?v=2"></script>
</body>
+1 -1
View File
@@ -27,7 +27,7 @@
<li>A sign-up reward needs a keeper-signed voucher, used once, under the per-reward cap and the per-wallet daily cap, and never more than the pot holds.</li>
<li>No proxy, no owner withdrawal of the pot, no self-destruct. The owner is Marty's Tangem hardware wallet.</li></ul></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/contract.js?v=2"></script>
</body>
+1 -1
View File
@@ -23,7 +23,7 @@
<p>Crypto prices change. A reward or payment priced in dollars is paid in POL at the price when it is paid; its value can go down afterwards. Network fees apply to every transaction.</p>
<p>Any example on this site is an illustration of how the contract splits a payment, not a prediction of what you will receive.</p>
<p>TrustClickz. Questions: <a href="https://instantadpay.com/support?from=viraladsource">network support</a>.</p></main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/static.js?v=2"></script>
</body>
+1 -1
View File
@@ -108,7 +108,7 @@
<div class="panel" id="hunt"><h3 style="margin:0 0 6px;font-size:19px">Hunt it on PolHunter</h3><p style="margin:0;color:var(--ink3)">A find code hides in one of the three "How an ad spreads" steps.</p></div>
</div></div></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/front.js?v=2"></script>
</body>
+1 -1
View File
@@ -28,7 +28,7 @@
</form>
<p id="status" class="note" hidden></p>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/join.js?v=2"></script>
</body>
+1 -1
View File
@@ -25,7 +25,7 @@
<section class="panel" style="margin-top:22px"><h2 style="font-size:26px">Sign-up rewards</h2><p class="muted" id="payNote" style="margin:6px 0 0"></p>
<div class="tbl"><table><thead><tr><th>When</th><th>Resharer</th><th>Kind</th><th>Amount</th><th>Status</th><th>Proof</th></tr></thead><tbody id="rrows"><tr><td colspan="6" class="muted">No rewards yet.</td></tr></tbody></table></div></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/ledger.js?v=2"></script>
</body>
+1 -1
View File
@@ -65,7 +65,7 @@
<div class="row" style="margin-top:22px"><button class="btn sm" id="logout" type="button">Sign out</button><button class="btn sm" id="logoutAll" type="button">Sign out everywhere</button></div>
</div>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/wallet.js?v=2"></script>
<script src="/assets/my.js?v=20261117a"></script>
+1 -1
View File
@@ -23,7 +23,7 @@
<h2>Sharing</h2><p>Your account is part of the network: your username, wallet and sponsor are shared with the network hub so one account works on every network site. We do not sell personal data. Blockchain transactions are public by nature.</p>
<h2>Your choices</h2><p>Ask network support to delete your data; the network hub removes it from every network site, except what the blockchain or the law keeps.</p>
<p>TrustClickz. Questions: <a href="https://instantadpay.com/support?from=viraladsource">network support</a>.</p></main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/static.js?v=2"></script>
</body>
+1 -1
View File
@@ -23,7 +23,7 @@
<label class="f" style="max-width:360px;margin-top:18px">Your network username<input type="text" id="kitUser" placeholder="username"></label>
<div id="kit" style="margin-top:22px"></div>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/promote.js?v=2"></script>
</body>
+1 -1
View File
@@ -50,7 +50,7 @@
<div class="panel"><h2 style="font-size:26px">Where to see it</h2><p class="muted">Your rewards and credits are on <a href="/my">My ad tree</a>. Every paid reward and every Boost split is on the <a href="/ledger">public ledger</a> with its Polygon transaction.</p></div>
</div></section>
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/static.js?v=2"></script>
</body>
+1 -1
View File
@@ -27,7 +27,7 @@
<h2>No promise of income</h2><p>What you buy is advertising. We do not promise any income, views, sign-ups or results. See the Earnings Disclaimer.</p>
<h2>Changes</h2><p>We can change these terms and the program's numbers going forward; a change never alters a payment already made on chain.</p>
<p>TrustClickz. Questions: <a href="https://instantadpay.com/support?from=viraladsource">network support</a>.</p></main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/chat.js?v=1" defer></script>
<script src="/assets/static.js?v=2"></script>
</body>
+24
View File
@@ -0,0 +1,24 @@
// Network Weekend gate (weekend.js, wire.js stacking, chatbot wording): +3 board days per Boost unit bought
// Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, by the purchase's chain time. WEEKEND_NOW test clock; never the server clock.
const assert = require('assert'); const fs = require('fs'); const os = require('os'); const path = require('path');
process.env.DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'vasnw-')); delete process.env.DOCSTORE_URL;
const w = require('../weekend');
const T = s => Date.parse(s);
assert.strictEqual(w.bonusDays(T('2026-11-27T05:59:59Z')), 0);
assert.strictEqual(w.bonusDays(T('2026-11-27T06:00:00Z')), 3);
assert.strictEqual(w.bonusDays(T('2026-12-01T05:59:59Z')), 3);
assert.strictEqual(w.bonusDays(T('2026-12-01T06:00:00Z')), 0);
process.env.WEEKEND_BOOST_DAYS = '0'; assert.strictEqual(w.bonusDays(T('2026-11-28T12:00:00Z')), 0, 'off switch'); delete process.env.WEEKEND_BOOST_DAYS;
const wire = require('../wire');
const sec = s => T(s) / 1000;
assert.strictEqual(wire.unitDays({ days: 7, blockAt: sec('2026-11-28T12:00:00Z') }), 10, 'weekend Boost: 10 days');
assert.strictEqual(wire.unitDays({ days: 7, blockAt: sec('2026-12-01T06:00:01Z') }), 7, 'Tuesday Boost: 7 days');
assert.strictEqual(wire.unitDays({ days: 7, at: T('2026-11-27T06:00:00Z') }), 10, 'no block time yet: the record time');
process.env.WEEKEND_NOW = '2026-11-30T20:00:00Z';
const bot = require('../chatbot');
assert.ok(/NETWORK WEEKEND/.test(bot.SITE.facts()) && !/\u2014/.test(bot.SITE.facts()));
assert.match(bot.SITE.finish('A Boost is a 7-day board spot.'), /3 extra board days per unit, 10 days in all/);
process.env.WEEKEND_NOW = '2026-12-01T06:00:00Z';
assert.ok(!/NETWORK WEEKEND/.test(bot.SITE.facts())); assert.strictEqual(bot.SITE.finish('A Boost is a 7-day board spot.'), 'A Boost is a 7-day board spot.');
delete process.env.WEEKEND_NOW;
console.log('weekend gate: all pass');
+7 -4
View File
@@ -31,6 +31,8 @@ const hubevents = require('./hubevents');
const hubline = require('./hubline');
const proof = require('./proof');
const netsites = require('./netsites');
const netdeals = require('./netdeals'); // Network Weekend ribbon feed (2026-11-17)
const weekend = require('./weekend'); // Network Weekend +3 board days per Boost (2026-11-17)
const lstrack = require('./lstrack');
const chatbot = require('./chatbot');
const adwriter = require('./adwriter');
@@ -273,7 +275,7 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/config' && req.method === 'GET') {
const live = await shop.liveRules().catch(() => null);
return json(res, 200, { site: C.site, siteName: C.siteName, staging: C.staging, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId,
boost: C.boost, split: live ? { resharerBps: live.resharerBps, potBps: live.potBps, levelBps: live.levelBps, maxDepth: 20, live: true } : Object.assign({ proposal: true }, C.split),
boost: Object.assign({}, C.boost, { days: C.boost.days + weekend.bonusDays(), weekendDays: weekend.bonusDays() }), split: live ? { resharerBps: live.resharerBps, potBps: live.potBps, levelBps: live.levelBps, maxDepth: 20, live: true } : Object.assign({ proposal: true }, C.split),
reward: { cents: C.reward.cents, dailyCap: C.reward.dailyCap, payouts: C.reward.payouts, tiers: C.reward.tiers, proposal: true }, credits: C.credits, visitSeconds: C.visitSeconds, ad: C.ad,
sso: networksso.enabled() || networksso.hubOn(), shop: { live: shop.watching() && shop.signerOn(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, joinUrl: joinUrl(''),
aiWriter: adwriter.enabled() ? { daily: adwriter.dailyCap() } : null });
@@ -316,6 +318,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, 'viraladsource'); // Network Weekend ribbon
if (p === '/api/recent' && req.method === 'GET') {
const cut = Date.now() - 30 * 60000;
const ads = store.liveAds().filter(a => a.createdAt > cut).slice(-6).map(a => ({ kind: 'ad', key: 'a' + a.id, at: a.createdAt, name: uname(a.owner), headline: a.headline }));
@@ -328,7 +331,7 @@ const server = http.createServer(async (req, res) => {
if (limited(req, 'quote', 600, 3600000)) return json(res, 429, { error: 'Too many requests this hour.' });
const qty = Number(u.searchParams.get('qty') || 1);
if (!Number.isInteger(qty) || qty < 1 || qty > C.boost.maxQty) return json(res, 400, { error: 'Pick 1 to ' + C.boost.maxQty + ' Boosts.' });
try { return json(res, 200, Object.assign({ usd: C.boost.usd * qty, days: C.boost.days * qty }, await shop.quote(C.boost.sku, qty))); } catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
try { return json(res, 200, Object.assign({ usd: C.boost.usd * qty, days: (C.boost.days + weekend.bonusDays()) * qty }, await shop.quote(C.boost.sku, qty))); } catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
}
if (p === '/api/gas' && req.method === 'GET') { try { return json(res, 200, shop.watching() ? await shop.fees() : {}); } catch (e) { return json(res, 200, {}); } }
if (/^\/api\/tx\/0x[0-9a-fA-F]{64}$/.test(p) && req.method === 'GET') {
@@ -417,7 +420,7 @@ const server = http.createServer(async (req, res) => {
source: root ? { code: root.id, url: shareUrl(root) } : null, tree: a ? tree.tree(a.id) : null, linkspin: ls, reshares: mine,
credits: { earned: cr.earned, spent: cr.spent, balance: store.creditBalance(me), views: cr.views, nextAt: C.credits.views - (cr.views % C.credits.views), per: C.credits.per, every: C.credits.views },
rewards: signup.mine(me), boosts: wire.purchases().filter(b => b.buyer === me).sort((x, y) => (y.at || 0) - (x.at || 0)).map(wire.boostView), earned: myEarned(me),
joinUrl: joinUrl(''), boost: C.boost });
joinUrl: joinUrl(''), boost: Object.assign({}, C.boost, { days: C.boost.days + weekend.bonusDays(), weekendDays: weekend.bonusDays() }) });
}
if (p === '/api/my/spins' && req.method === 'GET') {
if (limited(req, 'spins', 120, 3600000)) return json(res, 429, { error: 'Too many requests this hour.' });
@@ -473,7 +476,7 @@ const server = http.createServer(async (req, res) => {
const via = viaOf(req); const vs = via ? store.share(via.code) : null;
const resharer = vs && vs.step > 0 && vs.owner !== me ? vs.owner : null;
{ const S0 = store.state(); S0.orderVia = S0.orderVia || {}; if (resharer) S0.orderVia[me] = { code: vs.id, at: Date.now() }; else delete S0.orderVia[me]; store.save(); } // which branch sold it (proof.js books it on that reshare link)
try { return json(res, 200, Object.assign({ buyer: me, usd: C.boost.usd * qty, days: C.boost.days * qty, qty, adId: a.id, resharerName: resharer ? uname(resharer) : null }, await shop.order(me, C.boost.sku, qty, a.id, line, resharer))); }
try { return json(res, 200, Object.assign({ buyer: me, usd: C.boost.usd * qty, days: (C.boost.days + weekend.bonusDays()) * qty, qty, adId: a.id, resharerName: resharer ? uname(resharer) : null }, await shop.order(me, C.boost.sku, qty, a.id, line, resharer))); }
catch (e) { console.error('order failed:', String(e && e.message || e).slice(0, 200)); return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
}
if (p === '/api/my/paid' && req.method === 'POST') { shop.nudge(); return json(res, 200, { ok: true, confirmations: C.shopConfirmations }); }
+15
View File
@@ -0,0 +1,15 @@
// Network Weekend (Marty 2026-11-17, Black Friday to Cyber Monday 2026): every Boost bought from Fri 11-27 00:00 CT to Tue 12-01
// 00:00 CT (CST = UTC-6) stays on top of the reshare board 3 extra days per unit, same $5 price, same split. No contract change:
// the chain's SKU says 7 board days (VASShop setSku boardDays; the old "500 views" line in Seed.sol was replaced by days), and this
// app adds the bonus when it stacks board time (wire.js), by the purchase's own chain time, so it switches on and off by itself.
// WEEKEND_BOOST_DAYS extra days per unit (default 3, 0 = off, max 30)
// WEEKEND_NOW test clock (ISO), tests only: never set it on the server
'use strict';
const START = Date.parse('2026-11-27T06:00:00Z');
const END = Date.parse('2026-12-01T06:00:00Z');
function nowMs() { const o = process.env.WEEKEND_NOW; const t = o ? Date.parse(o) : NaN; return Number.isNaN(t) ? Date.now() : t; }
function extra() { const r = process.env.WEEKEND_BOOST_DAYS; const v = Number(r === undefined || r === '' ? 3 : r); return Number.isInteger(v) && v >= 0 && v <= 30 ? v : 0; }
function live(ms) { ms = ms === undefined ? nowMs() : ms; return extra() > 0 && ms >= START && ms < END; }
// extra board days per unit for a Boost bought at `ms` (default: now)
function bonusDays(ms) { return live(ms) ? extra() : 0; }
module.exports = { START, END, nowMs, live, bonusDays, extra };
+6 -3
View File
@@ -29,11 +29,14 @@ const fresh = (m, k) => { const t = m.get(k); return t && Date.now() - t < H24;
// ---- Boosts ----
function purchases() { return Object.entries(store.state().purchases || {}).map(([key, x]) => Object.assign({ key }, x)); }
// board days per unit of a Boost: the chain's SKU days, plus the Network Weekend bonus when it was bought in the window (weekend.js)
const weekend = require('./weekend');
const unitDays = b => (b.days || C().boost.days) + weekend.bonusDays((b.blockAt ? b.blockAt * 1000 : b.at) || 0);
// when an ad's Boosts end: each unit adds boost.days, back to back from its purchase (or from the end of the one before)
function boostedUntil(adId) {
let until = 0;
for (const b of purchases().filter(x => x.adId === Number(adId)).sort((a, b) => (a.at || 0) - (b.at || 0))) {
const at = (b.blockAt ? b.blockAt * 1000 : b.at) || 0; until = Math.max(until, at) + (Number(b.qty) || 1) * (b.days || C().boost.days) * 86400000;
const at = (b.blockAt ? b.blockAt * 1000 : b.at) || 0; until = Math.max(until, at) + (Number(b.qty) || 1) * unitDays(b) * 86400000;
}
return until;
}
@@ -45,7 +48,7 @@ function attach(rec) {
function attachPending(owner, adId) { let n = 0; for (const x of Object.values(store.state().purchases || {})) if (x.buyer === owner && !x.adId) { x.adId = adId; n++; } if (n) store.save(); return n; }
function boostView(b) {
const until = b.adId ? boostedUntil(b.adId) : 0;
return { key: b.key, tx: String(b.key).split(':')[0], orderId: b.orderId, at: (b.blockAt ? b.blockAt * 1000 : b.at) || null, adId: b.adId || null, qty: b.qty, days: (Number(b.qty) || 1) * (b.days || C().boost.days),
return { key: b.key, tx: String(b.key).split(':')[0], orderId: b.orderId, at: (b.blockAt ? b.blockAt * 1000 : b.at) || null, adId: b.adId || null, qty: b.qty, days: (Number(b.qty) || 1) * unitDays(b), weekendDays: (Number(b.qty) || 1) * (unitDays(b) - (b.days || C().boost.days)),
boostedUntil: until || null, status: !b.adId ? 'waiting-for-ad' : until > Date.now() ? 'on-top' : 'finished', resharer: b.resharer || null, resharerWei: b.resharerPaid || '0' };
}
@@ -137,5 +140,5 @@ function setSecret(s) { SECRET = String(s); }
const vtoken = vk => crypto.createHmac('sha256', SECRET).update('vt|' + vk + '|' + store.ctDay()).digest('hex').slice(0, 24);
const vtokenOk = (vk, t) => typeof t === 'string' && t.length === 24 && crypto.timingSafeEqual(Buffer.from(t), Buffer.from(vtoken(vk)));
module.exports = { init, rebuild, purchases, boostedUntil, isBoosted, attach, attachPending, boostView, adCard, board, creditPicks, weekStats,
module.exports = { unitDays, init, rebuild, purchases, boostedUntil, isBoosted, attach, attachPending, boostView, adCard, board, creditPicks, weekStats,
canVisit, verify, click, vtoken, vtokenOk, setSecret, hostOf };