Compare commits

..

5 Commits

Author SHA1 Message Date
Marty Bostick bfa13302e1 Holding tank in the Control Room menu (Marty 2026-11-11): shown only to members who can adopt (eligible, or at the cap), badge = people adoptable right now, title says you can adopt up to <tankAdoptCap> at a time, opens More > My line; GET /api/my/tank/summary (cached waiting list, no full list); tank card says the cap; chatbot knows where the tank lives and the 10-at-a-time rule; cr-shell ?v=20261111tank, my.js ?v=20261111tank. qa/btc4hits-bridge 28/28 (incl. browser checks)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:17:31 -06:00
Marty Bostick 5d79abe318 BTC4Hits import, round 2: tank cap 10 at one time (setting tankAdoptCap) with tests; BTC4Hits origin kept on carried shells (joinedRef btc4hits) and the adoption note/email/auto-assign message say their BTC4Hits account moved here; imported spin links may carry every valid URL (admin route maxDests up to 2000, one save per batch), editor shows 50 rows of a big link with Show all, Check now runs in the background past 50, at most one pause email per link per day; chatbot knows /from/btc4hits + the cap (KNOWLEDGE_DATE 2026-11-11). qa: tank-cap 15/15, tank-hold all passed, btc4hits-bridge 21/21, sponsorfollow 30/30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:08:58 -06:00
Marty Bostick f811ee2e8c Holding tank: an adopter may hold up to 6 people at one time (open adoptions not yet switched on payouts; setting tankAdoptCap, default 6; was 2 open adoptions), clear message at the cap
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:49:01 -06:00
Marty Bostick 557bc15972 Legacy bridge /from/btc4hits: BTC4Hits is now LinkSpin sign-in page (angle b4h, sponsor cookie cleared, forced first-touch source legacy:btc4hits, no welcome-back credits), join.js?v=20261111b4h. qa/btc4hits-bridge.test.mjs 21/21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:23:28 -06:00
Marty Bostick 215af86e55 Admin spin links for the BTC4Hits import: POST /api/admin/rotations takes several destinations per link (urls[], fallback), GET lists a member's links + sources, DELETE removes one; tank waiting list reads every account (was the newest 2000)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:22:01 -06:00
26 changed files with 281 additions and 51 deletions
+7 -3
View File
@@ -25,7 +25,7 @@ let DATA_DIR = null;
let chain = null;
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b';
const KNOWLEDGE_DATE = '2026-11-07'; // the day the CANNED answers and FACTS below were last checked against the site
const KNOWLEDGE_DATE = '2026-11-11'; // the day the CANNED answers and FACTS below were last checked against the site
function init(opts) {
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
@@ -148,9 +148,12 @@ const CANNED = [
{ id: 'tank-hold', title: 'Matched with a sponsor (payouts on hold)', q: ['Why can I not switch on payouts?', 'It says I am being matched with a sponsor'], tags: ['holding tank', 'switch on payouts', 'matched with a sponsor', 'ready to activate'],
re: /(being matched|matched with a sponsor|(can.?t|cannot|unable to) (i )?(switch on|turn on|activate) (my )?payouts|activate (button|payouts) (is )?(gone|missing|hidden)|ready to activate)/i,
a: 'You joined without a sponsor, so you are in the holding tank. If someone invited you, type their username in the Who invited you? box and this ends right away. The contract locks your sponsor for good the moment your payouts are switched on, so the site waits for a real member to pick you up instead of placing you under the company. First it checks the network: if InstantAdPay already has a sponsor for your email or wallet, you are placed under them right away. Otherwise members see you at the top of their holding tank with a Ready to activate badge once your wallet is linked, and if nobody adopts you within 24 hours the site assigns you to the next eligible member in turn (someone active with their own $25 package). As soon as you have a sponsor, the site switches your payouts on under them for you (no cost to you) and tells you, with the transaction link. Buying is never held: you can buy a package at any time, but a purchase made before you have a sponsor places you under the platform position for good.' },
{ id: 'btc4hits', title: 'BTC4Hits moved to LinkSpin', q: ['I was a BTC4Hits member, where is my account?', 'What happened to BTC4Hits?', 'Where is my BTC4Hits rotator?'], tags: ['btc4hits', 'rotator', 'moved', 'old account'],
re: /btc ?4 ?hits/i,
a: 'BTC4Hits is now LinkSpin. If your BTC4Hits email checked out as deliverable, your account came over on 2026-11-11: sign in at linkspin.app/from/btc4hits with the same email (we send you a code, there is no password). Your BTC4Hits sponsor came with you when they were also a member here; if not, you wait in the holding tank, where a member can pick you up as your sponsor, or you can name the person who invited you in the Who invited you? box. Rotators that had visits in the last month are now LinkSpin spin links on your Links screen, named BTC4Hits rotator and the old number, and the old btc4hits.com rotator link forwards to them. Destination URLs that no longer worked were left out. Every other btc4hits.com page now opens linkspin.app/from/btc4hits. Pro upgrades and any old BTC4Hits commissions do not carry over.' },
{ id: 'holding-tank', title: 'Holding tank and adoptions', q: ['What is the holding tank?', 'How do I adopt a member?'], tags: ['holding tank', 'adopt', 'no sponsor'],
re: /(holding tank|adopt|no sponsor|without a sponsor|orphan)/i,
a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line, unless the network already knows their sponsor (the same email or wallet on InstantAdPay), in which case they are placed under that sponsor. A new sign-up shows an Opens in badge with no Adopt button for their first 24 hours, so they have a day to tell us who invited them (the 24-hour safety net for wallet-linked members still runs on its own clock). After that, a member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list; adopting one switches their payouts on under you right away. If nobody adopts them within 24 hours, the site assigns them to the next eligible adopter in turn (own $25 package, fewer than 2 open adoptions, signed in within the last 7 days); the one assigned least recently goes first. Someone waiting in the InstantAdPay tank as well is assigned there, and the adoption carries over to LinkSpin.' },
a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line, unless the network already knows their sponsor (the same email or wallet on InstantAdPay), in which case they are placed under that sponsor. Members who can adopt (payouts on and their own $25 package) see a Holding tank item in the Control Room menu, with the number waiting, that opens the tank under More, My line. You can adopt up to 10 people at a time: anyone you picked up who has not switched on payouts yet counts, and a slot opens when one of them switches on payouts or their 7-day window ends. A new sign-up shows an Opens in badge with no Adopt button for their first 24 hours, so they have a day to tell us who invited them (the 24-hour safety net for wallet-linked members still runs on its own clock). After that, a member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list; adopting one switches their payouts on under you right away. If nobody adopts them within 24 hours, the site assigns them to the next eligible adopter in turn (own $25 package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within the last 7 days); the one assigned least recently goes first. Someone waiting in the InstantAdPay tank as well is assigned there, and the adoption carries over to LinkSpin.' },
{ id: 'team', title: 'My line: the Team screen', q: ['How do I see my downline?', 'Who is in my team?'], tags: ['team', 'my line', 'downline', 'levels'],
re: /(my line|downline|my team|who (is|are) (in|on) my|three levels|level 1\b)/i,
a: 'Team shows your line as a working table, three levels deep: who joined through your link, who has switched on payouts, who has bought, and how many qualifying buyers each person has. The chip count is what opens your levels: two qualifying buyers ($25 or larger) open level 2, five open level 3.' },
@@ -205,9 +208,10 @@ ${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first) and any WalletConnect wallet work; Trust Wallet blocks a buy that spends most of its POL. No card button on the site: members buy POL with a card on any major exchange or on-ramp, then send it to their own wallet on the Polygon network (guide at ${SITE_URL}/wallets); never name a specific exchange or on-ramp brand.
- SPONSOR: the invite link opened most recently sets the sponsor (30-day cookie), shown on the join page, locked when the account is created; the contract binds the buyer to that sponsor at the first purchase. CARRY-OVER: Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their InstantAdPay sponsor from the network registry automatically when no invite link was used. Wrong sponsor before the first purchase: the admin can move the account. Members should switch on payouts before their people buy.
- CONTROL ROOM screens: Links, Pages, Zones (with Audiences), Ads, Credits, Reports, Team (three levels, who has payouts on, who bought, qualifying-buyer counts), Wallet (what was paid to this wallet, payout history). More at ${SITE_URL}/tools: Promo tools, Training, Pipeline (a follow-up board for prospects and directs), My line (including the holding tank: members who joined with no sponsor wait there and can be adopted by a member with payouts on and their own qualifying package), Profile.
- BTC4HITS (2026-11-11): the closed BTC4Hits rotator site moved here. Its members with a deliverable email were imported as waiting accounts (InstantAdPay first, carried here by the registry sync), with their BTC4Hits sponsor when that sponsor was also imported or already a member, otherwise into the holding tank. Sign-in page: /from/btc4hits (same email, code sign-in, no welcome-back credits). Rotators with visits in the last month became spin links named 'BTC4Hits rotator #<old id>' on the owner's account with every working destination (dead, parked or erroring URLs left out), on a 'BTC4Hits' traffic source; btc4hits.com/ro.php?id=<id> forwards to the spin link, other btc4hits.com pages go to /from/btc4hits. Pro status and old BTC4Hits commissions do not carry over. HOLDING TANK CAP: an adopter may hold up to 10 people from the tank at one time (open adoptions whose person has not switched on payouts yet; was 2). The cap is the site setting tankAdoptCap (default 10). HOLDING TANK MENU ITEM: members who can adopt (payouts on, own $25 package) see Holding tank in the Control Room menu (rail), with a badge of how many can be adopted right now; it opens More > My line, where the Holding tank card lists them and says how many you can adopt at a time. Members who cannot adopt do not see the item.
- WHO INVITED YOU (2026-11-07, Marty approved): a member with no sponsor and no member number sees a Who invited you? box at the top of their Control Room screens. They type a username, confirm in an in-page box, and that member becomes their sponsor (it follows to InstantAdPay, lifts the hold, and the sponsor gets a new-referral email and notice); with a wallet already linked the site switches their payouts on under that sponsor right away. Refused: themselves, a username that does not exist, someone in their own line, a member who cannot take new members, a member with no payouts on and nobody above them on the contract, and anyone who already has a sponsor or a member number. Nobody invited me hides the box (a small link under More brings it back while they are in the tank) and changes nothing else. It never blocks the site. It is not an adoption: no 7-day window and it does not count toward the two.
- SIGN-UP GRACE (2026-11-07): for 24 hours from sign-up nobody can adopt a member by hand. The 24-hour auto-assign is unchanged and runs from the wallet link, so a member who links a wallet in their first hour is matched about 24 hours after linking, with at most a short hand-adoption window first. Members back in the tank later have no grace.
- HOLDING TANK ACTIVATION HOLD (2026-10-27): a member with no sponsor is first matched to their network sponsor (the same email or wallet with a sponsor on InstantAdPay). Nobody known: the free Switch on payouts waits for an adopter and the Credits screen says "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left; they show at the top of every holding tank with a green Ready to activate badge and the hours left, and the shared payments topic on Telegram is told. Nobody adopts in 24 hours: the site assigns them to the next eligible adopter in rotation (own $25+ package, fewer than 2 open adoptions, signed in within 7 days; least recently auto-assigned first), and the pickup is posted marked (auto-assigned). The moment they have a sponsor (adopted, assigned or matched), the site switches their payouts on under that sponsor (engine-paid) and sends them the transaction link. A PURCHASE IS NEVER HELD: a tank member can buy at any time; with no sponsor yet that purchase places them under the platform position for good. Someone who arrived through a sponsor link is never held.
- HOLDING TANK ACTIVATION HOLD (2026-10-27): a member with no sponsor is first matched to their network sponsor (the same email or wallet with a sponsor on InstantAdPay). Nobody known: the free Switch on payouts waits for an adopter and the Credits screen says "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left; they show at the top of every holding tank with a green Ready to activate badge and the hours left, and the shared payments topic on Telegram is told. Nobody adopts in 24 hours: the site assigns them to the next eligible adopter in rotation (own $25+ package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within 7 days; least recently auto-assigned first), and the pickup is posted marked (auto-assigned). The moment they have a sponsor (adopted, assigned or matched), the site switches their payouts on under that sponsor (engine-paid) and sends them the transaction link. A PURCHASE IS NEVER HELD: a tank member can buy at any time; with no sponsor yet that purchase places them under the platform position for good. Someone who arrived through a sponsor link is never held.
${launchFact()}
- SUPPORT (LIVE 2026-10-16): members open Help in the Control Room (${SITE_URL}/help) to send Marty a ticket (pick a category, a subject, the message), see each ticket's status (Open, Waiting on you, Closed), and read and answer his replies; a badge on the Help item shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at ${SITE_URL}/support, gets a private link to follow the ticket without signing in, and can reply there. The chat can also pass a conversation to support ("Send this to support"). Marty answers every ticket himself; there is no support email address, point people to ${SITE_URL}/support instead. Tickets share one desk with the rest of the Crypto Team Build Network.
- Leaderboard at ${SITE_URL}/leaderboard ranks members by packages sold to direct referrals (weekly, monthly, all time; weekly and monthly prizes are ad credits, never cash).
+4 -1
View File
@@ -108,10 +108,12 @@ function apply(r, d, c) {
}
return null;
}
const toldToday = new Set();
async function tell(r, d, change) {
if (!notify || !change || change.kind !== 'paused' || /^demo:/.test(r.owner)) return;
const tk = r.id + ':' + ctDay(Date.now()); if (toldToday.has(tk)) return; toldToday.add(tk); if (toldToday.size > 5000) toldToday.clear(); // at most one pause email per link per day (2026-11-11: imported links carry hundreds of pages)
const esc = s => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
const html = '<p>LinkSpin paused one destination in your link <b>' + esc(r.name) + '</b> (/r/' + esc(r.code) + ') because it failed three checks in a row.</p>'
const html = '<p>LinkSpin paused one destination in your link <b>' + esc(r.name) + '</b> (/r/' + esc(r.code) + ') because it failed three checks in a row. (You get at most one of these emails per link per day; the link\'s Destinations tab shows every paused page.)</p>'
+ '<p><span style="font-family:monospace">' + esc(d.url) + '</span><br>' + esc(d.health.note || d.health.state) + '</p>'
+ '<p>Visitors keep flowing to your other destinations' + (r.fallback ? ' and the fallback' : '') + '. If the page comes back, LinkSpin resumes it on its own after two clean checks. You can also fix the address or resume it yourself under Links.</p>';
try { await notify(r.owner, 'A destination in ' + r.name + ' was paused', html); } catch (e) {}
@@ -241,6 +243,7 @@ async function checkRotation(owner, id) {
lastManual.set(r.id, Date.now());
const jobs = r.destinations.map(d => async () => { const c = await check(d.url); const ch = apply(r, d, c); if (ch) await tell(r, d, ch); });
if (r.fallback) jobs.push(async () => { const c = await check(r.fallback); r.fallbackHealth = { state: c.state, code: c.code, ms: c.ms, checkedAt: Date.now(), note: c.note, frameBlocked: !!c.frameBlocked }; });
if (jobs.length > 50) { runAll(jobs).then(() => rotator.save()).catch(() => {}); return { ok: true, background: true, rotation: rotator.pub(r) }; } // a big link would outlive the request
await runAll(jobs); rotator.save();
return { ok: true, rotation: rotator.pub(r) };
}
+1 -1
View File
@@ -75,7 +75,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/ads-screen.js?v=20261104lf"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
<script src="/assets/engine-room.js?v=20261101t"></script>
+22 -5
View File
@@ -19,6 +19,7 @@ window.CR = (function () {
['reports', 'Reports', '/reports', '<path d="M4 19V9M10 19V5M16 19v-8M22 19H2"/>'],
['conversions', 'Conversions', '/conversions', '<circle cx="12" cy="12" r="8"/><circle cx="12" cy="12" r="4"/><circle cx="12" cy="12" r="0.8"/>'], // conversion pixel goals (2026-10-23)
['team', 'Team', '/team', '<circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 19c0-3 3-5 6-5s6 2 6 5M15 15c3 0 6 1.5 6 4"/>'],
['tank', 'Holding tank', '/tools#line', '<path d="M4 9h16l-1.5 10h-13z"/><path d="M7 9V7a5 5 0 0 1 10 0v2"/><path d="M9.5 14h5"/>'], // adopters only (2026-11-11): shown by tankItem()
['wallet', 'Wallet', '/wallet', '<rect x="3" y="6" width="18" height="12" rx="2"/><path d="M16 12h3"/>'],
['promo', 'Promo tools', '/tools#promo', '<path d="M7 10s5-1 9-5v14c-4-4-9-5-9-5H5a2 2 0 0 1-2-2v0a2 2 0 0 1 2-2h2z"/><path d="M8 15l1 5h2l-1-5"/>'],
['training', 'Training', '/tools#training', '<rect x="3" y="5" width="18" height="13" rx="2"/><path d="M10 9l5 2.5-5 2.5z"/>', 1],
@@ -30,7 +31,7 @@ window.CR = (function () {
];
// screens not built yet fall back to the classic dashboard pane so nothing is a dead end
const FALLBACK = {}; // the classic /my dashboard is retired (2026-10-08); its leftover panes live at /tools
const BUILT = new Set(['forum', 'links', 'sources', 'pages', 'zones', 'ads', 'credits', 'refuel', 'reports', 'conversions', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile', 'help']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11); Help = support tickets (2026-10-16)
const BUILT = new Set(['tank', 'forum', 'links', 'sources', 'pages', 'zones', 'ads', 'credits', 'refuel', 'reports', 'conversions', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile', 'help']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11); Help = support tickets (2026-10-16)
let ME = null, toastT;
// Deep links (2026-10-25): /credits#refuel, /credits#buy and /ads#engine scroll to their panel once it has loaded (and any
// sign-in or sponsor pop-up is closed) and flash it, so a button that says "Refuel" lands ON the Refuel panel.
@@ -108,7 +109,7 @@ window.CR = (function () {
const act = railActive(o);
const app = document.createElement('div'); app.className = 'app'; let railWide = true; try { railWide = localStorage.getItem('cr.rail') !== 'narrow'; } catch (e) {} if (railWide) app.classList.add('wide'); // expanded by default (Marty 2026-10-08), the choice remembered per browser
app.innerHTML = '<nav class="rail" aria-label="LinkSpin"><a class="mark" href="/" aria-label="LinkSpin home" title="LinkSpin"></a>'
+ NAV.map(([k, label, href, svg, sec]) => '<a ' + (k === 'help' ? 'id="crHelp" ' : '') + (/^https?:/.test(href) ? 'target="_blank" rel="noopener" ' : '') + 'href="' + (BUILT.has(k) ? href : FALLBACK[k]) + '"' + (k === act ? ' class="on' + (sec ? ' rsec' : '') + '" aria-current="page"' : (sec ? ' class="rsec"' : '')) + ' title="' + label + '" aria-label="' + label + '"><svg viewBox="0 0 24 24">' + svg + '</svg><span class="lbl">' + label + '</span></a>').join('')
+ NAV.map(([k, label, href, svg, sec]) => '<a ' + (k === 'help' ? 'id="crHelp" ' : k === 'tank' ? 'id="crTank" hidden ' : '') + (/^https?:/.test(href) ? 'target="_blank" rel="noopener" ' : '') + 'href="' + (BUILT.has(k) ? href : FALLBACK[k]) + '"' + (k === act ? ' class="on' + (sec ? ' rsec' : '') + '" aria-current="page"' : (sec ? ' class="rsec"' : '')) + ' title="' + label + '" aria-label="' + label + '"><svg viewBox="0 0 24 24">' + svg + '</svg><span class="lbl">' + label + '</span></a>').join('')
+ '<span class="sp"></span><button class="railtog" type="button" id="crRailTog" title="Collapse or expand the menu" aria-label="Collapse or expand the menu"><svg viewBox="0 0 24 24"><path d="M15 6l-6 6 6 6"/></svg><span class="lbl">Collapse</span></button></nav>'
+ '<div class="main"><div class="topbar"><div><div class="crumb">' + esc(o.crumb || 'Control room') + '</div><h1>' + esc(o.title || '') + '</h1></div><span class="readout" id="crSub">' + esc(o.sub || '') + '</span><span class="grow"></span><span id="crActions">' + (o.actions || '') + '</span>' + themeSeg('crTheme') + '<button class="who" type="button" id="crUserBtn" title="Account"><i id="crAv"></i><span id="crWho">Sign in</span></button></div>'
// pre-launch notice (Marty, 2026-10-17): open to everyone from today, official launch November 15; date-driven since 2026-11-02 so it drops off by itself at midnight Central on launch day
@@ -213,11 +214,27 @@ window.CR = (function () {
}
return m;
}
// Holding tank on the rail (Marty 2026-11-11): only for members who can adopt (their own qualifying package, payouts on),
// a badge with how many can be adopted right now, and the at-one-time cap from the site setting in its title and on the card
function badgeCss() {
if (!document.getElementById('crHelpCss')) { const st = document.createElement('style'); st.id = 'crHelpCss'; st.textContent = '.rail a .rbadge{position:absolute;top:3px;right:3px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--sig);color:#fff;font:700 10px/16px var(--mono);text-align:center;box-sizing:border-box}.rail.wide a .rbadge,.app.wide .rail a .rbadge{right:8px;top:50%;transform:translateY(-50%)}'; document.head.appendChild(st); }
}
async function tankItem() {
const a = $('crTank'); if (!a) return null;
let r = null; try { r = await get('/api/my/tank/summary'); } catch (e) { return null; }
if (!r || !r.adopter) { a.hidden = true; return r; }
a.hidden = false; const cap = Number(r.cap) || 0;
const t = 'Holding tank: ' + (r.waiting ? fmt(r.waiting) + ' waiting for a sponsor' : 'nobody waiting right now') + '. You can adopt up to ' + cap + ' people at a time.';
a.title = t; a.setAttribute('aria-label', t);
badgeCss();
let b = a.querySelector('.rbadge'); if (!r.waiting) { if (b) b.remove(); } else { if (!b) { b = document.createElement('b'); b.className = 'rbadge'; a.appendChild(b); } b.textContent = r.waiting > 999 ? '999+' : String(r.waiting); }
return r;
}
// Help badge on the rail: how many of the member's tickets have a reply from Marty they have not opened (helpdesk.js)
async function helpBadge() {
const a = $('crHelp'); if (!a) return 0;
let n = 0; try { n = Number((await get('/api/my/support/unread')).unread) || 0; } catch (e) { return 0; }
if (!document.getElementById('crHelpCss')) { const st = document.createElement('style'); st.id = 'crHelpCss'; st.textContent = '.rail a .rbadge{position:absolute;top:3px;right:3px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--sig);color:#fff;font:700 10px/16px var(--mono);text-align:center;box-sizing:border-box}.rail.wide a .rbadge,.app.wide .rail a .rbadge{right:8px;top:50%;transform:translateY(-50%)}'; document.head.appendChild(st); }
badgeCss();
let b = a.querySelector('.rbadge'); if (!n) { if (b) b.remove(); return 0; }
if (!b) { b = document.createElement('b'); b.className = 'rbadge'; a.appendChild(b); }
b.textContent = n > 9 ? '9+' : String(n); a.title = 'Help: ' + n + ' new repl' + (n === 1 ? 'y' : 'ies'); return n;
@@ -253,7 +270,7 @@ window.CR = (function () {
const small = () => { box.innerHTML = '<span class="ink2">Remembered who invited you? <a href="#" id="inviteBack">Tell us</a></span>'; $('inviteBack').addEventListener('click', e => { e.preventDefault(); full(); $('inviteWho').focus(); }); };
if (ask.dismissed) small(); else full();
}
async function requireSession(onReady) { let m = await me(); whoPaint(m); themeSync(m); if (m && m.signedIn) { strip(); helpBadge(); m = await ensureUsername(m); await loginAd(); inviteCard(m); return onReady(m); } signInFlow(async r => { whoPaint(r); themeSync(r); strip(); helpBadge(); await loginAd(); me(true).then(inviteCard); onReady(r); }); }
async function requireSession(onReady) { let m = await me(); whoPaint(m); themeSync(m); if (m && m.signedIn) { strip(); helpBadge(); tankItem(); m = await ensureUsername(m); await loginAd(); inviteCard(m); return onReady(m); } signInFlow(async r => { whoPaint(r); themeSync(r); strip(); helpBadge(); await loginAd(); me(true).then(inviteCard); onReady(r); }); }
// tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first
function sparkline(series) {
const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return '';
@@ -272,5 +289,5 @@ window.CR = (function () {
return '<div class="tile' + (o.hi ? ' hi' : '') + '"><span class="k">' + esc(o.k) + '</span><div class="row"><span class="v">' + o.v + (o.unit ? '<small>' + esc(o.unit) + '</small>' : '') + '</span>' + sparkline(o.series) + '</div>'
+ (o.delta ? '<span class="delta' + (o.delta.cls ? ' ' + o.delta.cls : '') + '">' + esc(o.delta.text) + '</span>' : '') + (o.note ? '<span class="muted mono" style="font-size:11px">' + esc(o.note) + '</span>' : '') + '</div>';
}
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow, tile, sparkline, delta, helpBadge };
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow, tile, sparkline, delta, helpBadge, tankItem };
})();
+2 -1
View File
@@ -17,6 +17,7 @@
zones: { video: 'zones', eyebrow: 'Your site pays you', h: 'One script tag. <em>Ad credits for every viewable view.</em>', lead: 'A zone is an ad slot on your own site in any of nine sizes. Member campaigns show first, then network ads, then a house banner. Viewable impressions pay you ad credits you spend on your own campaigns.', points: ['Viewable = half the banner on screen for one second. Bots never count.', 'Paid ads only on the site you declared.', 'Credits spend on your own banner or text campaign.'], cta: 'Add a zone, paste the tag', sub: 'free account by email' },
audiences: { video: 'audiences', eyebrow: 'Retargeting, built in', h: 'Reach your own visitors <em>again.</em>', lead: 'Everyone who views your pages or your zones is remembered for 30 days in an audience you own. Paste a pixel on any other site you control. Then show a campaign only to them, or never to them.', points: ['My visitors is automatic. Named audiences take one pixel line.', 'Show only to, or never show to, on any banner or text campaign.', 'Honest match: cookie plus a 24-hour fallback, nothing personal stored.'], cta: 'See your audiences', sub: 'free account by email' },
stack: { video: 'stack', eyebrow: 'Three tools, zero dollars', h: 'A rotator, a page builder, an ad slot. <em>Free.</em>', lead: 'Join with just an email and the whole stack is yours: spin links, bridge pages and a zone for your site. View a few ads a day and you earn credits for your first campaign. Buy a package only if you want more.', points: ['No wallet, no card, nothing to install.', 'Spin links, pages and zones never need a package.', 'Packages from $10 when you want more reach.'], cta: 'Start with the free stack', sub: 'type your email, get a code, that is the whole signup' },
b4h: { eyebrow: 'BTC4Hits is now LinkSpin', h: 'BTC4Hits is now <em>LinkSpin.</em>', lead: 'Your BTC4Hits account came with you. Sign in with the email you used there; an active rotator is already waiting as a LinkSpin spin link.', points: ['Sign in with your BTC4Hits email. We send a code, no password.', 'Active rotator links keep working and now forward through LinkSpin.', 'New here? The same box makes you a free account.'], cta: 'Sign in with your email', sub: 'same email as BTC4Hits, we send you a code', ctaBtn: 'Sign in with your BTC4Hits email' },
adspend: { eyebrow: 'For marketers who buy traffic', h: 'You were buying <em>ads anyway.</em>', lead: 'Every ad dollar you ever spent went one direction: out. Here the ad spend in your line pays you, in the same transaction, on a public ledger. Banner, text and login ads, packages from $10.', points: ['Views are timed on the server, so a real person saw your ad.', 'Your ads run in the viewer, on member sites and across the partner network.', 'Rotate the pages you promote with one spin link, free.'], cta: 'Put your next ad dollar where it pays you back', sub: 'free account by email, see every rate before you buy' }
};
const v = (new URLSearchParams(location.search).get('v') || (document.cookie.match(/(?:^|; )iap\.angle=([^;]+)/) || [])[1] || '').toLowerCase();
@@ -28,7 +29,7 @@
$('jnPoints').innerHTML = a.points.map(t => '<li>' + esc(t) + '</li>').join(''); $('jnPoints').hidden = false;
// the hook video (16:9 cut on Spaces) + a call to action that jumps to the email box
if (a.video) { const VID = 'https://coolify-saasytop.nyc3.digitaloceanspaces.com/linkspin/promo/'; const v = $('jnVideo'); v.src = VID + a.video + '.mp4'; v.poster = VID + a.video + '.jpg'; $('jnVideoWrap').hidden = false; }
$('jnCtaRow').hidden = false;
$('jnCtaRow').hidden = false; if (a.ctaBtn) $('jnCta').textContent = a.ctaBtn;
$('jnCta').addEventListener('click', e => { e.preventDefault(); const em = $('jnEmail'); em.scrollIntoView({ behavior: 'smooth', block: 'center' }); setTimeout(() => em.focus(), 450); });
}
// ?name=First personalises the page (site-owner links): letters, spaces, hyphens, apostrophes only, 30 chars
+6 -2
View File
@@ -68,6 +68,7 @@
return 'Checked ' + ago(h.checkedAt) + ', ' + (h.note || h.state) + (d.active ? ', strike ' + h.fails + ' of 3' + (h.fails >= 3 ? ', kept live' : ', pauses at 3') : '');
}
let HE = null; // the destination editor that is open: { rid, did }
const MANY = 60, FIRST = 50; const SHOWALL = new Set(); // big links (imported BTC4Hits rotators, hundreds of pages): first 50 rows until Show all
async function load(keep) {
let r; try { r = await CR.get('/api/my/rotations'); } catch (e) { CR.sub('could not load'); return; }
@@ -116,7 +117,8 @@
const prevHost = $('destRows').querySelector('[data-he]'); const prev = prevHost && HE && Number(prevHost.dataset.he) === HE.did && prevHost.heState ? prevHost.heState() : null;
$('autoNote').hidden = !auto.length;
if (auto.length) $('autoNote').textContent = 'LinkSpin paused ' + (auto.length === 1 ? 'one destination' : auto.length + ' destinations') + ' automatically after three failed checks: ' + auto.map(d => (d.label || d.url.replace(/^https?:\/\//, '')).slice(0, 40)).join(', ') + '. It comes back on its own after two clean checks, or fix the address and press Resume.';
$('destRows').innerHTML = r.destinations.length ? r.destinations.map(d => { const share = d.active ? Math.round(d.weight / total * 100) : 0; const h = d.health;
const big = r.destinations.length > MANY && !SHOWALL.has(r.id); const rows = big ? r.destinations.slice(0, FIRST) : r.destinations;
$('destRows').innerHTML = r.destinations.length ? rows.map(d => { const share = d.active ? Math.round(d.weight / total * 100) : 0; const h = d.health;
return '<div class="rw" data-did="' + d.id + '"><div><div class="dl"><span class="hdot ' + healthCls(h) + '" title="' + esc(healthLine(d)) + '"></span><span style="font-weight:700">' + esc(d.label || d.url.replace(/^https?:\/\//, '').slice(0, 60)) + '</span>' + (d.hours ? '<button class="hchip set" type="button" data-hc="' + d.id + '" title="This destination has its own hours">' + esc(hoursText(d.hours)) + '</button>' : '') + (h && h.frameBlocked ? '<span class="tag warn" title="This page refuses to load inside a frame (X-Frame-Options or CSP). Traffic exchanges that frame your link will show it blank.">no frames</span>' : '') + '</div>'
+ '<div class="mono muted" style="font-size:11px;overflow-wrap:anywhere">' + esc(d.url) + '</div><div class="muted" style="font-size:11px" data-hl="' + d.id + '">' + esc(healthLine(d)) + '</div></div>'
+ '<div class="wrow"><div class="bar" style="width:70px"><i style="width:' + share + '%"></i></div><input class="field mono" type="number" min="1" max="100" value="' + d.weight + '" data-w="' + d.id + '" aria-label="Weight"><span class="mono muted" style="font-size:11px">' + share + '%</span></div>'
@@ -124,8 +126,10 @@
+ '<span class="tag ' + (d.active ? 'ok' : d.autoPaused ? 'bad' : 'dim') + '">' + (d.active ? 'LIVE' : d.autoPaused ? 'AUTO-PAUSED' : 'PAUSED') + '</span>'
+ '<span style="display:flex;gap:6px;justify-content:flex-end"><button class="btn sm" type="button" data-hc="' + d.id + '" title="Hours for this destination" aria-label="Hours for this destination"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></button><button class="btn sm" type="button" data-t="' + d.id + '">' + (d.active ? 'Pause' : 'Resume') + '</button><button class="btn sm danger" type="button" data-x="' + d.id + '" aria-label="Remove">&times;</button></span></div>'
+ (HE && HE.rid === r.id && HE.did === d.id ? '<div class="rw edit" data-he="' + d.id + '"></div>' : ''); }).join('')
+ (big ? '<div class="rw"><span class="muted">Showing ' + FIRST + ' of ' + r.destinations.length + ' destinations (' + r.destinations.filter(d => d.active).length + ' live).</span> <button class="btn sm" type="button" id="destAll">Show all ' + r.destinations.length + '</button></div>' : '')
: '<div class="rw"><span class="muted">No destinations yet. Add the first page below; until then the link sends people to the fallback.</span></div>';
$('destFoot').textContent = 'weights are shares of the spin · fallback: ' + (r.fallback || 'none set') + ' · bots filtered on the server · one hop · health checked every 30 min';
if ($('destAll')) $('destAll').addEventListener('click', () => { SHOWALL.add(r.id); renderDest(r); });
const openEditor = did => { const d = r.destinations.find(q => q.id === did); if (!d) return; HE = { rid: r.id, did }; renderDest(r); };
$('destRows').querySelectorAll('[data-hc]').forEach(b => b.addEventListener('click', () => { if (HE && HE.rid === r.id && HE.did === Number(b.dataset.hc)) { HE = null; renderDest(r); } else openEditor(Number(b.dataset.hc)); }));
const heHost = $('destRows').querySelector('[data-he]');
@@ -234,7 +238,7 @@
$('hoursChip').addEventListener('click', () => { showTab('hours'); const h = $('rotHours'); if (h.scrollIntoView) h.scrollIntoView({ block: 'start', behavior: 'smooth' }); });
$('checkBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; const b = $('checkBtn'); b.disabled = true; b.textContent = 'Checking';
try { const out = await api('/api/my/rotations/' + r.id + '/health'); const i = ROT.findIndex(x => x.id === r.id); if (i >= 0 && out.rotation) ROT[i] = out.rotation; const fresh = out.rotation || r; renderDest(fresh); select(r.id, true);
const bad = fresh.destinations.filter(d => d.health && (d.health.state === 'dead' || d.health.state === 'parked')).length; toast('Checked ' + fresh.destinations.length + ' destination' + (fresh.destinations.length === 1 ? '' : 's') + (bad ? ', ' + bad + ' failing' : ', all answering')); }
if (out.background) { toast('Checking all ' + fresh.destinations.length + ' destinations in the background. Open the link again in a few minutes to see the results.'); } else { const bad = fresh.destinations.filter(d => d.health && (d.health.state === 'dead' || d.health.state === 'parked')).length; toast('Checked ' + fresh.destinations.length + ' destination' + (fresh.destinations.length === 1 ? '' : 's') + (bad ? ', ' + bad + ' failing' : ', all answering')); } }
catch (e) { toast(e.message, true); } b.disabled = false; b.textContent = 'Check now'; });
$('pbNew').addEventListener('click', () => pbForm(null));
$('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches;
+1 -1
View File
@@ -1277,7 +1277,7 @@
const r = await (await fetch('/api/my/tank')).json();
if (r.error) { el.innerHTML = ''; return; }
$('tankCap').textContent = r.cap; $('tankTtl').textContent = r.ttlDays;
$('tankSub').textContent = r.waiting.length ? r.waiting.length + ' waiting' : 'nobody waiting right now';
$('tankSub').textContent = (r.waiting.length ? r.waiting.length + ' waiting' : 'nobody waiting right now') + (r.cap ? ' · you can adopt up to ' + r.cap + ' at a time' : '');
const why = $('tankWhy'); why.hidden = r.eligible; why.innerHTML = r.eligible ? '' : '<span class="badge amber">not yet</span> ' + esc(r.reason);
$('tankMine').innerHTML = r.mine.length ? '<p class="small" style="margin:0 0 6px"><b>Your open adoptions</b></p>' + r.mine.map(m => '<div class="lin-row own"><span class="nm">' + esc(m.name) + '</span>'
+ '<span class="em">' + (m.bought ? 'bought' : m.wallet ? 'wallet linked' : 'free, no wallet yet') + ' · last seen ' + ago(m.lastSeen) + '</span>'
+1 -1
View File
@@ -70,7 +70,7 @@
<div id="goalReports"></div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/conversions.js?v=20261026a"></script>
</body>
</html>
+1 -1
View File
@@ -83,7 +83,7 @@
</div>
<script src="/assets/common.js?v=20261107tg"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/credits-screen.js?v=20261107tg"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
</body>
+1 -1
View File
@@ -30,7 +30,7 @@
<div id="page">
<div class="body" id="helpBody"><div class="panel"><span class="muted">loading</span></div></div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/help-screen.js?v=20261016a"></script>
</body>
</html>
+1 -1
View File
@@ -107,6 +107,6 @@ body.squeeze .card{position:sticky;top:16px}
</div>
</footer>
<script src="/assets/common.js?v=20261107tg"></script>
<script src="/assets/join.js?v=20261107nc"></script>
<script src="/assets/join.js?v=20261111b4h"></script>
</body>
</html>
+2 -2
View File
@@ -270,8 +270,8 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/links.js?v=20261021t"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/links.js?v=20261111big"></script>
<script src="/assets/banner-spin.js?v=20261105sz"></script>
</body>
</html>
+2 -2
View File
@@ -1016,11 +1016,11 @@
</div>
</div>
<script src="/assets/common.js?v=20261107tg"></script>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/tools.js?v=20261011a"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/promo.js?v=20261020bs3"></script>
<script src="/assets/my.js?v=20261107tg"></script>
<script src="/assets/my.js?v=20261111tank"></script>
<script src="/assets/chat.js?v=20261016a"></script>
</body>
</html>
+1 -1
View File
@@ -73,7 +73,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/pages-screen.js?v=20261021t"></script>
</body>
</html>
+1 -1
View File
@@ -90,7 +90,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/reports.js?v=20261107nc"></script>
</body>
</html>
+1 -1
View File
@@ -128,7 +128,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/traffic-guide-data.js?v=20261028a"></script>
<script src="/assets/sources-screen.js?v=20261028a"></script>
</body>
+1 -1
View File
@@ -38,7 +38,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/team.js?v=20261105fd"></script>
</body>
</html>
+1 -1
View File
@@ -64,7 +64,7 @@
<div class="rules" id="rules"></div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/traffic-guide-data.js?v=20261028a"></script>
<script src="/assets/traffic-guide.js?v=20261029b"></script>
</body>
+1 -1
View File
@@ -36,7 +36,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/wallet-screen.js?v=20261023ov"></script>
</body>
</html>
+1 -1
View File
@@ -42,7 +42,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261110forum"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/zones-screen.js?v=20261010a"></script>
</body>
</html>
+95
View File
@@ -0,0 +1,95 @@
// BTC4Hits bridge + admin spin links (2026-11-11). Boots a throwaway LinkSpin (temp DATA_DIR, JSON stores, no mail key,
// ADMIN_PASSWORD=localtest) and checks:
// /from/btc4hits: 200, the sponsor cookie is cleared, angle b4h + forced first-touch source legacy:btc4hits, sign-in copy,
// no em dash in the copy; a sign-up through it gets NO welcome-back credits (legacy grant rule is fw/t1 only)
// /api/admin/rotations: POST with urls[] makes one spin link with every destination at weight 1, GET lists links + sources,
// DELETE removes it; auth required.
// node qa/btc4hits-bridge.test.mjs (B4H_PORT to move the port)
import { spawn } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
const SITE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
const PORT = Number(process.env.B4H_PORT || 8831), BASE = 'http://127.0.0.1:' + PORT;
const sleep = ms => new Promise(r => setTimeout(r, ms));
let pass = 0, fail = 0; const ok = (c, n, x) => { if (c) { pass++; console.log('ok ' + n); } else { fail++; console.log('FAIL ' + n + (x ? '\n ' + x : '')); } };
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'b4h-ls-')); fs.mkdirSync(path.join(dir, 'uploads'), { recursive: true });
const now = Date.now();
fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify({ v: 2, byEmail: { 'owner@qa.test': { email: 'owner@qa.test', pass: null, sponsorRef: '', code: 'cowner1', username: 'owner', address: null, created: now - 86400000, joinedVia: 'carried', joinedRef: 'network' } }, byAddress: {}, byCode: { cowner1: 'owner@qa.test' }, joins: 0, positions: {} }));
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: dir, ADMIN_EMAIL: 'admin@qa.test', ADMIN_PASSWORD: 'localtest', DATABASE_URL: '', SENDGRID_API_KEY: '', SENDGRID_KEY: '', OUTBOUND: '', LS_SYNC_SECRET: '', ENGINE_KEY: '', ENGINE_KEY_FILE: '' });
const log = path.join(dir, 'server.log');
const proc = spawn(process.execPath, ['server.js'], { cwd: SITE, env, stdio: ['ignore', fs.openSync(log, 'w'), fs.openSync(log, 'a')] });
const admin = (pth, method, body, auth = true) => fetch(BASE + pth, { method, headers: Object.assign({ 'Content-Type': 'application/json' }, auth ? { Authorization: 'Bearer localtest' } : {}), body: body ? JSON.stringify(body) : undefined });
try {
let up = false; for (let i = 0; i < 40 && !up; i++) { try { up = (await fetch(BASE + '/api/config', { signal: AbortSignal.timeout(2000) })).status < 500; } catch (e) { await sleep(1000); } }
ok(up, 'local LinkSpin up');
// 1. the bridge page
const r = await fetch(BASE + '/from/btc4hits?src=splash', { headers: { Cookie: 'iap.sponsor=someone' } });
const html = await r.text(); const ck = r.headers.getSetCookie ? r.headers.getSetCookie() : [];
ok(r.status === 200, '/from/btc4hits answers 200', String(r.status));
ok(ck.some(c => /^iap\.sponsor=;/.test(c) && /Max-Age=0/.test(c)), 'sponsor cookie cleared (no sponsor from the bridge itself)', ck.join(' | '));
ok(ck.some(c => /^iap\.angle=b4h;/.test(c)), 'angle b4h remembered');
ok(ck.some(c => c.startsWith('iap.ref=' + encodeURIComponent('legacy:btc4hits:splash') + ';')), 'forced first-touch source legacy:btc4hits', ck.join(' | '));
ok(/<title>BTC4Hits is now LinkSpin\. \| LinkSpin<\/title>/.test(html) && html.includes('class="squeeze"'), 'title + squeeze layout');
ok(html.includes('join.js?v=20261111b4h'), 'join.js version bumped');
const js = fs.readFileSync(path.join(SITE, 'public', 'assets', 'join.js'), 'utf8'); const b4h = (js.match(/\n\s+b4h: \{[^\n]+/) || [''])[0];
ok(b4h.includes('Sign in with your BTC4Hits email') && b4h.includes("cta: 'Sign in with your email'"), 'sign-in call to action in the b4h copy');
ok(!/—/.test(b4h) && !/—/.test(html.match(/<title>[^<]*/)[0]), 'no em dash in the copy');
// a brand-new sign-up arriving through the bridge: no welcome-back credits
const st = await (await fetch(BASE + '/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.angle=b4h; iap.ref=legacy%3Abtc4hits' }, body: JSON.stringify({ email: 'newb4h@qa.test', fts: Date.now() - 8000 }) })).json();
if (st.devCode) {
const v = await fetch(BASE + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.angle=b4h; iap.ref=legacy%3Abtc4hits' }, body: JSON.stringify({ email: 'newb4h@qa.test', code: st.devCode }) });
ok(v.status === 200, 'sign-up through the bridge works', String(v.status));
await sleep(300);
ok(!fs.existsSync(path.join(dir, 'legacy-grants.json')) && !/legacy grant/.test(fs.readFileSync(log, 'utf8')), 'no welcome-back credits granted');
const a = JSON.parse(fs.readFileSync(path.join(dir, 'accounts.json'), 'utf8')).byEmail['newb4h@qa.test'];
ok(a && a.joinedVia === 'b4h' && a.joinedRef === 'legacy:btc4hits', 'account records angle b4h + source legacy:btc4hits', JSON.stringify(a && { v: a.joinedVia, r: a.joinedRef }));
// 1b. Holding tank menu item (2026-11-11): the summary route, and the rail item in a real browser
const cookies = (v.headers.getSetCookie ? v.headers.getSetCookie() : []).map(c => c.split(';')[0]);
const sum = await (await fetch(BASE + '/api/my/tank/summary', { headers: { Cookie: cookies.join('; ') } })).json();
ok(sum.adopter === false && sum.cap === 10 && typeof sum.waiting === 'number', '/api/my/tank/summary: a new member is not an adopter, cap 10 from the setting', JSON.stringify(sum));
ok((await fetch(BASE + '/api/my/tank/summary')).status === 401, '/api/my/tank/summary needs a sign-in');
try {
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
const browser = await chromium.launch();
const shot = async (summary) => {
const ctx = await browser.newContext(); await ctx.addCookies(cookies.map(c => { const i = c.indexOf('='); return { name: c.slice(0, i), value: c.slice(i + 1), domain: '127.0.0.1', path: '/' }; }));
const page = await ctx.newPage(); const errs = []; page.on('pageerror', e => errs.push(e.message));
if (summary) await page.route('**/api/my/tank/summary', r => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(summary) }));
await page.goto(BASE + '/links', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(2500);
const out = await page.evaluate(() => { const a = document.getElementById('crTank'); return a ? { hidden: a.hidden, href: a.getAttribute('href'), title: a.title, badge: (a.querySelector('.rbadge') || {}).textContent || '', label: (a.querySelector('.lbl') || {}).textContent || '' } : null; });
await ctx.close(); return Object.assign({ errs }, out || {});
};
const s1 = await shot(null);
ok(s1.href === '/tools#line' && s1.hidden === true, 'rail: Holding tank item hidden for a member who cannot adopt', JSON.stringify(s1));
const s2 = await shot({ adopter: true, eligible: true, full: false, held: 2, cap: 10, waiting: 1234 });
ok(s2.hidden === false && s2.label === 'Holding tank' && s2.badge === '999+', 'rail: shown for an adopter, with the waiting badge', JSON.stringify(s2));
ok(/You can adopt up to 10 people at a time\./.test(s2.title) && /1,234 waiting/.test(s2.title) && !/\u2014/.test(s2.title), 'rail: one line with the cap from the setting', s2.title);
const s3 = await shot({ adopter: true, eligible: false, full: true, held: 7, cap: 7, waiting: 0 });
ok(s3.hidden === false && !s3.badge && /up to 7 people at a time/.test(s3.title), 'rail: an adopter at the cap still sees it; cap read from the response (7), no badge when nobody waits', JSON.stringify(s3));
ok(!s1.errs.length && !s2.errs.length, 'no page errors', JSON.stringify(s1.errs.concat(s2.errs)).slice(0, 200));
await browser.close();
} catch (e) { ok(false, 'browser check ran', e.message); }
} else ok(false, 'dev sign-in code available', JSON.stringify(st));
// 2. admin spin links
ok((await admin('/api/admin/rotations?email=owner@qa.test', 'GET', null, false)).status === 401, 'GET needs admin');
const urls = ['https://example.com/a', 'https://example.org/b', 'example.net/c'].map(u => ({ url: u, label: 'x' }));
const p = await (await admin('/api/admin/rotations', 'POST', { email: 'owner@qa.test', source: { name: 'BTC4Hits', site: 'btc4hits.com' }, links: [{ name: 'BTC4Hits rotator #7', url: urls[0].url, fallback: urls[0].url, urls }] })).json();
ok(p.ok && p.links[0].dests === 3 && p.links[0].code, 'POST makes one link with 3 destinations', JSON.stringify(p));
const g = await (await admin('/api/admin/rotations?email=owner@qa.test', 'GET')).json();
const rot = (g.rotations || []).find(x => x.name === 'BTC4Hits rotator #7');
ok(rot && rot.destinations.length === 3 && rot.destinations.every(d => d.weight === 1 && d.active) && rot.destinations[2].url === 'https://example.net/c', 'GET lists it: 3 active destinations, weight 1, cleaned URLs');
ok(rot && rot.sourceId && (g.sources || []).some(s => s.id === rot.sourceId && s.name === 'BTC4Hits'), 'attached to the BTC4Hits source');
ok(typeof g.linkBase === 'string' && g.linkBase.endsWith('/r/'), 'linkBase given');
const red = await fetch(BASE + '/r/' + rot.code, { redirect: 'manual', headers: { 'User-Agent': 'curl/8' } });
ok(red.status >= 301 && red.status <= 308 && urls.some(u => red.headers.get('location').startsWith(u.url.startsWith('http') ? u.url : 'https://' + u.url)), '/r/<code> redirects to one of them', red.status + ' ' + red.headers.get('location'));
const d = await admin('/api/admin/rotations?email=owner@qa.test&id=' + rot.id, 'DELETE');
ok(d.status === 200, 'DELETE removes it');
const g2 = await (await admin('/api/admin/rotations?email=owner@qa.test', 'GET')).json();
ok(!(g2.rotations || []).length, 'gone after DELETE');
ok((await admin('/api/admin/rotations?email=nobody@qa.test', 'GET')).status === 404, 'unknown member -> 404');
} finally { proc.kill(); }
console.log('\n' + pass + ' passed, ' + fail + ' failed');
process.exit(fail ? 1 : 0);
+61
View File
@@ -0,0 +1,61 @@
// Holding-tank adoption cap + BTC4Hits wording (2026-11-11). No server: the real tank.js with in-memory accounts, a fake
// chain and a capturing mailer/messages, on a throwaway dir. node qa/tank-cap.test.mjs
// Marty: an adopter may hold up to 10 people from the tank at one time (not yet switched on payouts), as a setting;
// a BTC4Hits import is told the truth (their BTC4Hits account moved here), never "You joined LinkSpin without a sponsor".
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { createRequire } from 'node:module';
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
const require = createRequire(path.join(SITE, 'package.json'));
delete process.env.DATABASE_URL;
let fails = 0, passes = 0; const ok = (c, l, x) => { console.log((c ? 'PASS ' : 'FAIL ') + l + (x && !c ? ' ' + String(x).slice(0, 300) : '')); if (c) passes++; else fails++; };
const DAY = 86400000;
function bench(cap) {
delete require.cache[require.resolve(path.join(SITE, 'tank.js'))];
const tank = require(path.join(SITE, 'tank.js'));
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ls-tankcap-'));
const by = new Map(); let n = 100; const pub = a => a ? Object.assign({}, a) : null; const find = f => { for (const a of by.values()) if (f(a)) return pub(a); return null; };
const accounts = { add(email, o) { by.set(email, Object.assign({ email, username: null, code: 'c' + (n++), sponsorRef: '', memberId: 0, address: null, created: Date.now() - 3 * DAY, lastSeen: 0, joinedVia: 'carried', joinedRef: 'network' }, o || {})); },
async byEmail(e) { return pub(by.get(String(e || '').toLowerCase())); }, async byUsername(u) { return find(a => a.username === String(u || '').toLowerCase()); }, async byCode(c) { return find(a => a.code === String(c || '').toLowerCase()); },
async byMemberId(id) { return find(a => Number(a.memberId) === Number(id) && id > 0); }, async setSponsorRef(e, ref) { const a = by.get(e); a.sponsorRef = String(ref || ''); return { ok: true }; },
async listAll() { return [...by.values()].map(pub); }, async sponsorOf() { return null; }, _by: by };
const events = []; const mails = []; const chats = [];
tank.init({ dataDir: dir, accounts, chain: { recentEvents: () => events.slice(), getConfig: () => ({ explorer: 'https://polygonscan.com' }) },
messages: { sendChat: async (id, from, to, text) => { chats.push({ to, text }); }, lastFrom: async () => 0 },
mailer: { hasKey: () => true, send: async (to, subject, text) => { mails.push({ to, subject, text }); } }, site: 'https://linkspin.test',
capOpen: cap === undefined ? undefined : () => cap, hooks: {} });
accounts.add('adopter@x.co', { username: 'helper', memberId: 77, address: '0x' + '1'.repeat(40), lastSeen: Date.now() - 3600000, joinedVia: null, joinedRef: null });
events.push({ type: 'Purchase', buyerId: 77, priceCents: 2500, block: 1 });
return { tank, accounts, mails, chats };
}
{ // default cap 10, measured as people held who have not switched on payouts
const B = bench(); const { tank, accounts, mails, chats } = B;
for (let i = 0; i < 12; i++) accounts.add('m' + i + '@b4h.test', { joinedRef: i < 6 ? 'btc4hits' : 'network' });
ok(tank.capOpen() === 10, 'default cap is 10');
let okCount = 0; for (let i = 0; i < 10; i++) { const r = await tank.adopt('adopter@x.co', 'm' + i + '@b4h.test'); if (r.ok) okCount++; else console.log(' adopt ' + i + ': ' + r.error); }
ok(okCount === 10, 'adopts 10 in a row');
const r11 = await tank.adopt('adopter@x.co', 'm10@b4h.test');
ok(r11.error && /helping 10 people/.test(r11.error) && /10 at one time is the most/.test(r11.error) && !/—/.test(r11.error), 'the 11th is refused with a clear message', JSON.stringify(r11));
const v = await tank.view('adopter@x.co'); ok(v.cap === 10 && v.eligible === false && /10 at one time/.test(v.reason), 'tank view shows cap 10 and the reason');
accounts._by.get('m3@b4h.test').memberId = 901; // one of them switched on payouts: the slot frees at once
const r11b = await tank.adopt('adopter@x.co', 'm10@b4h.test'); ok(r11b.ok, 'a held member switching on payouts frees a slot right away', JSON.stringify(r11b));
ok((await tank.adopt('adopter@x.co', 'm11@b4h.test')).error, 'and the cap holds again at 10 not yet switched on');
// wording
const imp = mails.filter(m => m.to === 'm0@b4h.test'); const reg = mails.filter(m => m.to === 'm7@b4h.test');
ok(imp.length === 1 && reg.length === 1, 'exactly one email to each adoptee', JSON.stringify(mails.map(m => m.to)));
ok(/BTC4Hits has moved to LinkSpin, and your BTC4Hits account came with you/.test(imp[0].text) && /\/from\/btc4hits/.test(imp[0].text) && !/You joined LinkSpin/.test(imp[0].text), 'BTC4Hits import: email says the account moved, points to /from/btc4hits', imp[0].text);
ok(/Your BTC4Hits account moved to LinkSpin without a sponsor/.test((chats.find(c => c.to === 'm0@b4h.test') || {}).text || ''), 'BTC4Hits import: the default first chat reads right too');
ok(/^You joined LinkSpin without a sponsor/.test(reg[0].text) && /\/my#messages/.test(reg[0].text), 'ordinary tank member keeps the old wording');
ok(imp[0].subject === '@helper is now your sponsor on LinkSpin', 'subject unchanged', imp[0].subject);
ok(!mails.some(m => /—/.test(m.text + m.subject)), 'no em dash in any adoption email');
ok(!mails.some(m => m.to === 'adopter@x.co'), 'no email to the adopter on a hand adoption');
}
{ // the setting
const B = bench(3); const { tank, accounts } = B;
for (let i = 0; i < 4; i++) accounts.add('s' + i + '@b4h.test');
for (let i = 0; i < 3; i++) await tank.adopt('adopter@x.co', 's' + i + '@b4h.test');
const r = await tank.adopt('adopter@x.co', 's3@b4h.test'); ok(r.error && /3 at one time/.test(r.error), 'tankAdoptCap setting is respected (3)', JSON.stringify(r));
const B2 = bench('junk'); ok(B2.tank.capOpen() === 10, 'a bad setting falls back to 10');
}
console.log('\n' + passes + ' passed, ' + fails + ' failed'); process.exit(fails ? 1 : 0);
+2
View File
@@ -146,6 +146,8 @@ async function partA() {
const f4b = await accounts.byEmail('free4@x.co');
ok(f4b.memberId > 0 && sends.slice(n0).every(s => s.sponsorId === 11), 'retried on a later tick and switched on under A (#11), never #1', JSON.stringify(sends.slice(n0)));
ok(chats.some(c => c.to === 'free4@x.co' && /Your LinkSpin payouts are now on under @a/.test(c.text)), 'follow-up chat once the retried activation lands');
// since 2026-11-11 the cap is people held at one time who have not switched on payouts (default 10): fill A up by hand
for (let i = 0; i < tank.capOpen(); i++) { accounts.add('fill' + i + '@x.co'); await tank.adopt('a@x.co', 'fill' + i + '@x.co'); }
// A full (2 open), B + C stale: nobody eligible -> keep holding, one admin alert
accounts._by.get('b@x.co').lastSeen = env.now - 8 * 86400000; accounts._by.get('c@x.co').lastSeen = env.now - 8 * 86400000;
accounts.add('free5@x.co', { address: addr() }); await tank.readyTick(); env.now += 24 * H;
+8 -3
View File
@@ -130,13 +130,18 @@ async function update(owner, id, body) {
J.save(); return { ok: true, rotation: pub(r) };
}
async function remove(owner, id) { const n = J.db.rotations.length; J.db.rotations = J.db.rotations.filter(r => !(r.id === Number(id) && r.owner === norm(owner))); J.save(); return n !== J.db.rotations.length ? { ok: true } : { error: 'No such rotation.' }; }
async function addDest(owner, id, body) {
// opts.max: the admin import path only (BTC4Hits rotators, 2026-11-11) may go past the 25 a member can add, up to IMPORT_MAX
const DEST_MAX = 25, IMPORT_MAX = 2000;
async function addDest(owner, id, body, opts) {
const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); if (!r) return { error: 'No such rotation.' };
const url = cleanUrl(body.url); if (!url) return { error: 'Destination must be a full https:// address.' };
if (r.destinations.length >= 25) return { error: 'Up to 25 destinations per rotation.' };
const cap = opts && opts.max ? Math.min(IMPORT_MAX, Math.max(DEST_MAX, Math.round(Number(opts.max) || DEST_MAX))) : DEST_MAX;
if (r.destinations.length >= cap) return { error: 'Up to ' + DEST_MAX + ' destinations per rotation.' };
const w = Math.max(1, Math.min(100, Math.round(Number(body.weight) || 1)));
const d = { id: r.nextDest++, url, label: String(body.label || '').trim().slice(0, 60), weight: w, active: true, added: Date.now() };
r.destinations.push(d); J.save(); return { ok: true, rotation: pub(r) };
r.destinations.push(d);
if (opts && opts.defer) return { ok: true, id: d.id }; // bulk import: the caller saves once at the end (rotator.json holds every click, ~18 MB; one write per destination would stall the app)
J.save(); return { ok: true, rotation: pub(r) };
}
async function updateDest(owner, id, did, body) {
const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); if (!r) return { error: 'No such rotation.' };
+34 -6
View File
@@ -480,6 +480,7 @@ const JOIN_ANGLES = {
'fw-adv': { t: 'Your next ad budget pays you back.', d: 'Faucet Wave closed. LinkSpin was built for the people who bought ads there: packages from $10, banner, text and login ads, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave?seg=advertiser' },
'fw-earn': { t: 'Same daily habit. Real payouts on-chain.', d: 'You viewed ads on Faucet Wave. Here you view ads to earn credits, run your own campaign free, and get paid in POL to your own wallet when your line buys ads. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave' },
't1-adv': { t: 'Your next ad budget pays you back.', d: 'Tier One Ads closed. LinkSpin was built for the people who bought ads there: packages from $10, banner, text and login ads, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads?seg=advertiser' },
'b4h': { t: 'BTC4Hits is now LinkSpin.', d: 'Your BTC4Hits account came with you. Sign in with the same email; an active rotator is already waiting as a LinkSpin spin link.', url: SITE_URL + '/from/btc4hits' },
't1-earn': { t: 'Same daily habit. Real payouts on-chain.', d: 'You viewed ads on Tier One Ads. Here you view ads to earn credits, run your own campaign free, and get paid in POL to your own wallet when your line buys ads. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads' },
instant: { t: 'Paid before the page reloads.', d: 'A smart contract on Polygon splits every ad package the moment it sells. Same transaction, real wallets, public ledger. Join free by email.' },
adspend: { t: 'You were buying ads anyway.', d: 'Here the ad spend in your line pays you, in the same transaction, on a public ledger. Banner, text and login ads, packages from $10. Join free.' },
@@ -731,7 +732,7 @@ async function boot() {
zonereport.init({ dataDir: DATA_DIR });
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, accounts, rotator, bannerspin, zones, pages, send: async (c, t, th) => { await telegramSend(c, t, th); return true; } });
setInterval(() => snapshot.tick().catch(e => console.error('snapshot', e.message)), 10 * 60 * 1000);
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, site: SITE_URL, follow, store: followStore,
tank.init({ capOpen: () => siteConfig().tankAdoptCap, dataDir: DATA_DIR, chain, accounts, messages, mailer, site: SITE_URL, follow, store: followStore,
// network alignment + activation hold + 24-hour safety net (2026-10-27): a tank member's plain activation is never
// bound under the fallback position; their InstantAdPay sponsor first, else an adopter (a purchase is never held)
hooks: { network: (email, address) => networkSponsor(email, address), prefetch: emails => iapFacts(emails, { timeout: 20000 }),
@@ -828,6 +829,7 @@ function siteConfig() {
memberWeeklyEmail: '0', // 1 = the weekly 'Your week on LinkSpin' email goes to every active member, not only sponsors with a line
noPayoutIds: '', // LinkSpin member ids differ from InstantAdPay's (IAP #25 = Jim's compromised wallet; LinkSpin #25 is a real member, cleared 2026-10-15). Positions kept for linkage only (compromised wallets): no buys signed from them, no new joins routed under them or their upline chain (Marty, 2026-09-14)
leaderboardWeeklyPrize: '', leaderboardMonthlyPrize: '', leaderboardWeeklyCredits: '1000,500,250', leaderboardMonthlyCredits: '5000,2500,1000', leaderboardAnnounceGeneral: '1', // referral contest prizes (text shown on /leaderboard; credits granted to the winner automatically at rollover)
tankAdoptCap: 10, // holding tank: people one adopter may hold at one time (not yet switched on payouts), Marty 2026-11-11
legacyCreditsAdvertiser: 500, legacyCreditsEarner: 150, // welcome-back credits for listed Faucet Wave / Tier One Ads emails arriving via /from/<brand>
geoTier1: '', // comma-separated ISO country codes; empty = built-in default (US, CA, GB, AU, NZ, IE, DE, FR, NL, SE, NO, DK, FI, CH, AT, BE)
geoTier2: '', // empty = built-in default (rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO ...); tier 3 = everything else
@@ -1587,10 +1589,12 @@ const server = http.createServer(async (req, res) => {
// with brand copy, NO sponsor (the sponsor cookie is cleared so they land in the holding
// tank for adoption), the angle remembered so the welcome-back grant fires at signup, and
// a forced first-touch source so link stats / admin can see the legacy arrivals.
m = /^\/from\/(faucetwave|tieroneads)$/.exec(p);
// /from/btc4hits (2026-11-11): the closed BTC4Hits rotator site. Its members were imported as waiting accounts, so the
// page is mostly a sign-in; angle 'b4h' is outside the fw/t1 grant rule, so no welcome-back credits are ever granted.
m = /^\/from\/(faucetwave|tieroneads|btc4hits)$/.exec(p);
if (m && (req.method === 'GET' || req.method === 'HEAD')) {
const brand = m[1];
const key = (brand === 'faucetwave' ? 'fw' : 't1') + (String(u.searchParams.get('seg') || '').toLowerCase().startsWith('adv') ? '-adv' : '-earn');
const key = brand === 'btc4hits' ? 'b4h' : (brand === 'faucetwave' ? 'fw' : 't1') + (String(u.searchParams.get('seg') || '').toLowerCase().startsWith('adv') ? '-adv' : '-earn');
const cookieTail = `; Path=/; SameSite=Lax; Max-Age=${30 * 24 * 3600}${IS_PROD ? '; Secure' : ''}`;
const src = String(u.searchParams.get('src') || '').toLowerCase().replace(/[^a-z0-9.\-]/g, '').slice(0, 40); // e.g. the old domain's splash page
const set = ['iap.sponsor=; Path=/; SameSite=Lax; Max-Age=0' + (IS_PROD ? '; Secure' : ''), 'iap.angle=' + key + cookieTail, 'iap.ref=' + encodeURIComponent('legacy:' + brand + (src ? ':' + src : '')) + cookieTail];
@@ -2249,12 +2253,27 @@ const server = http.createServer(async (req, res) => {
const out = [];
for (const l of (Array.isArray(b.links) ? b.links : []).slice(0, 25)) {
const c = await rotator.create(a.email, { name: String(l.name || ''), fallback: String(l.url || '') }); if (c.error) { out.push({ name: l.name, error: c.error }); continue; }
const d = await rotator.addDest(a.email, c.rotation.id, { url: String(l.url || ''), label: String(l.label || ''), weight: 1 }); if (d.error) { out.push({ name: l.name, error: d.error }); continue; }
// several destinations (2026-11-11, BTC4Hits rotators): l.urls = [{ url, label }] at equal weight, up to the rotator's own cap of 25
const list = Array.isArray(l.urls) && l.urls.length ? l.urls.map(x => typeof x === 'string' ? { url: x } : x) : [{ url: l.url, label: l.label }];
if (l.fallback) await rotator.update(a.email, c.rotation.id, { fallback: String(l.fallback) });
const maxDests = Math.max(25, Math.min(2000, Number(b.maxDests) || 25)); // the import may go past the member cap of 25 (BTC4Hits rotators)
let added = 0; const destErrors = []; for (const x of list) { const d = await rotator.addDest(a.email, c.rotation.id, { url: String(x.url || ''), label: String(x.label || ''), weight: 1 }, { max: maxDests, defer: true }); if (d.error) destErrors.push({ url: String(x.url || '').slice(0, 120), error: d.error }); else added++; }
await rotator.update(a.email, c.rotation.id, {}); // one save for the whole batch of destinations
if (!added) { await rotator.remove(a.email, c.rotation.id); out.push({ name: l.name, error: (destErrors[0] || {}).error || 'no destination' }); continue; }
if (sourceId) { const up = await rotator.update(a.email, c.rotation.id, { sourceId }); if (up && up.error) out.push({ name: l.name, warn: 'source not attached: ' + up.error }); }
out.push({ name: l.name, id: c.rotation.id, code: c.rotation.code, url: 'https://' + host + '/r/' + c.rotation.code, to: l.url });
out.push({ name: l.name, id: c.rotation.id, code: c.rotation.code, url: 'https://' + host + '/r/' + c.rotation.code, to: list[0].url, dests: added, destErrors });
}
return json(res, 200, { ok: true, email: a.email, sourceId: sourceId || null, links: out });
}
// a member's spin links + traffic sources (2026-11-11, BTC4Hits import: makes the admin route above idempotent), and removing one
if (p === '/api/admin/rotations' && (req.method === 'GET' || req.method === 'DELETE')) {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const a = await adminMember.resolve(String(u.searchParams.get('email') || ''));
if (!a) return json(res, 404, { error: 'No member matches that email.' });
if (req.method === 'DELETE') { const r = await rotator.remove(a.email, u.searchParams.get('id')); console.log('admin removed rotation', a.email, u.searchParams.get('id')); return json(res, r.error ? 404 : 200, r); }
const host = String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(h => h && !h.startsWith('www.'))[0] || SITE_HOST;
return json(res, 200, { email: a.email, linkBase: 'https://' + host + '/r/', rotations: await rotator.list(a.email), sources: (await sources.list(a.email)).sources }, { 'Cache-Control': 'no-store' });
}
if (p === '/api/admin/member' && req.method === 'PATCH') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const b = await readBody(req);
@@ -2479,6 +2498,15 @@ const server = http.createServer(async (req, res) => {
for (let i = 2; i < 100 && await accounts.byUsername(pick); i++) pick = base.slice(0, 20 - String(i).length) + i;
return json(res, 200, { suggest: pick });
}
// the menu item (2026-11-11): may this member adopt, how many can be adopted right now, the at-one-time cap. Cheap: the waiting
// list is the same 60-second cache the Overview notice uses; the full list stays on /api/my/tank.
if (p === '/api/my/tank/summary' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
if (!tankWaitCache || Date.now() - tankWaitCache.ts > 60000) tankWaitCache = { ts: Date.now(), list: await tank.waiting() };
const el = await tank.eligibility(s.email);
return json(res, 200, { adopter: !!(el.ok || el.full), eligible: !!el.ok, full: !!el.full, held: el.held != null ? el.held : null, cap: tank.capOpen(), waiting: tank.adoptableOf(tankWaitCache.list).length }, { 'Cache-Control': 'no-store' });
}
if (p === '/api/my/tank' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
@@ -2952,7 +2980,7 @@ const server = http.createServer(async (req, res) => {
const e = String(r.email || '').trim().toLowerCase(); if (!e) continue;
let a = await accounts.byEmail(e);
const created = !a;
if (!a) { const x = await accounts.ensure(e, '', 'carried', 'network'); if (x.created) shells++; a = await accounts.byEmail(e); }
if (!a) { const x = await accounts.ensure(e, '', 'carried', r.origin === 'btc4hits' ? 'btc4hits' : 'network'); if (x.created) shells++; a = await accounts.byEmail(e); } // BTC4Hits imports keep their origin (tank mail wording)
if (!a) continue;
if (Object.prototype.hasOwnProperty.call(r, 'tank')) followStore.setRemote(e, r.tank); // network tank: InstantAdPay's own adoptions of them
if (created && SF.incomingOf(r)) { const inc = SF.incomingOf(r); followStore.record(e, { at: inc.at, by: inc.by, sponsorEmail: inc.sponsorEmail, prevEmail: inc.prevEmail, origin: inc.origin || 'instantadpay' }); } // a new shell carries the same record (no echo)
+23 -13
View File
@@ -12,7 +12,12 @@ const fs = require('fs');
const path = require('path');
const db = require('./db');
const CAP_OPEN = 2; // open adoptions per adopter
// How many people an adopter may hold from the tank AT ONE TIME (Marty 2026-11-11, for the ~1,200 BTC4Hits imports, 6 then 10 the same day; was 2 open
// adoptions): open adoptions whose person has not switched payouts on yet (no member id). Activating frees the slot at once; the
// 7-day window closes the rest as before. Site setting tankAdoptCap, default 10.
const CAP_DEFAULT = 10; let capFn = () => CAP_DEFAULT;
const capOpen = () => { const n = Math.round(Number(capFn())); return n >= 1 && n <= 50 ? n : CAP_DEFAULT; };
async function holding(open) { const out = []; for (const ad of open || []) { const a = await accounts.byEmail(ad.adoptee); if (!(a && Number(a.memberId) > 0)) out.push(ad); } return out; }
const TTL_MS = 7 * 86400000; // an adoption's window to convert
const MAX_ADOPTIONS = 2; // per adoptee, lifetime (dropped adoptions count too, since 2026-09-13)
const HOLD_MS = 3 * 24 * 3600 * 1000; // an adoption is a commitment: no releasing someone you picked up less than 3 days ago (Marty, 2026-09-13)
@@ -67,7 +72,7 @@ const D = {
const rowA = r => ({ id: r.id, adoptee: r.adoptee, adopter: r.adopter, ts: Number(r.ts), expires: Number(r.expires), status: r.status, note: r.note || null, closed: r.closed ? Number(r.closed) : null });
const impl = () => db.enabled() ? D : J;
function init(opts) { DATA_DIR = opts.dataDir; accounts = opts.accounts; chain = opts.chain; messages = opts.messages; mailer = opts.mailer; if (opts.site) siteUrl = opts.site; follow = opts.follow || null; store = opts.store || null; J.load();
function init(opts) { DATA_DIR = opts.dataDir; accounts = opts.accounts; chain = opts.chain; messages = opts.messages; mailer = opts.mailer; if (opts.site) siteUrl = opts.site; follow = opts.follow || null; store = opts.store || null; if (opts.capOpen) capFn = opts.capOpen; J.load();
hooks = opts.hooks || {}; RS.st = null; RS.load(); }
// every sponsor change the tank makes is deliberate: recorded (when, how, the sponsor before) so it follows to InstantAdPay
// until the member is bound on a contract (sponsorfollow.js). Without the follow glue (tests) it is a plain write.
@@ -84,7 +89,7 @@ const inTank = a => !a.sponsorRef && !a.memberId; // arrived with no sponsor (or
// waiting list: newest sign-in first so a live one is easy to spot
async function waiting() {
const all = await accounts.listAll(2000);
const all = await accounts.listAll(1e6); // was 2000: newest-first, so once the site passed 2000 accounts (BTC4Hits import 2026-11-11) older tank members fell off the list
return all.filter(a => inTank(a) && !remoteOpen(a.email)).map(a => ({ email: a.email, name: nameOf(a), username: a.username || null, joined: a.created, lastSeen: a.lastSeen || 0, wallet: !!a.address,
// wallet linked = ready to switch on payouts, the plain activation held for an adopter (24-hour clock, autoAssign after that)
opensAt: inGrace(a) ? graceEnd(a) : 0, // new sign-up: nobody can adopt them by hand before this (0 = open now)
@@ -104,8 +109,8 @@ async function eligibility(email) {
if (!a) return { ok: false, reason: 'Sign in first.' };
if (!a.memberId) return { ok: false, reason: 'Switch on payouts and buy your first $25 package to adopt from the tank.' };
if (!hasOwnBuy(a.memberId)) return { ok: false, reason: 'Buy your own $25 or larger package first. Adopting is for members who have made that move themselves.' };
const open = await impl().open(a.email);
if (open.length >= CAP_OPEN) return { ok: false, reason: 'You have ' + CAP_OPEN + ' open adoptions. Help one of them link a wallet or buy, and a slot frees up.', full: true };
const open = await impl().open(a.email); const held = await holding(open); const cap = capOpen();
if (held.length >= cap) return { ok: false, reason: 'You are already helping ' + held.length + ' people from the holding tank, and ' + cap + ' at one time is the most anyone can hold. A slot opens when one of them switches on payouts, or when their 7-day window ends.', full: true, cap, held: held.length };
return { ok: true, account: a, open };
}
@@ -117,7 +122,7 @@ async function view(email) {
const a = await accounts.byEmail(ad.adoptee);
mine.push({ id: ad.id, name: a ? nameOf(a) : mask(ad.adoptee), email: ad.adoptee, ts: ad.ts, expires: ad.expires, lastSeen: a ? (a.lastSeen || 0) : 0, wallet: !!(a && a.address), address: (a && a.address) || null, bought: !!(a && a.memberId) });
}
return { eligible: el.ok, reason: el.ok ? '' : el.reason, cap: CAP_OPEN, ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, graceHours: GRACE_MS / 3600000, waiting: await waiting(), mine };
return { eligible: el.ok, reason: el.ok ? '' : el.reason, cap: capOpen(), ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, graceHours: GRACE_MS / 3600000, waiting: await waiting(), mine };
}
async function adopt(adopterEmail, who, note, opts) {
@@ -138,7 +143,10 @@ async function adopt(adopterEmail, who, note, opts) {
const r = await setSponsor(target.email, token, 'adopt');
if (r.error) return r;
const now = Date.now();
const text = String(note || '').trim().slice(0, 600) || ('Hi, I am ' + nameOf(me) + '. You joined LinkSpin without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.');
const tgt0 = await accounts.byEmail(target.email); const b4h = !!(tgt0 && (tgt0.joinedRef === 'btc4hits' || tgt0.joinedVia === 'btc4hits')); // a BTC4Hits import (2026-11-11): they never joined LinkSpin themselves
const text = String(note || '').trim().slice(0, 600) || (b4h
? 'Hi, I am ' + nameOf(me) + '. Your BTC4Hits account moved to LinkSpin without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.'
: 'Hi, I am ' + nameOf(me) + '. You joined LinkSpin without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.');
const ad = await impl().add({ adoptee: target.email, adopter: e, ts: now, expires: now + TTL_MS, status: 'open', note: (opts && opts.recordNote) || text });
{ const rr = RS.load().ready[target.email]; if (rr && !rr.done) { rr.done = clock(); rr.adoptedBy = e; RS.save(); } } // the hold lifts: their sponsor resolves now
// wallet already linked: the engine switches their payouts on under the adopter right away (Marty approved 2026-10-27)
@@ -153,7 +161,9 @@ async function adopt(adopterEmail, who, note, opts) {
if (mailer && mailer.hasKey()) {
try {
await mailer.send(target.email, nameOf(me) + ' is now your sponsor on LinkSpin',
'You joined LinkSpin without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + payLine + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nLinkSpin');
b4h
? 'BTC4Hits has moved to LinkSpin, and your BTC4Hits account came with you. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + payLine + '\n\nSign in with the email you used on BTC4Hits (we send you a code, no password) and reply in your member area: ' + siteUrl + '/from/btc4hits\n\nLinkSpin'
: 'You joined LinkSpin without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + payLine + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nLinkSpin');
} catch (err) {}
if (auto) {
try {
@@ -481,10 +491,10 @@ async function autoAssignRun() {
let done = null;
for (const c of pool) {
if (c.a.email === e) continue;
if ((await impl().open(c.a.email)).length >= CAP_OPEN) continue;
if ((await holding(await impl().open(c.a.email))).length >= capOpen()) continue;
if (hooks.payoutBlocked && await Promise.resolve(hooks.payoutBlocked(Number(c.a.memberId))).catch(() => true)) continue; // no-payout chain: they would fall to the company after all
if (await inDownlineOf(e, c.a)) continue;
const msg = 'Hi, I am ' + nameOf(c.a) + '. You joined LinkSpin without a sponsor and nobody picked you up from the holding tank within 24 hours, so you were matched with me. I will walk you through the first steps whenever you are ready. Reply here.';
const msg = 'Hi, I am ' + nameOf(c.a) + '. ' + ((a.joinedVia === 'btc4hits' || a.joinedRef === 'btc4hits') ? 'Your BTC4Hits account moved to LinkSpin' : 'You joined LinkSpin') + ' without a sponsor and nobody picked you up from the holding tank within 24 hours, so you were matched with me. I will walk you through the first steps whenever you are ready. Reply here.';
const r = await adopt(c.a.email, a.username || e, msg, { auto: true, recordNote: 'auto-assigned after 24 hours in the tank' });
if (r && r.ok) { done = { adoptee: e, adopter: c.a.email, adopterName: r.adopterName, adopteeName: r.adopteeName }; break; }
}
@@ -498,7 +508,7 @@ async function autoAssignRun() {
out.held++;
if (!rec.noAdopterAlerted) {
rec.noAdopterAlerted = clock(); RS.save();
if (hooks.adminAlert && await claimOnce('tankalert:' + e + ':' + rec.readyAt)) { try { await hooks.adminAlert('LinkSpin holding tank: ' + nameOf(a) + ' (' + e + ') linked a wallet ' + Math.round((now - rec.readyAt) / 3600000) + ' hours ago and nobody is eligible to take them (own $25+ package, fewer than ' + CAP_OPEN + ' open adoptions, signed in within 7 days, not on a no-payout chain). Their payouts stay switched off (a purchase still goes ahead), never under the company. Adopt them from More > My line > Holding tank, or set their sponsor in Admin.'); } catch (err) {} }
if (hooks.adminAlert && await claimOnce('tankalert:' + e + ':' + rec.readyAt)) { try { await hooks.adminAlert('LinkSpin holding tank: ' + nameOf(a) + ' (' + e + ') linked a wallet ' + Math.round((now - rec.readyAt) / 3600000) + ' hours ago and nobody is eligible to take them (own $25+ package, fewer than ' + capOpen() + ' tank members held, signed in within 7 days, not on a no-payout chain). Their payouts stay switched off (a purchase still goes ahead), never under the company. Adopt them from More > My line > Holding tank, or set their sponsor in Admin.'); } catch (err) {} }
}
}
}
@@ -658,7 +668,7 @@ async function adminView() {
const recent = await impl().recent(200);
const names = {};
for (const ad of recent) for (const em of [ad.adoptee, ad.adopter]) if (!(em in names)) { const a = await accounts.byEmail(em); names[em] = a ? nameOf(a) : em; }
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: CAP_OPEN, ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30) };
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: capOpen(), ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30) };
}
module.exports = { init, view, adopt, holdFor, gate, markReady, readyRec, readyTick, autoAssign, alignToNetwork, alignedRecent, setClock, eligibility, inTank, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, adoptable, adoptableOf, openedSince, leftText, inviteAsk, dismissInvite, nameSponsor, GRACE_MS, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, CAP_OPEN, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };
module.exports = { init, view, adopt, holdFor, gate, markReady, readyRec, readyTick, autoAssign, alignToNetwork, alignedRecent, setClock, eligibility, inTank, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, adoptable, adoptableOf, openedSince, leftText, inviteAsk, dismissInvite, nameSponsor, GRACE_MS, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, capOpen, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };