Compare commits

...

135 Commits

Author SHA1 Message Date
martbost 0785d4b41a Bridge pages: inside the ad viewer the button opens a new tab, so an offer that refuses framing no longer shows 'refused to connect' (reported for prenet.world, 2026-11-23); pt.js?v=3
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 08:03:12 -06:00
martbost 35aa2f6514 Video Spins screen: Watch how this works lesson link
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:52:20 -06:00
martbost 255e399272 Training: Video Spins lesson (video + card), chatbot mentions it
Narrated walkthrough in Marty's voice from the network-videos pipeline (site linkspin-videospin), hosted in Spaces training/video-spins.mp4.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 14:20:53 -06:00
martbost 994a2054d8 Video Spin zone (/vz/<code>): a rotating player for any web page; house Video Spin admin route
/vz/<code> sends a frame to Social Tube's small player for one of the spin's videos on each page view; no click is recorded for a view
(rotator.peek), plays and taps are counted by Video App Income under the spin's code. Embed code on the Video Spin screen.
vsCreate / vsAdd shared by the member routes and POST /api/admin/house-videospin (admin key, house account, admin action log).
Chatbot lines updated (Marty 2026-11-22).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 12:56:38 -06:00
martbost bca3666ee2 Video Spin: one short link that rotates through video pages on Social Tube; Social Tube as a network link + traffic source
Links > Video Spins (third view). A Video Spin is a spin link (rotator kind 'video'): its videos are picked from the member's own Video App
Income videos or added by any member's Social Tube address, each checked with Video App Income over signed calls (NETCONV_SECRET_VAI,
prefix vspin.v1.). Pasted addresses are refused on a Video Spin. Per video: clicks here plus opened / played / tapped from Video App Income.
Limits mirror Banner Spin (Starter 2x5, Builder 5x15, Leader 10x25), counted apart from spin links. Network link nwst + source socialtube;
socialtube.club gets the click id. Chatbot answer video-spin, KNOWLEDGE_DATE 2026-11-22 (Marty 2026-11-22).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 12:29:54 -06:00
martbost a6c36aeca1 Video App Income as a network site: fixed link nwvai + its traffic source (catalog, ?src=videoappincome), videoappincome.com and clickvidpro.com get the click id, and its own signed conversion route /api/partner/netconv/vai (NETCONV_SECRET_VAI, events keyed vai: only; reporting only). netconv rows carry the reporting site, so a purchase reads Video App Income in Reports (Marty 2026-11-21: loop Video App Income through LinkSpin tracking)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 07:17:06 -06:00
martbost 61c0ccc48a Pipeline board fits on one screen: long columns scroll inside themselves (headings pinned) and the board's sideways scrollbar is wide and visible (member request in LinkSpin Support 2026-11-20: "need a bottom slide rule"); site.css v=ls20261120pp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:28:10 -06:00
martbost 2217fd2c80 Admin credit grant: purchased:true grants at purchase grade, like InstantAdPay's (Marty 2026-11-20)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 05:37:48 -06:00
martbost 7edc1a25b0 Holding-tank readiness on the tank cards (Marty 2026-11-18, warm-up stage 1, no email)
Each waiting lead on the Holding tank card (/tools) and Admin > Members tank card shows how they got into the tank, a stage chip (New / Warming / Engaged / Activated / Ready, real actions only), the network heat 0-100 with its band, and their last real action, from the network hub (POST /v1/tank/readiness). tankready.js is the same module as InstantAdPay's (entry facts from this site's adoption records, follow records and join data; usernames only). Hottest first inside the usual grace / ready-to-activate groups, a "Warm or hot only" toggle. Hub down = the card as before. No mail, no Telegram, no sponsor moves; adoption rules and caps untouched. qa/tank-readiness.test.mjs in member + tankhold; tankready.js / my.js / admin.js ?v=20261118rd, site.css ?v=ls20261118rd. qa member ALL PASSED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 19:08:51 -06:00
martbost 4d22ae72c8 How LinkSpin works: whole-site walkthrough video (Marty 2026-11-18)
A 3:15 narrated tour in Marty's voice (one link that rotates your pages, email-code sign-in,
weights, fallback, health checks, hours, the Share kit, traffic sources, Reports, Pages, Zones,
what ad packages do), pointing on to the Monthly Refuel and Conversion tracking lessons.
Hosted on Spaces training/linkspin-tour.{mp4,jpg}?v=20261118a.

- catalog/training.json: lesson linkspin-tour, group "Start here", first:true
- server.js /api/training: built-in lessons with first:true lead the list (ahead of the volume list)
- home: light "Watch how LinkSpin works" link under the hero ticks (main CTA stays above the fold
  on phones) + a #watch section with the player after "What you get, free"; pub.css ?v=20261118w
- chatbot: WALKTHROUGH VIDEO fact, KNOWLEDGE_DATE 2026-11-18

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:35:17 -06:00
martbost e62545994f Promo tools: 600x300 wide cards for both LinkSpin angles
Member request (600x300 and 250x250; the 250x250 square already existed).
ls-wide-a / ls-wide-b in a new 600x300 group in the Banners pill, rendered by
tools/promo-kit-wide.cjs from the kit's own art and fonts. my.js?v bumped,
chatbot promo-tools fact updated. QA member run: 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:28:28 -06:00
martbost b5df8a2820 YourProgramBuilder go-live (Marty GO 2026-11-17): partner ypb (saved IDs become tracked links, the dh wiring, sub-id ypb<packet>), catalog template yourprogrambuilder + NET_SRC ypb, network link nwypb, netsites CODES nwypb
qa/netsrc.test.mjs counts the eleven network links (it still said nine after nwvas): 19/19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:30:41 -06:00
martbost bd5ed4e370 Owner account (ADMIN_EMAIL) has no link or source cap (Marty 2026-11-17: 'since I am the owner, I don't want a limit on my account'); members keep 100 links / 30 sources
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:17:52 -06:00
martbost ae39e05fc5 AI ad writer on LinkSpin (Marty 2026-11-17: "do it on the other sites too"): "Write my ad from my link" on the Ads screen text ads (60/140) and "Write my headline from my link" in the page builder (headline 90 + subhead 200), both asking the network hub (hubadwriter.js, POST /v1/adwriter) through GET/POST /api/my/adwriter; shown only when the hub says on; chatbot fact, KNOWLEDGE_DATE 2026-11-17; ads-screen.js/pages-screen.js ?v=20261117aiw. Plus the PolHunter embed on the home page (3 tiles) with polhunter.com in script-src and connect-src (punch list L2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:43:47 -06:00
martbost 5613d10224 Network Weekend (Marty 2026-11-17): ribbon, WEEKEND500 start gate, date-gated chatbot fact
- netdeals.js + /api/network-deals (hub /v1/network-deals) and /assets/netweekend.js loaded from common.js and netline.js:
  the ribbon shows only Fri 11-27 00:00 CT to Tue 12-01 00:00 CT by the page's own clock (common/netline ?v=20261117nw)
- promos: optional starts (MySQL promo_codes.starts) so a code can be created dormant and open by itself; setClock for tests
- weekendfact.js: chatbot FACTS for the event (live deal lines from the hub) Fri to Mon, the WEEKEND500 line to Tue 12-08 00:00 CT
- qa/networkweekend.test.cjs: 8 pass (test clocks only)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 07:22:52 -06:00
martbost e0ece93e9d Network sign-in: the way back to every network site (Marty 2026-11-17)
networksso.js now also answers every site in the hub's GET /v1/sso-sites (the hand-written list
missed sites, the ViralAdSource bug), ?return=<site>&to=/path links remember the way back and
/sso/resume finishes it after the sign-in, and the deliberate-tap state lives 1 hour. Every
/go/<site> and ?return= request goes to networksso (no per-site line in server.js any more).
qa/networksso-return.e2e.mjs: a hub-only site, silent check, tap, wallet step, return links,
no open redirect. All network sign-in suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 07:10:17 -06:00
martbost 03d87fbb79 Network link nwvas: ViralAdSource as its own spin link + traffic source (netlinks.js, netsites CODES), the nwvab pattern (Marty 2026-11-17 go-live)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 05:59:57 -06:00
martbost 77e18fd230 Partner links for ViralAdSource: PARTNER_LINKS vas (the vab wiring)
/api/partner/vas/links serves ViralAdSource the same way as vab: ensure / stats / spins, tagged vas:<ad id>, on the member's own
"ViralAdSource" network source (new catalog template viraladsource, NET_SRC vas + viraladsource). qa/partner-vaslinks.test.mjs
(16 checks, incl. account by network username and vab/vas/dh kept apart); vab, dh, spins, netsrc, netconv, housespins green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 05:27:27 -06:00
martbost 6c5851b4d5 Remove street mailing address from public pages (Marty 2026-11-16)
Pages, footers and the site assistant now name only TrustClickz; the footer
reads "(c) 2026 TrustClickz". Contact stays the network support link.
QA checks updated to assert no street address is shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:46:38 -06:00
martbost 1db7699e25 Hub activity from every signed-in LinkSpin use (Marty 2026-11-16: "LinkSpin never reports activity", DownlineHydra Wake it)
The page-load ping (networksso.page) only fires on a full top-level navigation with Sec-Fetch-Dest: document and a
member session that carries an email. It never fired for a Control Room tab kept open (client-side moves and the
/api/my/ping heartbeat), browsers that send no Sec-Fetch headers, wallet-only sessions, or the owner working in the
admin portal. Live finding: Marty has had no LinkSpin member session since 2026-11-15 20:20 UTC, before the ping
shipped (b2669cf, 21:36 UTC); 16 other members already had linkspin rows.
- networksso.seen(s): the same once-a-day ping for any signed-in request; called from /api/me (email or wallet),
  the dashboard heartbeat /api/my/ping and the admin portal page (/admin, the owner's email; hub activity only,
  the admin session is never shared).
- qa/networksso-activity.test.mjs (13 checks, real hub, in run.sh sso + member): a signed-in page load records
  site linkspin, once a day, never API/assets/bots/fetches/signed-out, seen() for an open tab and a wallet session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 07:28:12 -06:00
martbost aa7595a9cd Smarter chatbot + support matching by meaning (Marty 2026-11-16): the hub's semantic match (free core2 embeddings)
Chatbot (chatbot.js + netkb.js route): a hand-off pattern still answers first; then the hub's POST /v1/kb/match answers with
this site's entry when it is sure, keeps or overrules the CANNED regex hit, and picks the AI prompt context, this site's own
entries first. 1.5 s timeout, then the hub is skipped for 30 s and the old pattern + BM25 path answers (NETKB_MATCH=0 = off).
Support desk: while a signed-in member types a new ticket, POST /api/my/support/suggest shows the closest help answers (KB
entries only, incl. ones written from past tickets, never another member's ticket; BM25 when the hub is down); Send is never
blocked. help-screen.js?v=20261116sg.
Tests: qa/netkb-semantic.test.mjs (route/suggest decisions, fail soft, shared-file parity; run.sh kb) and
qa/support-suggest.mjs (run.sh member). netkb.js is the same file in all eight network sites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 05:53:38 -06:00
martbost 2ede19a13d networksso hub e2e: the wallet partner takes the hub hook (Marty 2026-11-16)
The stand-in wallet partner now runs the real wallet-site hubevents.js (from ../../5xyourteam/app, skipped when absent) behind
POST /api/hub/events, and the hub hooks it (HUB_HOOK_EVERY_MS 1 s). New cases: the partner session open in the browser ends after
Sign out everywhere on LinkSpin (member.signedout, matched by the member wallet), and a partner session opened before a hub
block ends after it (member.blocked). Same file in InstantAdPay and LinkSpin: ALL PASSED from both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 05:24:33 -06:00
martbost daf24a8f81 Admin route: house Banner Spins on the admin's own account, logged (Marty 2026-11-16)
POST /api/admin/house-spins creates or updates Banner Spins on a house account (ADMIN_EMAIL or NETWORK_LINKS_OWNER) for house ads
such as the Network Ad Space rows, through the same bannerspin.js calls the member Links screen uses (create, update, addBanner,
updateBanner). Admin auth only (portal session or the admin key); no member session is read or minted. Every call, denied ones
too, goes to the new admin action log (adminaudit.js: MySQL table admin_audit, JSONL without a database) with who, what and when;
GET /api/admin/house-spins/log reads it. qa/housespins.test.mjs (in run.sh netsrc) covers auth, house-account only, member
checks, idempotent repeat, prune, serving + click attribution, the log and no session minted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 05:08:25 -06:00
martbost 1b0e324176 networksso e2e: tamper a middle character of the signature (the last base64url character carries only 4 bits, so A<->B could decode to the same bytes: a 6% flake seen in qa member 2026-11-15)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:46:04 -06:00
martbost b2669cfed7 Network hub sign-in, step 3 (Marty 2026-11-15)
networksso.js (the same file on every network site): with HUB_SSO=on /sso/start asks the network hub, /sso/in takes the hub's h1. token (this site's HUB_SECRET, iss hub, aud linkspin, 60 s, single use, state cookie) and falls back once to the pairwise InstantAdPay check when the hub has nobody. networksso.page() on every GET of the main host: a signed-in member's page load tells the hub once (nsso.hp) and pings /v1/activity once a day, only while the hub answers /health.
Sessions: SESSION_TTL_HOURS (168 = 7 days in production), renewed on use at most hourly; cookie 30 days, the server's sliding expiry decides. auth.endSessions.
Sign out everywhere: POST /api/auth/logout-everywhere; the account menu's Sign out asks "Only LinkSpin or every network site"; cr-shell.js?v=20261115hub. hubsync: member.blocked and member.signedout end every session of that member here.
Chatbot: a sign-in lasts 7 days and renews; the silent check is every 2 minutes.
Tests: qa/networksso-hub.e2e.mjs (same file as InstantAdPay, in run.sh). qa sso: ALL PASSED; qa member: ALL PASSED (known warnings).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:36:06 -06:00
martbost 73bee6c826 Login ad on a clock, hop back to the asking site, 5xYourTeam in the wallets map, signed-out login slot refused (Marty 2026-11-15)
Login ad: every Control Room page asks (cr-shell.js loginAd, the per-tab sessionStorage guard is gone); the server answers with an ad only when the member's last finished view on LinkSpin is older than loginAdEveryHours (site setting, default 3). loginadclock.js (the same file as InstantAdPay), MySQL table login_ad_views through DOCSTORE_URL. POST /api/ads/login/seen at the end of the countdown restarts the clock only if the serve was dwell-2 s earlier. Member erase forgets the row. Admin site setting label.
Signed out: /api/ads/slot?type=login draws nothing and counts no view (bots, probes, previews cannot run up an advertiser's numbers).
Hop: a member who signed in here because another network site asked ("Sign in with LinkSpin", nsso.back) goes back there after the login ad (/sso/resume), from every Control Room screen, not only the retired /my.
networksso.js: the network-wide copy (loop guard 120 s, fivex, unknown r refused); fivex added to the wallets map (FIVEX_URL, default https://5xyourteam.com).
Tests: qa/networksso-partner.e2e.mjs (same file as InstantAdPay, in run.sh): partner via LinkSpin, LinkSpin clock, signed-out slot; networksso e2e retries a keep-alive ECONNRESET. qa sso: ALL PASSED; qa member: ALL PASSED (2 known warnings; networksso e2e flaked on ECONNRESET once, passes with the retry).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:03:14 -06:00
martbost 60dc4d537d ViralAdBlitz "Use one of my spin links" (Marty 2026-11-15): /api/partner/vab/links op 'spins' (same net.v1 signature) lists the account's own spin links { code, name, url (public /r/ link on the clean link host), destinations (active), paused }, never partner-made links (tracked text ads, program links), nothing else about the account; hosts = every host a /r/ link answers on (also sent with account false) so ViralAdBlitz can tell a LinkSpin spin link from any other link. Read only. qa/partner-vabspins.test.mjs (12 pass) in qa netsrc; netsrc, sso, member green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:37:02 -06:00
martbost fbf7d87030 Shared network knowledge (Marty 2026-11-15): the chatbot publishes its KB to the network hub and reads the other network sites' entries (netkb.js, the same file in every network site), home entries boosted, a named site's entries first and labelled with its LinkSpin tracked link, a question naming another site skips the instant answers (a hand-off still wins). Wallet answers follow Marty's rule (SafePal or any other crypto wallet, never recommend MetaMask), since they are now shared network-wide. KNOWLEDGE_DATE 2026-11-15. qa kb: netkb-merge 67 pass, kb-chat pass, kb-retrieval 2 misses that also fail on a clean tree
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 13:31:37 -06:00
martbost f4789156b8 Member erase (Marty 2026-11-15, ticket LS-1021): POST /api/admin/erase {email, dryRun (default true), force} + the hub's member.erased event
erase.js runs inside the app so the documents modules keep in memory and the MySQL docs rows stay consistent. Refused
unless force: a main wallet, an on-chain member number, positions, a team here, ads running or queued. Removes the
account, their spin links with every click row in rot_hits and conversions (rotator.eraseOwner, docstore.rowsWhere),
and scrubs every document that mentions them with scrub.js (same file as InstantAdPay) through the owning module's live
copy: accounts, audiences, coach, convtrack, earned (unspent credits go away), hubsync, iapsync, mail-intro, postbacks,
registry, rotator, sponsorfollow; others (updates-log, ...) through docstore. A 30-day email-hash tombstone (erase.json)
stops the InstantAdPay registry sync and hub events from bringing them back; the log keeps hashes and counts only.
hubsync handles member.erased {emailHash}. qa/erase.test.cjs 6 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 12:29:33 -06:00
martbost e2af298317 DownlineHydra as a network site (2026-11-15 go-live): fixed network link nwdh -> https://downlinehydra.com/{s2}?ref={s1} on the admin account (catalog network template downlinehydra + NET_SRC dh/downlinehydra already there), netsites CODES downlinehydra: nwdh; qa netsrc expects nine network links + nwdh redirect. LOCAL, not run here (qa on hold for the VAB lane's suite)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 08:57:58 -06:00
martbost ab6124ea9b 5xYourTeam as a network site (2026-11-15): fixed network link nw5x -> https://5xyourteam.com/{s2}?ref={s1} on the admin account, catalog network template 5xyourteam + NET_SRC fivex/5xyourteam, netsites CODES fivex: nw5x; qa netsrc expects eight network links + nw5x redirect
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 08:52:30 -06:00
martbost b2b670df14 Network sign-in for DownlineHydra (2026-11-15, same change as InstantAdPay 1c06c58): networksso NAMES downlinehydra (same file as IAP), wallets.downlinehydra = DH_URL (default https://downlinehydra.com; staging https://dh.saasy.top until the domain switch), /go/downlinehydra and /go/viraladblitz hops
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 08:39:12 -06:00
martbost 90596b4d0f qa/networksso.e2e: same file as InstantAdPay again (the 'expired IAP session' check expects the 2026-11-14 deliberate-tap behaviour: IAP asks for its own sign-in first and remembers the trip in nsso.back)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 08:23:23 -06:00
martbost 86007f0784 Footer network links carry a referral username (Marty 2026-11-15): the signed-in member's own (/api/me), else the referral the visitor came in on (?ref= on the page, remembered for the visit, then the iap.sponsor join cookie; usernames only, never a member number or wallet). Tracked links get it as s1 (LinkSpin sends it on as ?ref=), plain links as ?ref=, none for Earners Corner. Same approach as VBB 6798503. common.js + netline.js ?v=20261115nr. NOT deployed (another lane owns the LinkSpin deploy).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 07:59:33 -06:00
martbost 6607e39e30 Partner tracked links generalized (2026-11-15): POST /api/partner/<site>/links for site dh (DownlineHydra programs) or vab (ViralAdBlitz text ads, the ad id as s1/placement). PARTNER_LINKS maps each site to its network template + link name; keys dh:<id> / vab:<id> keep the two apart; items take program or id. Catalog viraladblitz template gains clickid/placement/s1 params. qa/partner-vablinks.test.mjs 13/13 (signature, unknown site refused, source, edit keeps the code, dh vs vab apart, stats per site); run.sh netsrc runs netsrc 17/17 + partner-dhlinks 13/13 + partner-vablinks 13/13. LOCAL ONLY.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:20:23 -06:00
martbost e23d9ecbdb ViralAdBlitz as a network site (2026-11-15): network sign-in by wallet to ViralAdBlitz (networksso wallets.viraladblitz = VAB_URL, default https://viraladblitz.com; NAMES viraladblitz), fixed network link nwvab -> https://viraladblitz.com/{s2}?ref={s1} on the admin account, catalog network template viraladblitz + NET_SRC vab/viraladblitz (merged by hand beside d6e8de3's dh entry), netsites CODES viraladblitz: nwvab. qa: netsrc 17/17 (seven network links), partner-dhlinks 13/13. LOCAL ONLY.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:06:31 -06:00
martbost d6e8de3e6a Partner endpoint for DownlineHydra tracked program links (Marty 2026-11-15): POST /api/partner/dh/links, net.v1-signed with NETWORK_SSO_SECRET. op ensure makes or updates one link per program on the member's own account (by email, else network username), tagged with a new 'DownlineHydra' network source and the program id as sub-id (?s1=&placement=), clean link host from domains.hosts(); op stats answers clicks per program. rotator.ensurePartner / partnerStats; catalog template downlinehydra; NET_SRC dh. qa/partner-dhlinks.test.mjs 13/13, partner-spins 13/13, netsrc 16/16. LOCAL ONLY, not pushed or deployed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:26:46 -06:00
martbost 82e25de691 docstore: skip rewriting a document whose body equals what MySQL already holds (whole-document rewrites on every save filled core with 115 GB of binlogs, 2026-11-15); qa/docstore-skip.test.cjs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:14:35 -06:00
martbost 836332b5ed Network sign-in: a deliberate 'Sign in with InstantAdPay/LinkSpin' tap while signed out on the provider now asks for the provider's sign-in, then finishes the trip (/sso/resume), instead of bouncing back silently (Marty 2026-11-14: VBB sign-in did nothing)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 14:31:51 -06:00
martbost fb083b7085 GET /api/admin/member-extra?email= (Marty 2026-11-14, network hub member lookup): read-only, admin Bearer; what the member card leaves out: optedOut (drip unsubscribe), tank {inTank, ready {readyAt, holdUntil}, adoptions summary}. qa/member-extra.mjs in the member run (401 without/with a wrong password, 404 unknown, fields present). qa member: 57 passed 0 failed, member-extra 7/7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:03:34 -06:00
martbost e545343fe0 Michael Camire fixes + hub shells in the tank (Marty 2026-11-14, LinkSpin Support)
1. Top-up across positions: an ad burns from ONE position, and topUpCampaign only looked at the ad's
   own position (or the main one when the list row had no memberId), so credits bought on a linked
   position could never top up the ad. Ported from InstantAdPay 2026-09-27 (Jim Watts): the ad's real
   member id is read from the campaign row; when it cannot cover, the refusal names where the free
   credits are and offers switchOptions; with the member's yes (switchTo, only a position on the
   account) moveFunding settles what the ad already ran up on the OLD position, moves the ad, then
   tops up. Ads screen asks in-page (own dialog) and retries. Create already had the largest-position guard.
2. Toasts: errors stay until closed (close button, role=alert), other notes 3.5 to 9 s by length.
3. Banner Spin per-banner clicks: his 3 clicks were all unmatched (no view on record for that browser),
   so they landed on the fallback row and every banner said 0. Click matching now also tries the same
   connection (daily-salted IP-only hash) when the browser key finds nothing (mail/exchange app view,
   click opened in the phone browser), view notes last 60 min instead of 15, and the stats split
   'Fallback shown' from 'Clicks not tied to a banner' so the rows add up to the total. History is not
   backfilled: views were never stored per visitor, so old clicks cannot be tied reliably.
4. Holding tank: hub-made waiting accounts with no sponsor are in the tank (waiting, rescue, readyTick
   read listAll with { shells: true }; 'hub-shell' no longer holds anyone back). Locked / sponsored /
   unknown, grace, 2-adoption cap unchanged; readyTick still never switches a shell on;
   accounts.listAll default unchanged (mailings skip shells).

Assets: cr.css, cr-shell.js, ads-screen.js ?v=20261114tu, banner-spin.js ?v=20261114bc.
QA: walk member 0 bugs (36 ok), netconv 57/57, networksso ALL PASSED, tank-hold all passed (new hub
shell part), profile policy 16/16, new topup-positions 8/8, new bannerspin-attrib 7/7, bannerspin e2e
75/75, hubsync 15 checks, tank-cap 15/15, sponsorfollow 30/30.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 11:59:38 -06:00
martbost a630979a3a Network sites as LinkSpin traffic sources (Marty 2026-11-14: "Make sure each of these sites is its own traffic source and link spun so we can track it"). Catalog: InstantAdPay, LinkSpin, Stack POL, Earners Corner network templates (next to Downline Banners and Viral Banner Blitz). A spin-link click with ?src=<site id> (iap, linkspin, dlb, vbb, stackpol, earnerscorner) counts under the link owner's source for that site, made from the template on first use (network templates only, no postback, so no network hears of a click it did not send; no referrer = the site's name as referrer). netlinks.js: at boot the admin account gets one fixed network link per site, made once when missing: nwiap, nwls, nwdlb, nwvbb, nwsp, nwec -> https://<site>/{s2}?ref={s1} (Earners Corner without ref), so every site links to the others as linkspin.app/r/<code>?src=<sender>&s1=<member>&s2=<page>. Health checks probe a destination with its {macros} empty, as a click with no params lands. netsites.js: /api/network-sites adds go (the tracked link with ?src=linkspin); common.js + netline.js footers use it (rel nofollow). common.js?v=20261114ns, netline.js?v=20261114ns. qa: netsrc 16/16 (new, bash qa/run.sh netsrc), member 57 passed 0 failed, partner-spins 13/13, netconv 57/57, lsid 31/31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 11:39:34 -06:00
martbost 9025057128 Admin zone creation for a member (Marty 2026-11-14, approved named admin actions instead of signing in as a member): POST /api/admin/zones {owner, name, size, site, reason}, existing accounts only, same zones.create rules, logged. qa member 57/57
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 11:09:27 -06:00
martbost 018ff9c2f2 Network line on the public pages that do not load common.js (home, contract, legal, guides, ledger, join, earning, partners, support): netline.js adds the company line and the 'Part of the network' list from /api/network-sites (LinkSpin marked as current, built-in fallback); footer link reads Earnings Disclaimer. netline.js?v=20261114nf. qa member: 57 passed, 0 failed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 10:33:21 -06:00
martbost f1f757f895 Footer: 'Part of the network' line from the network hub (Marty 2026-11-14 trust pack), smallest change before the 11-15 launch. netsites.js serves GET /api/network-sites (hub GET /v1/network-sites, 10 min cache, never waits on a slow hub, built-in fallback); common.js paints the line (LinkSpin marked as current) in the site footer and the members-area footer; company line TrustClickz, 615 Green Valley Drive, Moody, AL 35004; Earnings Disclaimer label; members-area footer links Support, Terms, Earnings Disclaimer, Privacy. common.js?v=20261114nf. qa member: 57 passed, 0 failed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 10:22:33 -06:00
martbost 5d630ec479 Banner Spins for Viral Banner Blitz (Marty 2026-11-14: "make sure Viral Banner Blitz incorporates banner spins that could be pulled in just like downline banners"). /api/partner/bl/spins takes { site: 'vbb' }: 125x125 + 250x250 spins, a "Viral Banner Blitz" source (new catalog template viralbannerblitz), and { username } (the member's network username) when no account holds the wallet; vbb only. Answers now carry host and each spin's size. Downline Banners' calls are unchanged (468x60, wallet only). Same NETWORK_SSO_SECRET signature. qa/partner-spins.test.mjs 13/13 (local copy, JSON store); networksso ALL PASSED; hubsync 15 checks ok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 10:07:27 -06:00
martbost fb84d1545d Quiet hub accounts (Marty 2026-11-14, join one = join all): accounts the hub makes here get joinedRef 'hub', and accounts.listAll leaves out hub-made accounts that never signed in unless { shells: true }, so no mailing or sweep (updates 'all', launch week, coach, leaderboard) reaches them. hubsync/launchweek/sponsorfollow/tank-cap tests pass
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 09:10:11 -06:00
martbost 42cbe96979 Hub switch-on (Marty 2026-11-14). Rule 2: a hub arrival gets person.locks.linkspin's sponsor when the LinkSpin contract holds them, never the plain network sponsor; sponsor.changed stays ignored. Quiet: a wallet filled from a hub event never switches payouts on (isQuiet: no gas, no lock, no 'payouts are switched on' mail). Rule 3: the holding tank (waiting, release, expiry, rescue, readyTick, autoAssign) leaves out anyone the hub reports locked on any contract or sponsored, and hub waiting copies that never signed in here; /v1/locked detail cached 10 min, last answer kept 1 h, after that held (unknown). Alignment to the hub sponsor only with HUB_TANK_ALIGN=on. Needs network-hub b44dba6. hubsync 15 checks, sponsorfollow 30/30, tank-cap 15/15, networksso ALL PASSED, tank-hold, carry-hold ok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:45:43 -06:00
martbost 5fbaf4f17d Hub rule 2 (Marty 2026-11-14): every paid Purchase on the LinkSpin contract goes to the hub's /v1/contract-spend from its own retried queue (spends, sent after the binds, tx hash so a resend counts once, POL-in only; activation alone is not a spend), so when two contracts lock different sponsors the one with money spent decides the network sponsor. Still one way, only with HUB_ENABLED; needs network-hub 296aa5d. qa/hubsync.test.cjs 11 checks ok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:24:00 -06:00
martbost 9c4a6458f6 Network sign-in for Viral Banner Blitz (2026-11-14): vbb listed under networksso wallets (VBB_URL, default https://viralbannerblitz.com), so "Sign in with LinkSpin" works on VBB the way it does on Downline Banners; NAMES gains vbb (same networksso.js as IAP, DLB, VBB). networksso unit + e2e: ALL PASSED
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:16:26 -06:00
martbost ec09f2925e Holding-tank arrivals post shows the running total too (Marty 2026-11-14: post those totals so people know who is waiting to be adopted): '(N waiting in total)' after the new names
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:06:44 -06:00
martbost d6fd0c8e04 docstore.js: claim() for once-across-copies actions (same file as Downline Banners)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 10:35:12 -06:00
martbost 1554c262a6 LinkSpin data in MySQL (Marty 2026-11-13: 'everything database-driven'). docstore.js: every .json/.jsonl data document under DATA_DIR lives in MySQL table docs (DOCSTORE_URL), served to the modules through their own fs calls from an in-memory copy, written through in order; one writer at a time (docs_writer), so an older copy during a deploy can never overwrite newer data; first boot imports each file and sets it aside (.imported-<date>). Spin-link clicks are rows in rot_hits (one insert per click instead of rewriting a 20 MB document; every click kept). Kept as files on purpose: chain-index cache, uploads, geo db, kits, marks, queues. Admin sessions load after the store. Rehearsed on a copy: 52/54 documents byte-identical (rotator.json minus hits, kb.json seeds refreshed), 97,579 clicks moved, links + clicks work after restart.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:25:59 -06:00
martbost d1c9d62801 Data safety (2026-11-13 incident: a deploy read a half-written rotator.json, the store fell back to empty and its next save wiped 294 spin links): safefs.js makes every .json write inside DATA_DIR atomic (temp file + rename); LinkSpin's rotator refuses to start empty when rotator.json exists but will not parse
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:11:27 -06:00
martbost 656c9a940d Downline Banners partner call (Marty 2026-11-13): /api/partner/bl/spins, signed with NETWORK_SSO_SECRET, lists the 468x60 Banner Spins of the account holding a wallet; with spinId it makes sure a Downline Banners source exists, tags an untagged spin with it and answers the image + click URLs with the board's macros
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 08:55:41 -06:00
martbost 17c9764cc7 Downline Banners now lives at https://downlinebanners.com (Marty 2026-11-13): network sign-in hop default moved off new.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 08:36:00 -06:00
martbost 6301ee23ff Traffic source catalog: Downline Banners (network banner board, Marty 2026-11-13). clickid={clickid}, placement={spot}, s1={type}; the board fills them on every click
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 08:25:51 -06:00
martbost a7f9b80c18 Hub gaps (Marty 2026-11-13): deliberate sponsor changes -> /v1/sponsor-change, BTC4Hits accounts reported (no other door does), MemberActivated -> /v1/contract-bind (contract linkspin) from a retried queue; still one way, only with HUB_ENABLED
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 08:21:59 -06:00
martbost 33285ad590 Merge branch 'hub-listener' 2026-11-13 07:51:48 -06:00
martbost 138c98ccec Network sign-in: same networksso.js as InstantAdPay (wallet sites); LinkSpin vouches for Downline Banners by wallet (2026-11-13)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 07:35:18 -06:00
martbost f3fc8dfe18 Team page: your directs' email, where they came from (referrer + ?src= tag) and how they joined, on each level-1 row (Marty 2026-11-13, same as InstantAdPay's 11-12 change); levels 2-3 never show emails. team.js?v=20261113org
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:10:17 -06:00
martbost c79b0aedf6 Network links (Marty 2026-11-13 'yes please proceed'): every click on a link to the other site goes through /go/<peer> (InstantAdPay -> /go/linkspin, LinkSpin -> /go/iap), so a signed-in member arrives signed in; signed out it is a plain redirect. Click-time rewrite in the shared scripts (IAP common.js; LinkSpin common.js + cr-shell.js), so copied share links stay clean; data-nogo opts a link out. Browser check: path+query+hash kept, other hosts and data-nogo untouched. iap-qa member ALL PASSED. common.js/cr-shell.js ?v=20261113nl
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 05:28:15 -06:00
martbost 2c27dbc6e4 Network sign-in landing (Marty 2026-11-13, Android Chrome: signed in on LinkSpin via InstantAdPay but landed on the public home page, which always says Sign in): a hop with no page named lands on the member dashboard (LinkSpin /ads, InstantAdPay /my); LinkSpin's home page turns Sign in into 'Open my dashboard' for a signed-in visitor (home.js?v=20261113me). networksso.test + e2e ALL PASSED.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 05:16:37 -06:00
martbost 3c8fc1802d Network sign-in: a wallet-only session counts as signed in when its wallet belongs to an account (session carries the address, not the email), so a member who signed in with their wallet is signed in on the other site too (Marty 2026-11-13: signed in on IAP, LinkSpin's check came back 'not signed in here'). networksso.test + e2e ALL PASSED.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 05:09:56 -06:00
martbost a20e5a772e Merge network sign-in (InstantAdPay <-> LinkSpin) into main for the Friday launch (Marty 2026-11-13: 'we need to get that done now'). Conflicts only in script version tags (kept today's newer assets, re-tagged ?v=20261113sso). networksso.test 'ALL PASSED' both repos, networksso.e2e ALL PASSED, iap-qa member ALL PASSED. NETWORK_SSO_SECRET set on both Coolify apps. Chatbot KNOWLEDGE_DATE 2026-11-13.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 04:53:12 -06:00
martbost 31bf6b9f41 Network hub link behind HUB_ENABLED (default off): hub member.joined from another door becomes the same waiting shell account the InstantAdPay registry sync makes (ensure 'carried'/'network', fill empty fields only, sponsor line placed first, wallet last under carry.hold); wallet.connected fills an empty wallet; LinkSpin's own joins and wallet links go to /v1/join and /v1/wallet through a persisted retry outbox (DATA_DIR/hubsync.json). Signed X-Hub-Ts/X-Hub-Sig, 5-minute window, each event seq applied once. sponsor.changed and the rest are ignored (TODO). iapsync and /api/partner/registry unchanged. Test: HUB_DIR=<network-hub with /v1/resolve {id}> bash qa/run.sh hubsync, 10 checks against a local hub in JSON mode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:07:28 -06:00
martbost 7c79bc7cc0 Join page records the ?src= tag in the first-touch source (Marty 2026-11-12: 'we need the source tag so we can know where these things come from'): joinedRef = <referrer host>/<src> or just <src> when the referrer was stripped; a tagged visit replaces an untagged 'direct' first touch; a real earlier source is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 12:10:47 -06:00
martbost 7c4c9563fe Text ads get their own off-site rate (Marty 2026-11-12, same as InstantAdPay): Network Ad Space and partner-zone text views cost 1/synRateDivisorText (default 10, 1 credit = 100 network views) of the on-site rate; banners keep synRateDivisor 4. Going forward only. Admin Rates field, Ads screen + Campaigns table show 1/N per type, chatbot canned + prompt updated (KNOWLEDGE_DATE 2026-11-12). my.js/ads-screen.js/admin.js ?v=20261112txt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 09:33:08 -06:00
martbost e79d5ae63e Network sign-in with InstantAdPay (Marty approved 2026-11-12): signed in on one site = signed in on the other, no email code
networksso.js (same file in both repos): /go/iap hop for signed-in members' cross-site links; /sso/start (state cookie +
30-minute loop guard) -> InstantAdPay /sso/check -> /sso/in?t=<v1 HMAC-SHA256 token, NETWORK_SSO_SECRET, 60 s, single-use nonce,
bound to the browser's state cookie, email, audience and a same-site relative path>. App host only (not link/pages hosts).
Member sessions only (admin portal never shared), ordinary 4-hour session. An email not here yet (sync not run) or not on
LS_TESTERS gets the normal email-code sign-in, email prefilled; nothing is created. Silent check on every Control Room screen
(cr-shell.js loads public/assets/netsso.js); never for bots/fetches; sign-out pauses it 12 hours. Engine Room, Fuel and the
arrival strip's Back to InstantAdPay go through /go/iap. Chatbot knows it (KNOWLEDGE_DATE 2026-11-12). Off until
NETWORK_SSO_SECRET (32+ chars) is set. ?v= bumped (cr-shell, fuel, engine-room: 20261112sso).

qa: networksso.test.cjs all passed, networksso.e2e.mjs (both servers, real browser) 31/31, run.sh member green (0 bugs)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:05:51 -06:00
martbost 3cc687aff5 Holding tank admin grant: POST /api/admin/tank/grant {adopter, count} assigns N real BTC4Hits imports on top of the cap as auto adoptions, skipping the bot patterns (yandex, dotted gmail); adopt/eligibility take skipCap (Marty 2026-11-11: the adopters who picked up the Yandex batch keep them and get the same number more). tank-cap 15/15, tank-hold all passed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:58:10 -06:00
martbost 163bb9dfa0 Holding tank: BTC4Hits imports skip the 24-hour sign-up grace (they never signed up here, no inviter to wait for); adopters can pick them up at once (Marty 2026-11-11). tank-hold all passed, tank-cap 15/15
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:46:24 -06:00
martbost aff03d9c5c Admin spin-link route accepts up to 2 MB (BTC4Hits rotator #297 sends 834 URLs; every other route keeps the 64 KB limit)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:41:37 -06:00
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
martbost 3436df38e5 Control Room menu: Earners Corner (the network forum, signs in with InstantAdPay) before Help; external menu links open in a new tab; cr-shell ?v=20261110forum. QA member 57/57.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 08:45:18 -06:00
martbost 81f1a96df1 Banner Spin: the owner (ADMIN_EMAIL) skips the tier's Banner Spin count cap (Marty 2026-11-09, like the upload cap exemption); members unchanged
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:11:19 -06:00
martbost f38e8f798b Wallet payouts table: stack rows by the card's width (container query), From gets a 120px floor; From and Level overlapped on mid-size screens (Michael 2026-11-09)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:16:56 -06:00
martbost 27a975138a Owner (ADMIN_EMAIL) and the admin portal skip the 10-a-day upload cap (Marty 2026-11-08); members keep 10 a day
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 08:05:16 -06:00
martbost eedc15bc13 Conversion linkage, LinkSpin side (Marty 2026-11-07, "Yes ship these"): InstantAdPay's sign-ups, wallet links and package purchases on a click count for the click's owner, in one Conversions list. Reporting only: no sponsor, payout, credit or chain path changes.
The landing tag (t.js) adds the kept click id to links to linkspin.app, instantadpay.com and the share domains, also inside a member's own redirect link (Orlando's buttons are go.opgnetwerk.com/go?u=<encoded join link>). Spin and Banner Spin links are left alone and only LinkSpin's own id shapes travel. A spin link or Banner Spin pointed straight at those sites carries lsclk with no goal set up.

netconv.js: new partner op 'events' on /api/partner/conv. Append-only ledger DATA_DIR/netconv.jsonl so two app copies cannot overwrite each other, marks.claim plus the ledger keys for once-only, join and wallet once per root click, every purchase by its own key, 30 days from click to event, the first account on a click owns it, the click owner's own account and own clicks kept as tests, each row keeps what the click was so later events survive the hit ageing out of the rotator. Spin events mirror into rotator.conv (replayed on a timer) so per-link counts, sources and placements see them; postbacks fire as for LinkSpin's own conversions.

Reports > Conversions lists goals, joins, wallets, purchases, leads and partner postbacks with values, each once; per-link Conv. counts include goals. /join keeps lsclk as well as lsid. Guide, /conversions, privacy and chatbot (CANNED + FACTS) updated; reports.js and join.js tags bumped.

The false Pages webhook claim is gone from chatbot.js, join.js and the home page: leads go to the member's list and CSV, or into a pasted autoresponder form.

QA: bash qa/run.sh netconv (57 checks, also runs in member).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 07:46:43 -06:00
martbost 01ef4e9260 Holding tank: 24-hour sign-up grace plus a Who invited you box, the same rules as InstantAdPay (Marty 2026-11-07: "24-hour grace plus the prompt"). One network tank, so both sites behave the same.
Grace: for 24 hours from an account's created time nobody can adopt the person by hand: an Opens in badge, no Adopt button, a plain refusal from adopt(). Auto-assign keeps its clock from the wallet link, so the 24-hour hold is not stretched. The wallet-ready post waits for the grace and says the time really left, is skipped when the rotation takes them in that tick, the arrivals post moves to when the grace ends (marks.claim per member), and the Overview note and weekly email count only people who are open.

Prompt: LinkSpin members land on the Control Room, not the /tools Overview, so the box sits at the top of every Control Room screen, /tools included (cr-shell.js). Same checks as InstantAdPay, through setSponsor as a deliberate change with by 'invited', so it follows and clears the hold. With a wallet already linked the engine switches payouts on under the named sponsor right away, as an adoption does, and the confirm box says so first. Nobody invited me hides it everywhere and a small link on /tools brings it back. The named sponsor gets the referral email and an on-site notice (new hooks.notify).

Chatbot canned + systemPrompt, KNOWLEDGE_DATE 2026-11-07. cr-shell.js, common.js, credits-screen.js, my.js, admin.js, admin-sponsorcheck.js ?v=20261107tg. qa/tank-hold.test.mjs and qa/sponsorfollow.test.cjs extended; qa/run.sh member now runs tank-hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 07:06:44 -06:00
martbost b59b6eb017 Update emails can be intro-only (LinkSpin launch campaign 2026-11-05): send() and the admin card required at least one release note; campaign emails carry only an intro and closing. Now an intro OR a note is enough. admin.js?v=20261105ue
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 18:47:54 -06:00
martbost f41d1ef384 Launch week: Founder badge + launch week contest (Marty approved 2026-11-05, PLAN.md options B and C)
Founder badge (cosmetic only: no credits, no POL, no perks, never posted to Telegram)
- Criterion: the account's earliest signed-in visit is before the launch moment (launchAt, default
  2026-11-15T06:00:00-06:00). Field: accounts.firstSeen, else lastSeen. Both are written only by
  accounts.touchSeen() on signed-in requests (dashboard, ping, chat); touchSeen now keeps firstSeen =
  the previous lastSeen on the next visit, so a pre-launch member who signs in again after launch still
  qualifies. Carried-over shells that never signed in have neither field and never qualify.
- Stored flag accounts.founder (JSON + MySQL column). Grant: launchweek.tick every 10 minutes from the
  launch moment, idempotent, one run per 10-minute slot across app copies (marks.claim); founderGrant '0'
  turns it off. Admin preview + "Grant Founder badges now" (refused before launch).
- Shown in the badge strip (on the way before launch, Share works, no Telegram post), wall (wall-founder.js),
  Team rows (my.js + team.js), the Team activity chip, and next to names on /leaderboard. Art:
  /badges/badge-founder.jpg, drawn in code in the existing card layout.

Launch week contest
- Window [launchContestStart or launchAt, launchContestEnd) = Sun Nov 15 6:00 AM to the end of Sat Nov 21,
  Central (end stored exclusive, 2026-11-22T00:00:00-06:00). Count = the weekly board's tier-1 TierPaid
  sales. Never counted: own positions, buys by linked positions (Qualified Start), the admin account and
  overrideHouseIds (as contestants or buyers), launchContestExcludeEmails/Ids. launchContestMinSales 2.
  Ties: sales, dollars, who got there first. Prizes launchContestPrizesPol '10,6,4'.
- Payout only by Admin > Launch week > Pay launch contest: the ranking is frozen on the first press, the
  admin's confirmed list must match it, balance + gas checked first, each place claimed once (marks.claim)
  and written as sending before award(memberId) from the Level 4 override payer wallet
  (override.payerHandle). Records tx hashes; resolve paid-with-tx or retry for blocked/failed/review.
  The prize email + feed line say "Launch week contest prize".
- /leaderboard panel from the launch moment until the prizes are paid; /launch copy states both rules.
- chatbot: CANNED founder-badge + launch-contest, FACTS lines (no amounts quoted before launch).
- qa/launchweek.test.cjs (16 checks: Central window bounds, exclusions, minimum, two-copy payout once,
  frozen result, Founder criterion + grant, touchSeen backfill); run.sh launchweek and in all.
- Versions: my.js?v=20261105fd, team.js?v=20261105fd, wall-founder.js?v=20261105fd,
  admin-launchweek.js?v=20261105lw (wall.js unchanged: the shared policy test pins it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:14:28 -06:00
martbost 4b8b31abe7 Payouts switch on by themselves (Marty 2026-11-05): the chatbot's activation answer still described the old manual step (buy, or the free activation, one transaction); the code has activated members the moment a wallet is linked since 2026-10-17 (accounts.onWalletLinked -> carry.ensureOnChain, engine pays gas, sponsors first; holding-tank members wait for a match, a purchase is never held). Chatbot answer + KNOWLEDGE_DATE 2026-11-05, /launch DM swipe and the checklist item ('Payouts switched on'), common.js?v=20261105po on every page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 07:54:33 -06:00
martbost 01d3c5cec2 Launch moment is 6 AM Central, not 9 (Marty 2026-11-05 on the launch review page): /launch copy, swipes and the countdown fallback 2026-11-15T06:00-06:00. launch.js?v=20261105l6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 07:40:52 -06:00
martbost 866a8d3083 /launch is LinkSpin's launch week checklist for Sunday 2026-11-15, 9 AM Central (Marty 2026-11-05: update it to the correct dates and information). It still carried InstantAdPay's September founding-week copy: the FOUNDER code and 500 credits, Monday Sept 21, the IAP doors images. Now: the Nov 15 date and a countdown that falls back to 2026-11-15T09:00-06:00 when launchAt is unset, a launch week note (Founder badge for members in before launch, rule posted before Sunday; launch week leaderboard contest Nov 15-21 with POL prizes, details on launch day; no amounts), day plan to Nov 21, posts and emails from campaign-2026-11/SWIPES.md with the member's link and angle tags, LinkSpin disclaimer. Dashboard link text 'launch week checklist'. launch.js?v=20261105lw, my.js?v=20261105lw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 07:08:13 -06:00
martbost 045f9522c4 Banner Spin: the Add a banner frame follows the selected spin's size (Marty 2026-11-05: it always showed 728x90). select() never redrew the empty preview, so it kept the first spin's frame; it now redraws on every select, and a file or image address picked for another spin is dropped so it is never checked or uploaded at the wrong size. banner-spin.js?v=20261105sz
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 04:23:55 -06:00
martbost bc4af45c01 Banner Spin and its stats tables switch to compact rows on the TABLE's width, not the window's (Marty 2026-11-04 screenshot: beside the link list and the rail, a desktop window left the banner column a few letters wide and the data ran down the left edge). Same container-query pattern as the destinations table (10-21)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:08:42 -06:00
martbost cc7c1d36af Login slots spell out the one-position rule (Michael Camire 2026-11-03: a reservation with 1,000 credits split 618 + 382 failed in a 2-second toast he never saw): GET /api/my/campaigns carries loginFunds (each position's free purchased credits); the composer shows "Paid from one position" with the per-position numbers and disables Launch/Reserve when no single position covers the slot; a login-specific 400 says nothing was charged and what to do; login failures open a dialog instead of a toast; chatbot fact; ads-screen.js?v=20261104lf, KNOWLEDGE_DATE 2026-11-04. loginqueue unit 13/13, e2e 36/36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 07:23:46 -06:00
martbost 33a6710909 Admin: POST /api/admin/rotations makes tracked spin links on a member's account (one rotation per link, optional traffic source), for the standalone games page and partner placements (Marty 2026-11-03)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-03 06:26:42 -06:00
martbost 8dbac9379f Snapshot: account counts from the JSON account store when MySQL is off (production LinkSpin), so sign-ups, wallets and payouts-on are real numbers, not zeros
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-02 08:29:37 -06:00
martbost d22b8adada Daily LinkSpin snapshot card (Marty 2026-11-02): spin links served, Banner Spin views, zone views, page views and leads, then sign-ups, purchases and POL paid, posted once a day to the LinkSpin Support topic (new target 'support', settings telegramSupportChatId/TopicId); window24() helpers on rotator, bannerspin, zones and pages; POST /api/admin/snapshot/send takes {target} for a one-off
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-02 08:17:38 -06:00
martbost fb0afbcb3c Home page Zones blurb says nine sizes, matching zones.js, /publishers and the chatbot (the four extra sizes landed 2026-10-07)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-02 07:08:10 -06:00
martbost dd438e6586 Launch day is date-driven (2026-11-15 Central): the pre-launch notice on every Control Room screen and the chatbot's pre-launch fact switch off by themselves at midnight, no deploy needed that morning 2026-11-02 07:04:44 -06:00
martbost f4351613a3 Signed-in sponsor line shows the chain-bound sponsor for activated members (2026-11-02): Orlando (member 2, carried in with no sponsor field) saw whoever's referral link he last clicked because /api/me fell back to the iap.sponsor cookie; the cookie now only speaks for accounts not on chain yet
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-02 04:26:48 -06:00
martbost e7a10f5478 Chatbot knows the light and dark themes (where the switch is, what Auto does, saved on the account); KNOWLEDGE_DATE 2026-11-01
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 11:14:57 -06:00
martbost 68061284ef QA for the themes: contrast check in both themes, QA_THEME walks, theme-switch assertions
qa/theme-contrast.mjs (bash qa/run.sh theme) loads the public pages and the member area in light and dark with Playwright, samples the main text/background pairs (body and muted text, links, buttons, chips, tags, stage pills, table text, panel headings, fields) with composited ancestor backgrounds and gradient averages, injects one probe per variant so every pair is measured even when a page has no live example, and reports the ratio per pair with pass/fail at 4.5:1 (3:1 for large text). One account per theme, since the account value wins at sign-in. Result today: 2,413 pairs, 0 fails, worst 4.63:1.

qa/walk.mjs honours QA_THEME=light|dark|auto (localStorage set before the first navigation; screenshots carry a -<theme> suffix so both sets survive), asserts the topbar and Profile switch (applies at once, saves to the account, repaints the other control), and screenshots the public home, the member's wall and the join page from the local copy. Requests the page cancels by navigating away (net::ERR_ABORTED) no longer count as failures, and the local-only /api/qr 404 (no qrcode module in a checkout) is ignored for images. Both QA_THEME walks: 0 bugs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 10:57:58 -06:00
martbost b84eed3be5 Theme switch: auto | light | dark, stored in localStorage ls.theme and on the account, applied before first paint on every page
themehead.js is the one source of the tiny inline head script (and of AUTO_DEFAULT, the one constant Marty decides later: 0 = nothing stored keeps the page's current look, light for Control Room and public pages, dark for the sapphire pages; 1 = follow the device). The script sets data-theme on <html> from ls.theme (auto follows prefers-color-scheme and tracks changes live) and exposes window.LSTheme. tools/stamp-theme-head.cjs writes it into every static page before the first stylesheet with data-theme-base on <html>; blog, leaderboard, what's-new, the badge page, the unsubscribe page and the wall 404 read the module directly. The site CSP allows inline scripts by hash only, so themehead.CSP_HASH joins script-src (the script was silently blocked until then).

Account side: accounts.theme (JSON store and MySQL, alterSafe column), in the public account JSON and /api/me; POST /api/my/profile {theme} rides the existing profile save path and never touches the username. cr-shell.js renders a Light / Dark / Auto segmented control in the topbar of every Control Room screen and paints every .theme-seg on the page (the Profile pane gains an Appearance card with the same control); a click applies at once, saves locally and to the account when signed in; at sign-in the account value wins over the local one, and a local choice is pushed up when the account has none yet. view.html stops reading an undefined --bg so its light variant has a light stage. ?v= tags bumped on every changed stylesheet and script (20261101t / ls20261101t).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 10:44:40 -06:00
martbost 7c8f204f5a Light and dark themes as token sets (Marty 2026-11-01: a member asked for both, for vision-impaired readers and people who struggle with bright or dark screens)
cr.css and pub.css gain :root[data-theme="dark"]: deep navy workspace (#0B1424 ground, #142338 panels, #1B2D47 panel-2), near-white ink, readable muted, quiet lines, the blue accent and signal orange retuned so text on them and they on the ground clear WCAG AA 4.5:1 (accent-ink/sig-ink/ok-ink/bad-ink/on-ink tokens carry the text colour for each fill), soft fills as dark tints, flatter darker shadows; the chrome rail, topbar and strip stay as they are. site.css (the sapphire pages) gains :root[data-theme="light"]: light ground, white panels, dark ink, the same blue family darkened to read on white, the chrome headline gradient turned blue steel so it still shows.

Audit of stray literals: every raw hex/rgba that encoded a surface, text, border or soft fill in the five stylesheets now reads a token (new tokens: field-bg, btn-bg, btn-blue, panel-grad(-hi/-deep), ph-a/b, hl, grid-dot, bg-glow, row-hover, panel-glass, sh-lg, note-*, violet-*, *-line, chrome-hi/warm, mint-faint/soft-2/line/line-2/deep/pale, gold-*, amber-*, cyan-*, muted-soft, ink-faint, ground-soft, nav-bg, side-bg, pill-bg, glow). tools.css maps every site.css token onto a Control Room token (its hard-coded --ink and --mint-ink are gone), admin.css loses its white/slate literals. Stage and pipeline palettes get a lifted dark variant; .stg text mixes the stage colour with ink so 10.5px pills pass in both themes. Light-side tuning for AA: muted #596984, ok #0B7A52, warn #B23A0A, sig-2 #B8420A, and the orange primary button carries navy text (white on #FF6A1A was 2.9:1).

Scripts that draw UI read tokens: my.js charts take their colours from getComputedStyle at draw time (CH proxy), donut caption and rank/wallet/ready badges use var(--muted)/var(--gold)/var(--ok); admin.js, credits-screen.js, engine-room.js, common.js (wordmark stroke) and cr-shell.js (arrival strip) likewise. Left as literals on purpose: brand gradients on the orange primary buttons, glows and drop shadows, overlays (modal backdrops, the full-screen ad viewer), video/QR/banner-preview backings that must stay black or white, print styles, var() fallbacks, and the categorical stage colours themselves.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 10:44:20 -06:00
martbost 4c0a68cbdd Coach nudges never guess from a failed chain read, and the site owner is never coached (Marty 2026-10-31): a chain.member() failure cached null for 60 s, rungFor() then classed the member as "payouts on, no purchase" and mailed the rung-2 "See a payout land: your first package" nudge to the owner (memberId 1, 4 purchases, 7 buyers). describe() now reports unknown and stalled requires a known state; nudgeTick skips adminEmail.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-31 07:44:19 -05:00
martbost 12788e799f Policy test follows the new link-farm report wording (new / still watched / left the list)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-31 07:29:06 -05:00
martbost 58dcbf8cee Link-farm scan reports only changes: new candidates since the last run and accounts that left the list (wallet linked, bought, deleted), with the still-watched count; candidates carry firstSeen (Marty 2026-10-31: watch, do not delete yet)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-31 07:26:41 -05:00
martbost a24e90b590 Pages host (lookfirst.page) serves page-builder media too: /niches/<file> and /uploads/<id>.<ext>; the builder pages live on the pages host, not the link domains (Neville 2026-10-30)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-30 14:46:50 -05:00
martbost db4308c5fc Link domains serve page-builder media: /niches/<file> and /uploads/<id>.<ext> on the short link domains (Neville 2026-10-30: images showed in Preview on linkspin.app but 404ed on the live lookfirst.page link because the mini-site answered gone for every path but its own five)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-30 14:44:15 -05:00
martbost f69453648b Wall profile rendering: a purchase alone decides (a quarantined account that buys a package gets its bio and links back, as the quarantine notice promises)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-30 07:33:19 -05:00
martbost bdf1aab06c Link-farm hardening (2026-10-30 incident: 106 free accounts synced from InstantAdPay carried casino bios and website links; Google indexed the text through /wall pages)
Public walls: profile fields (bio, avatar, socials, intro video) render only for a paying member (memberId > 0 or a registered position), on /api/wall and in the OG image; a free account's wall shows the name, the line's ads and the join call. The meta/og description is a fixed site sentence with the handle, never the bio. Outbound profile links are rel="sponsored ugc noopener" target="_blank". A deleted or unknown name is a real 404 with X-Robots-Tag noindex (was a bare "Banner wall" page at 200, a soft 404 that stayed indexed).

Policy (prohibited.js, byte-for-byte copy of InstantAdPay's): bios may not carry a URL or a domain token ("Links go in the social fields, not the bio"); gambling, adult, pharma, weapons and link-selling terms (Unicode aware) are refused in bios, social URLs, line banner targets, wall offers and every campaign field, with the refusal logged. The registry ingest from InstantAdPay drops a bio with a link or a prohibited term instead of storing it; iapsync applies the same on the way out.

Quarantine rule: a brand-new free account (no wallet, no sponsor, under 24 h) whose first profile save plants a link is saved with profileQuarantined (JSON + MySQL column), never rendered publicly, and told "Your profile links will appear after your first ad package"; the admin member card shows the flag.

Daily link-farm scan (spamscan.js, same copy as InstantAdPay): in-app job at 06:30 Central, claimOnce per day, lists memberId-0 walletless accounts with a link plus a farm signal (prohibited term, sign-in over within 15 min, no sponsor), skips the spamScanAllow setting (seeded), writes DATA_DIR/wall-spam-scan.json and sends one "LinkSpin link-farm scan" Telegram to the private admin chat only when there are candidates. Admin > Members > Link-farm list: rows with "also on InstantAdPay" (local registry mirror), Delete selected (existing DELETE /api/admin/member, on-chain refused, no cascade) and Allow.

Terms section 9 "Prohibited content", bio hint in the profile editor, chatbot canned answer + kb-seed entry "What content is not allowed?", KNOWLEDGE_DATE 2026-10-30. Test: qa/profile-policy.test.cjs (unit + local copy, hash check against the InstantAdPay copies; runs in qa/run.sh member and policy).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-30 07:32:07 -05:00
martbost be38f454ef QA: LinkSpin's public walk targets linkspin.app (the instantadpay.com default was a copy-paste leftover, so the public run had been checking the wrong site)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-29 10:56:53 -05:00
martbost 86b60f493c Traffic guide rendered empty since 2026-10-28: a // comment inside the network filter one-liner swallowed the return and the closing brackets, so traffic-guide.js failed to parse (Marty saw it on his phone 2026-10-29). Comment moved out, ?v=20261029b. QA: node --check syntax gate on every script in every run.sh mode; /traffic-guide, /refuel and /conversion-tracking added to the public walk
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-29 10:51:46 -05:00
martbost 1e8addc801 Traffic guide (/traffic-guide): which ad formats convert for which offer, all 30 catalog networks with the formats they sell plus adult-heavy and strict-policy flags, ground rules; Sources screen gets a Traffic guide button, format tags in the New source picker (searchable by format) and a 'sells / best for' line on each source; chatbot answer + facts (Marty 2026-10-28: members asked what traffic suits which ads)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 07:30:28 -05:00
martbost 9ebbef2d21 Network rate 4:1 (Marty approved 2026-10-27, same as InstantAdPay): views off LinkSpin cost 1/synRateDivisor of the on-site rate, going forward
rates.synRateDivisor (default 4, Admin > Rates; 1 = the old rule). Network Ad Space impressions charge 1 credit per
impressionsPerCredit x N views; member campaigns shown in other members' zones on their own sites (zones.js serve,
offsite) are counted in the new synImps (not Views here) and charged one batch per N x the on-site batch (2 credits
per 40 banner views at N=4) through the same spend path, so burns follow what was charged. Fractions are exact (the
cumulative served count / the syn_batch counter carry the remainder). The budget is the limit: bookings, resume,
top-up and daily allowances are sized at the network rate, and a live ad booked at the old rate is topped up once.
Nothing already charged changes; zone owners keep earning as before. Ads screen + classic Campaigns show network and
partner-zone views marked at 1/4; chatbot canned answer + live AI fact; cache tags bumped.
QA: qa/run.sh nas (stop 9, ratio 10), loginqueue 13, refill 12, run.sh member passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 08:10:02 -05:00
martbost fd6f88cab7 Fix NAS stop trap on LinkSpin: snapshot true delivery before every stop, reconcile active ads only, restart stopped ads from the true count
The InstantAdPay 2026-09-17 fix was never ported. nas.deactivate zeroed `remaining` with no snapshot, so served =
assigned - remaining read the undelivered rest as delivered, and reconcileNas read EVERY status: a paused ad was
charged for its zeroed remainder (up to its budget) and stopped ads showed their whole allocation as network views.
Now: nas.deactivate returns the served count read before the stop; ads.stopNas persists it on pause, end and
exhaustion; reconcileNas only looks at active campaigns; resume/top-up of a stopped ad uses the new nas.restart
(re-bases assigned on the true count) instead of a plain top-up. QA: qa/nas-stop.test.cjs (9), loginqueue 13,
refill 12, run.sh member passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:56:56 -05:00
martbost 2d0413037d Holding tank on LinkSpin (ported from InstantAdPay 4645d56, Marty 2026-10-27): network sponsor ALIGNMENT first, the free activation held (never a purchase), 24-hour rotation, payouts switched on the moment someone is assigned
- Align first, every path (/api/me, /api/sponsor all intents incl. buy, carry.ensureOnChain via tank.gate, 15-min readyTick): a tank member (no sponsorRef, no member number, no resolvable cookie) whose email has a sponsor in the InstantAdPay registry rows, else a signed sponsor-facts call (3 s timeout, 10 min cache, one batch per tick), else the same wallet, is placed under that sponsor through accounts.setSponsorRef when the sponsor has a LinkSpin account; never a sponsor they were adopted/released/rescued away from, never a loop. Recorded in tank-ready.json, listed in Admin tank
- Hold ONLY the plain Switch on payouts (Marty: "I would never want to hold up a purchase ... they'll just pay number one"): the engine's wallet-link activation and seeding wait, /api/sponsor?intent=activate answers sponsorBlocked tankHold; intent=buy and /api/me never block (buys go ahead under #1 as before). A sponsor activated because someone below is buying is never held. Activate buttons now call intent=activate
- Ready badge + hours left (My line tank, Admin tank, Overview count); one shared-payments-topic line per newly ready member (digest when more than 3)
- 24-hour rotation through adopt(): own $25+ buy, fewer than 2 open, seen within 7 days, not company/#1, not a no-payout chain, not own downline; least recently auto-assigned first. Nobody eligible: keep holding, one admin alert. Never #1
- Payouts on at assignment (Marty approved 2026-10-27): adopted, auto-assigned or aligned member with a wallet is activated right away by carry.activateAssigned (strict: sponsor must be on the contract and not on a no-payout chain, never the fallback; retried every tick for 7 days); the auto-assign chat/email say "Your payouts are now on under @sponsor" with the Polygonscan link, a manual adoption gets a follow-up chat + email
- Deploy overlap: marks.js claims for the activation (per member per 10 min), the auto-assign, the ready post and the admin alert
- Cross-site: someone waiting in InstantAdPay's own tank (claimed account there, no sponsor, not a member there, wallet linked) is auto-assigned by InstantAdPay only (live sponsor-facts, registry fallback); LinkSpin defers and does not post them
- Chatbot: tank-hold canned answer, holding-tank answer + facts, KNOWLEDGE_DATE 2026-10-27; cache tags my.js / credits-screen.js / admin.js 20261027th
- QA: qa/tank-hold.test.mjs (unit with mocked clock + fake engine, then a local copy with a mock InstantAdPay and a browser check of Credits), qa/carry-activate.test.cjs (regression for the 10-22 scoping bug), run.sh tankhold + sponsorfollow; run.sh borrows InstantAdPay's node_modules when this checkout has none

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:26:51 -05:00
martbost fd064b1db1 Fix carry.ensureOnChain: sponsorId/txHash/lastErr were declared inside the try but read after the finally, so every engine activation since a5c2c38 (2026-10-22) threw 'sponsorId is not defined' after the activateFor tx mined: member number not saved, notice not sent, in-flight flag stuck, and a buy whose sponsor needed activation fell back to #1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 07:12:51 -05:00
martbost c037923528 Remove every MoonPay mention and link (ZeroFox/MoonPay false-positive takedown, 2026-10-26)
- server.js: /api/moonpay-url endpoint deleted (MOONPAY_PUBLIC_KEY / MOONPAY_SECRET_KEY env and siteConfig().moonpayPublicKey no longer read)
- admin.js: moonpayPublicKey settings label dropped
- credits.html + credits-screen.js: "Buy POL with a card" button and handler removed
- my.js: openMoonpay() and the card-buy button removed; the New to crypto note now points to /wallets ("Wallet help")
- wallets.html + wallets.js: card section rewritten neutrally (any major exchange or on-ramp, POL on Polygon, your own address), wlMoonpay button logic, in-wallet note and MoonPay FAQ/disclaimer replaced
- chatbot.js: wallets canned answer, tags/regex and FACTS rewritten with no brand named
- kb-seed.js: f-moonpay-declined replaced by f-card-declined (the old seed is retired from kb.json on the next boot unless it was admin-edited)
- qa/kb-retrieval.cjs: case updated to f-card-declined
- cache tags bumped: credits-screen.js, my.js, wallets.js ?v=20261026a

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:04:32 -05:00
martbost 399a2bcc38 Sessions last 4 hours, same as InstantAdPay (Marty 2026-10-26: login ads get seen more often); SESSION_TTL_HOURS env, default 4; new sessions carry issued, legacy 24 h sessions are cut to issue time + 4 h
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 07:03:11 -05:00
martbost 98e3ed36d8 Conversion tracking fixes (Marty approved 2026-10-26): own clicks are tests on every click type, Banner Spin straight-to-page clicks carry lsclk
1. Own clicks: a goal owner's own click on ANY click type (LinkSpin/InstantAdPay ads, spin links, Banner Spins) is kept as a test, never counted, never fires a goal postback. Own = ad click flagged self for that owner, a spin-link / Banner Spin click marked at click time (signed in as the owner, or from an owner soft key: markOwnClick in server.js), or the clicking or converting browser's soft key is one the owner signs in from. auth.onSeen notes LinkSpin session soft keys (throttled, kept 31 days in convtrack.json S.own); /api/partner/clicks takes owners [{owner, sk, ts}] from InstantAdPay before the clicks, so IAP members' own browsers are known too. Linked positions share the owner's email. X-LS-Result adds ;self. partnerSummary returns selfTests for the IAP card. Conversions screen copy: test with Send a test conversion and the &test=1 page check, own clicks never count (conversions.js ?v=20261026a).
3. Banner Spin: a click whose target is a direct page (not a /r/ spin link) gets ?lsclk=<k click id> when the owner tracks goals (string insert like lsconv.withClickId: params kept, before #hash, an existing lsclk never replaced). convtrack.lookup resolves k ids through bannerspin.clickById; conversions record k:'bspin' with the Banner Spin, banner, page and source; report By Banner Spin, CSV site 'Banner Spin', postback ctx with its sub ids.
Guides: /conversion-tracking (Banner Spin straight to a page now counted, own clicks on every type are tests, By Banner Spin), /refuel tile. Chatbot CANNED + FACTS, KNOWLEDGE_DATE 2026-10-26.
QA: convpixel 77/77 (new: owner soft keys, own ad/spin/Banner Spin/IAP clicks as tests, stranger still counts, own-browser conversion, withClickId, Banner Spin lsclk + By Banner Spin + spin-link banner untouched, selfTests in the IAP summary, no postback for own clicks); lsid 31/31; fuel all pass (engine.js / engine-room.js / kit.js untouched, byte-identical with InstantAdPay); bannerspin 75/75; member walk 0 bugs; public 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 06:19:54 -05:00
martbost 28192b61e9 Conversion tracking walkthrough video live (Marty approved 2026-10-26): on /conversion-tracking and the Training card
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 04:55:38 -05:00
martbost 837d4b6569 Refuel in the menu + arrivals from InstantAdPay (Marty 2026-10-25: "I don't see any kind of refueling option on LinkSpin in the menu"; "it took me to LinkSpin but I don't know how to pick up from there"). Rail item Refuel -> /credits#refuel: the Refuel panel is scrolled to and flashed once loaded (also after sign-in pop-ups, settles again on phones); /credits#buy and /ads#engine work the same way. Refuel panel: says any $25+ package counts, button "Buy a $25+ package" scrolls to the picker, links to the Engine Room, and a Buy on InstantAdPay link when LinkSpin is done but InstantAdPay is not. Packages of $25+ carry a "counts for Refuel" tag. Links from InstantAdPay (?from=iap&task=refuel|conversions|bannerspin|spinlink|testing|page|ads) open with a strip: "You came from InstantAdPay to <job>. Step 1: ...", guide link, Back to InstantAdPay; signed out, the strip and the sign-in pop-up say to use the same InstantAdPay email, and the Refuel/Engine panels reload after sign-in (cr:signedin). Engine Room built with site 'linkspin': buy/top-up/Fuel links stay on LinkSpin. engine.js / engine-room.js byte-identical with InstantAdPay. Chatbot routes, KNOWLEDGE_DATE 2026-10-25. QA: fuel 16/16 + drift check, member walk 0 bugs. cr-shell.js ?v=20261025ff on all 12 pages; fuel.js, engine-room.js, credits-screen.js bumped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 09:06:06 -05:00
martbost f38eec9a38 Support tickets are members-only (Marty 2026-10-24, after a throwaway-address 'pentest' ticket IAP-1012): signed-out support form + chatbot handoff need an email that belongs to an account on this site; inbound email opens NEW tickets only for member emails (replies to existing tickets still land)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 11:36:22 -05:00
martbost db46fc4a2b Conversion tracking member guide at /conversion-tracking (Marty, 2026-10-24: no training existed for the conversion pixel, live since 10-23)
Same content as InstantAdPay's guide in the pub.css look of /refuel, LinkSpin-first: Control Room > Conversions, spin links add lsclk once a goal exists, the 2 / 2b snippets, report columns (Spent, Clicks, Goals, Rate, Cost / goal), Address / Kept / Cookie / 24 h match, by spin link / page / source, CSV, postbacks on event goal, a Banner Spin banner pointed straight at a page is not matched (point it at a spin link), own AD clicks are tests while a sign-up through your own spin link counts. Flow drawn in HTML/CSS (works at 390 px). conversion-guide.js: copy buttons + new-tab links when framed.
Route + TRAFFIC_PAGES + sitemap; Training entry (catalog/training.json "conversion-guide", group "Track your results"); "How to set it up" link on the Conversions screen. Chatbot CANNED conversions answer + FACTS line point to the guide (KNOWLEDGE_DATE stays 2026-10-24).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 10:19:03 -05:00
martbost 93317d6ba0 Refuel guide: why-cards 2 x 2 on desktop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 09:20:51 -05:00
martbost 9ce57ae1ff Refuel guide: the walkthrough video (Marty approved 2026-10-24) replaces the banner, plus a 'Why keep refueling' section (steady traffic, useful numbers, fresh creative, the climbing bonus); training card gets the video
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 09:17:20 -05:00
martbost e5fb985c6b Fuel Your Offers member guide at /refuel (Marty, 2026-10-24): LinkSpin-first wording (Credits, Ads, Banner Spin), same rules as InstantAdPay's refuel.js, flow drawn in HTML/CSS (works at 390 px), pub.css look, hero og:image banners/fuel-your-offers-1200x675.jpg, refuel-guide.js opens join/member/off-site links in a new tab (with ?ref) when framed. Route + TRAFFIC_PAGES + sitemap; Training entry (catalog/training.json "refuel-guide"); "How the Refuel streak works" link on the Monthly Refuel panel and in the Engine Room.
Fixes: Engine Room streak line no longer asks for the other site once both are refueled (engine.js + engine-room.js copied from InstantAdPay, byte-identical). Ads-screen Monthly Refuel rows had no spacing ("InstantAdPay+30%"): own flex row style. Load into my Banner Spin: size checkboxes, pre-ticked to what fits the tier (728x90 + 300x250 on an empty Starter), and kitspin.js returns one plain message: what loaded, what did not and why (tier holds N Banner Spins), and what to do; /api/my/kits adds spinRoom. Test added (refuel-kit 6/6).
Chatbot CANNED + refuelFact point to /refuel. fuel.js + engine-room.js ?v=20261024rg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 08:07:32 -05:00
martbost fee138bbc1 Chatbot: month-4 Twin Engine Featured bonus is 100 credits on InstantAdPay (Marty 2026-10-24)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 06:39:01 -05:00
martbost fc92b09796 Chatbot: Level 4 override is live (CANNED level4-override + FACTS line; start Mon 2026-10-26 00:00 CT, first payout Mon 2026-11-02 9 AM CT). overrideMode=live + overrideGoLive=1792990800000 set on the site, payer wallet funded (Marty, 2026-10-24).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 06:14:59 -05:00
martbost 018101f011 Engine Room panel on the LinkSpin Ads screen (Fuel Your Offers stage 4, Marty approved 2026-10-24): engine.js + engine-room.js are the same files as InstantAdPay's. LinkSpin's facts (credits, campaigns, clicks this week and last via coach.clicksSince, free login slots, conversion-pixel goals this month from the Central 1st via convtrack.countSince, conversions in 30 days, and the Banner Spin / spin link / page / testing part states from bannerspin, rotator and pages) are combined with InstantAdPay's facts and the streak from signed /api/partner/engine on InstantAdPay (cached a minute; when it does not answer the panel says so). LinkSpin answers /api/partner/engine for InstantAdPay's tab. /api/my/engine, /api/my/engine/goal (forwarded to InstantAdPay, where the goal lives with the streak). Hidden while refuelStreak is off; greyed "Refuel to start your engine" until the first counted refuel. Chatbot CANNED + FACTS cover it. qa/refuel-engine.test.cjs checks the shared files have not drifted from InstantAdPay's and runs its engine test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 05:55:12 -05:00
martbost 4749d711f4 Refuel Kit on LinkSpin (Fuel Your Offers stage 3, Marty approved 2026-10-24): kit.js (same file as InstantAdPay) with LinkSpin's own art, entitlement from InstantAdPay's streak record through refuel.status (view.kits: month -> streak month at unlock). Ads screen Refuel Kit panel (fuel.js?v=20261024kit): Make mine, Download, Copy image link, animated at a 3-month streak, and "Load into my Banner Spin" (kitspin.js): each Banner Spin size in the kit goes into one of the member's Banner Spins of that size with room, or a new one while the tier allows (the reason is shown when it does not); the personalized file is copied into uploads like a normal Banner Spin upload, labelled "Refuel Kit <month>", target = the member's own link; loading twice adds nothing twice; files over 150 KB are refused plainly. /kitimg/<hmac> public serving, admin Settings > Refuel Kit (upload, placeholder art, preview, release), raster copies of the LinkSpin placeholder banners (public/banners/linkspin-<size>.png, from the existing SVGs) for the placeholder kit. Behind the refuelStreak switch. Chatbot CANNED + FACTS mention the kit. qa/refuel-kit.test.cjs 5 checks against the real bannerspin.js. Note: qa kb retrieval has 2 pre-existing misses (spin links vs Banner Spin, PropellerAds postback), same before this change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 05:44:40 -05:00
martbost 7bcde25116 Monthly Refuel streak, LinkSpin side (Fuel Your Offers stage 2, Marty approved 2026-10-24). The streak lives on InstantAdPay (one per member across both sites); refuel.js here reports each $25+ LinkSpin package (refuelMinLsCents) once per tx (claim rfev:<tx>, then a pending file in DATA_DIR/refuel-pending retried every minute until InstantAdPay answers), applies LinkSpin's grants and reminders from InstantAdPay's outbox (claim rfg:<ref> before applying, so two app copies or a lost ack never double-grant; grants are purchased-grade addEarned + a credit-log line + a notice), and relays the member's status for the Monthly Refuel panel on Credits and Ads (fuel.js) and the refill notice streak line. Linked positions count for their owner. Chatbot CANNED + FACTS follow the switch, KNOWLEDGE_DATE 2026-10-24. Admin /api/admin/refuel (+ /tick), member /api/my/refuel. MASTER SWITCH refuelStreak default '0': nothing reported, pulled or shown. qa/refuel.test.cjs 10 checks against InstantAdPay's real refuel.js in-process (both switches, cross-site both-engine top-up in both orders, two LinkSpin copies, InstantAdPay down, lost ack, reminders, status).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 05:29:00 -05:00
martbost ab4f1693df Refill notices on LinkSpin (Fuel Your Offers stage 1, Marty approved 2026-10-24): refill.js copied from InstantAdPay. Low (80% of budget delivered, refillLowPct), out, and idle (7 days after an unanswered out notice, 100+ credits free, nothing running): one email + one on-site notice per owner per pass, naming each ad and what it delivered, then the relaunch line (100+ credits free) or the /credits link, then the packages from the chain catalog and a streak-line hook for stage 2. Email skips drip unsubscribes and carries the unsubscribe link; the notice (kind notice) always goes. Every send is watched 45 days for purchase / relaunch / resumed / topup. marks.js: one-time claims shared by both app copies during a deploy (event_marks with a DB, exclusive file create on the shared volume without one); every send is claimed first. Settings refillNotices '1' (default on) + refillLowPct 80; admin GET /api/admin/refill, POST /run and /reset, an Overview card (admin-refill.js). qa/refill.test.cjs (12 checks incl. two app copies on one volume) + run.sh fuel mode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 05:11:12 -05:00
martbost 7b3844b757 QA: convpixel test (unit, local e2e, browser + framed) and Conversions in the member walk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:10:48 -05:00
martbost b0f13e2a66 Chatbot + FAQ: conversion pixel canned answer and FACTS line (KNOWLEDGE_DATE 2026-10-23)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:10:48 -05:00
martbost 07379803d7 Control Room Conversions screen: goals, the two snippets, Send a test conversion, autoresponder advice, match-method breakdown, per-goal conversions and cost per goal by ad campaign (LinkSpin + InstantAdPay), spin link, page and source, CSV; rail entry, shell tag bumped; privacy page covers click ids, the landing tag and the pixel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:10:47 -05:00
martbost dd2244272b Conversion pixel engine (Marty approved 2026-10-23): goals with public pixel ids, click ids on every ad click (lsclk, 'a'+11 hex), spin links pass the ad click on, landing tag /t.js + goal pixel /cv.gif /cv.js matching url > stored > cookie > 24 h soft key, once per click, 30-day window, owner check, rate limits, goal postbacks (event 'goal'), member + signed partner APIs for InstantAdPay
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:10:46 -05:00
192 changed files with 18941 additions and 5516 deletions
+26 -9
View File
@@ -36,9 +36,14 @@ const pub = a => a ? { email: a.email, sponsorRef: a.sponsorRef || '', code: a.c
username: a.username || null, memberId: a.memberId || 0, joinedVia: a.joinedVia || null, joinedRef: a.joinedRef || null, username: a.username || null, memberId: a.memberId || 0, joinedVia: a.joinedVia || null, joinedRef: a.joinedRef || null,
lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null, wallOffers: a.wallOffers || null, lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null, wallOffers: a.wallOffers || null,
avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials: a.socials || null, avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials: a.socials || null,
profileQuarantined: !!a.profileQuarantined, // 2026-10-30: first profile save of a brand-new free account planted a link; stored, never rendered publicly (spamscan.js)
chatAvailable: a.chatAvailable === false ? false : true, lastSeen: a.lastSeen || 0, chatAvailable: a.chatAvailable === false ? false : true, lastSeen: a.lastSeen || 0,
firstSeen: a.firstSeen || 0, // 2026-11-05: earliest known signed-in visit (backfilled from lastSeen on the next visit); the Founder badge reads it
founder: a.founder || 0, // 2026-11-05: Founder badge granted (ms of the launch moment it was granted for); cosmetic only (launchweek.js)
theme: a.theme || null, // 2026-11-01 appearance: auto | light | dark, follows the member across browsers (cr-shell.js)
address: a.address || null, created: a.created } : null; address: a.address || null, created: a.created } : null;
const USER_RE = /^[a-zA-Z0-9_]{3,20}$/; const USER_RE = /^[a-zA-Z0-9_]{3,20}$/;
const THEMES = new Set(['auto', 'light', 'dark']);
const normUser = u => String(u || '').trim().toLowerCase(); const normUser = u => String(u || '').trim().toLowerCase();
// ---- JSON fallback ---- // ---- JSON fallback ----
@@ -116,16 +121,19 @@ const J = {
acct.wallOffers = json || null; this.save(); acct.wallOffers = json || null; this.save();
return { ok: true, account: pub(acct) }; return { ok: true, account: pub(acct) };
}, },
async setProfile(e, avatarUrl, bio, socials) { async setProfile(e, avatarUrl, bio, socials, quarantined) {
const acct = this.db.byEmail[e]; const acct = this.db.byEmail[e];
if (!acct) return { error: 'No such account.' }; if (!acct) return { error: 'No such account.' };
if (avatarUrl !== undefined) acct.avatarUrl = avatarUrl || null; if (avatarUrl !== undefined) acct.avatarUrl = avatarUrl || null;
if (bio !== undefined) acct.bio = bio || null; if (bio !== undefined) acct.bio = bio || null;
if (socials !== undefined) acct.socials = socials || null; if (socials !== undefined) acct.socials = socials || null;
if (quarantined !== undefined) acct.profileQuarantined = !!quarantined;
this.save(); this.save();
return { ok: true, account: pub(acct) }; return { ok: true, account: pub(acct) };
}, },
async touchSeen(e) { const a = this.db.byEmail[e]; if (a) { a.lastSeen = Date.now(); this.save(); } }, async touchSeen(e) { const a = this.db.byEmail[e]; if (a) { const now = Date.now(); if (!a.firstSeen) a.firstSeen = a.lastSeen || now; a.lastSeen = now; this.save(); } }, // firstSeen keeps the earliest signed-in visit we know of
async setFounder(e, ts) { const a = this.db.byEmail[e]; if (!a) return { error: 'No such account.' }; if (a.founder) return { ok: true, already: true }; a.founder = Number(ts) || Date.now(); this.save(); return { ok: true }; },
async setTheme(e, t) { const a = this.db.byEmail[e]; if (!a) return { error: 'No such account.' }; a.theme = THEMES.has(t) ? t : null; this.save(); return { ok: true, account: pub(a) }; },
async setChatAvailable(e, v) { const a = this.db.byEmail[e]; if (!a) return { error: 'No such account.' }; a.chatAvailable = !!v; this.save(); return { ok: true, available: !!v }; }, async setChatAvailable(e, v) { const a = this.db.byEmail[e]; if (!a) return { error: 'No such account.' }; a.chatAvailable = !!v; this.save(); return { ok: true, available: !!v }; },
async getMutes(e) { const a = this.db.byEmail[e]; return (a && Array.isArray(a.chatMutes)) ? a.chatMutes : []; }, async getMutes(e) { const a = this.db.byEmail[e]; return (a && Array.isArray(a.chatMutes)) ? a.chatMutes : []; },
async setMute(owner, target, muted) { async setMute(owner, target, muted) {
@@ -229,8 +237,8 @@ const J = {
const rowPub = r => r ? pub({ email: r.email, sponsorRef: r.sponsor_ref, code: r.code, const rowPub = r => r ? pub({ email: r.email, sponsorRef: r.sponsor_ref, code: r.code,
username: r.username, memberId: r.member_id || 0, joinedVia: r.joined_via || null, joinedRef: r.joined_ref || null, username: r.username, memberId: r.member_id || 0, joinedVia: r.joined_via || null, joinedRef: r.joined_ref || null,
lineBannerUrl: r.line_banner_url, lineTargetUrl: r.line_target_url, wallOffers: r.wall_offers || null, lineBannerUrl: r.line_banner_url, lineTargetUrl: r.line_target_url, wallOffers: r.wall_offers || null,
avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, profileQuarantined: !!r.profile_quarantined,
chatAvailable: r.chat_available === 0 ? false : true, lastSeen: Number(r.last_seen || 0), chatAvailable: r.chat_available === 0 ? false : true, lastSeen: Number(r.last_seen || 0), theme: r.theme || null, firstSeen: Number(r.first_seen || 0), founder: Number(r.founder || 0),
address: r.address, created: Number(r.created) }) : null; address: r.address, created: Number(r.created) }) : null;
const D = { const D = {
async signup(e, password, ref) { async signup(e, password, ref) {
@@ -284,13 +292,16 @@ const D = {
await db.q('UPDATE accounts SET wall_offers=? WHERE email=?', [json || null, e]); await db.q('UPDATE accounts SET wall_offers=? WHERE email=?', [json || null, e]);
return { ok: true, account: await this.byEmail(e) }; return { ok: true, account: await this.byEmail(e) };
}, },
async setProfile(e, avatarUrl, bio, socials) { async setProfile(e, avatarUrl, bio, socials, quarantined) {
if (avatarUrl !== undefined) await db.q('UPDATE accounts SET avatar_url=? WHERE email=?', [avatarUrl || null, e]); if (avatarUrl !== undefined) await db.q('UPDATE accounts SET avatar_url=? WHERE email=?', [avatarUrl || null, e]);
if (bio !== undefined) await db.q('UPDATE accounts SET bio=? WHERE email=?', [bio || null, e]); if (bio !== undefined) await db.q('UPDATE accounts SET bio=? WHERE email=?', [bio || null, e]);
if (socials !== undefined) await db.q('UPDATE accounts SET socials=? WHERE email=?', [socials || null, e]); if (socials !== undefined) await db.q('UPDATE accounts SET socials=? WHERE email=?', [socials || null, e]);
if (quarantined !== undefined) await db.q('UPDATE accounts SET profile_quarantined=? WHERE email=?', [quarantined ? 1 : 0, e]);
return { ok: true, account: await this.byEmail(e) }; return { ok: true, account: await this.byEmail(e) };
}, },
async touchSeen(e) { await db.q('UPDATE accounts SET last_seen=? WHERE email=?', [Date.now(), e]); }, async touchSeen(e) { const now = Date.now(); await db.q('UPDATE accounts SET first_seen=COALESCE(first_seen, last_seen, ?), last_seen=? WHERE email=?', [now, now, e]); }, // SET runs left to right: first_seen takes the OLD last_seen
async setFounder(e, ts) { const r = await db.q('UPDATE accounts SET founder=? WHERE email=? AND (founder IS NULL OR founder=0)', [Number(ts) || Date.now(), e]); return { ok: true, already: !(r && r.affectedRows) }; },
async setTheme(e, t) { await db.q('UPDATE accounts SET theme=? WHERE email=?', [THEMES.has(t) ? t : null, e]); return { ok: true, account: await this.byEmail(e) }; },
async setChatAvailable(e, v) { await db.q('UPDATE accounts SET chat_available=? WHERE email=?', [v ? 1 : 0, e]); return { ok: true, available: !!v }; }, async setChatAvailable(e, v) { await db.q('UPDATE accounts SET chat_available=? WHERE email=?', [v ? 1 : 0, e]); return { ok: true, available: !!v }; },
async getMutes(e) { async getMutes(e) {
const r = await db.q('SELECT chat_mutes FROM accounts WHERE email=?', [e]); const r = await db.q('SELECT chat_mutes FROM accounts WHERE email=?', [e]);
@@ -459,7 +470,11 @@ async function linkWallet(email, address) {
async function count() { return impl().count(); } async function count() { return impl().count(); }
// admin: newest-first account list, and re-pointing a member's sponsor (a // admin: newest-first account list, and re-pointing a member's sponsor (a
// username, share code, or numeric member id: the same tokens join links use) // username, share code, or numeric member id: the same tokens join links use)
async function listAll(limit = 500) { return impl().listAll(limit); } // QUIET (Marty 2026-11-14, "join one = join all"): a waiting account the network hub made here (carried, joinedRef 'hub') that has never
// signed in is left out of every list by default, so no sweep or mailing (updates, launch week, coach, leaderboard) reaches
// someone who never chose LinkSpin. { shells: true } includes them (spam scan, sponsor follow). Same rule as InstantAdPay's.
const isHubShell = a => !!a && a.joinedVia === 'carried' && a.joinedRef === 'hub' && !a.lastSeen && !a.memberId; // made by hubsync.js
async function listAll(limit = 500, opts) { if (opts && opts.shells) return impl().listAll(limit); const all = await impl().listAll(Math.max(limit, 1e7)); return all.filter(a => !isHubShell(a)).slice(0, limit); }
async function setSponsorRef(email, ref) { return impl().setSponsorRef(normEmail(email), String(ref || '').trim().toLowerCase().slice(0, 40)).then(tap(normEmail(email))); } async function setSponsorRef(email, ref) { return impl().setSponsorRef(normEmail(email), String(ref || '').trim().toLowerCase().slice(0, 40)).then(tap(normEmail(email))); }
// resolve a member's DIRECT sponsor account (the token they joined under) // resolve a member's DIRECT sponsor account (the token they joined under)
@@ -484,12 +499,14 @@ async function getChatSettings(email) {
return { available: a ? a.chatAvailable !== false : true, mutes: await impl().getMutes(String(email || '').toLowerCase()) }; return { available: a ? a.chatAvailable !== false : true, mutes: await impl().getMutes(String(email || '').toLowerCase()) };
} }
module.exports = { init, signup, login, ensure, onChange, byEmail, byAddress, byCode, byUsername, byMemberId: id => impl().byMemberId(Number(id) || 0), listAll, setSponsorRef, module.exports = { /* member erase (erase.js, 2026-11-15): the live copy */ _json: { state: () => J.db, save: () => J.save() }, init, signup, login, ensure, onChange, byEmail, byAddress, byCode, byUsername, byMemberId: id => impl().byMemberId(Number(id) || 0), listAll, setSponsorRef,
setUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, onWalletLinked, count, setUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, onWalletLinked, count,
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t), setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j), setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j),
setProfile: (e, a, bio, socials) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials).then(tap(String(e || '').toLowerCase())), setProfile: (e, a, bio, socials, quarantined) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials, quarantined).then(tap(String(e || '').toLowerCase())),
touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()), touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()),
setFounder: (e, ts) => impl().setFounder(String(e || '').toLowerCase(), ts), // cosmetic Founder flag (launchweek.js); no onChange tap
setTheme: (e, t) => impl().setTheme(String(e || '').toLowerCase(), t), // appearance only: no onChange tap, InstantAdPay does not mirror it
adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null).then(tap(String(e || '').toLowerCase())), adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null).then(tap(String(e || '').toLowerCase())),
positionByAddress: a => impl().positionByAddress(normAddr(a)), positionByAddress: a => impl().positionByAddress(normAddr(a)),
removeAccount: e => impl().removeAccount(String(e || '').toLowerCase()), removeAccount: e => impl().removeAccount(String(e || '').toLowerCase()),
+41
View File
@@ -0,0 +1,41 @@
// Admin action log (Marty 2026-11-16, "a named, logged admin route"): who did what, to what, and when, for admin routes that
// change a member's things on their behalf (first user: /api/admin/house-spins). One row per call, denied calls included.
// With MySQL (production) the rows live in table admin_audit; without it (local copies, QA) in DATA_DIR/admin-audit.jsonl.
// Never holds a secret: callers pass a short summary, and anything that looks like a key or password is masked here too.
// record({ who, action, target, ok, detail, ip }) list(limit) -> newest first
'use strict';
const fs = require('fs');
const path = require('path');
const db = require('./db');
let DATA_DIR = null, made = false;
function init(opts) { DATA_DIR = opts.dataDir; }
const FILE = () => path.join(DATA_DIR, 'admin-audit.jsonl');
const clip = (s, n) => String(s == null ? '' : s).slice(0, n);
// a value under a key like token/secret/password/key never lands in the log
const scrub = o => JSON.parse(JSON.stringify(o == null ? null : o, (k, v) => (/pass|secret|token|apikey|api_key|authorization/i.test(k) ? '[masked]' : v)));
async function table() {
if (made) return;
await db.q(`CREATE TABLE IF NOT EXISTS admin_audit (
id BIGINT AUTO_INCREMENT PRIMARY KEY, ts BIGINT NOT NULL, who VARCHAR(190) NOT NULL, action VARCHAR(80) NOT NULL,
target VARCHAR(190) NOT NULL DEFAULT '', ok TINYINT NOT NULL DEFAULT 1, ip VARCHAR(64) NOT NULL DEFAULT '', detail MEDIUMTEXT,
KEY ts (ts), KEY action (action)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
made = true;
}
async function record(e) {
const row = { ts: Date.now(), who: clip(e.who || 'unknown', 190), action: clip(e.action, 80), target: clip(e.target, 190), ok: e.ok === false ? 0 : 1, ip: clip(e.ip, 64), detail: clip(JSON.stringify(scrub(e.detail)), 60000) };
try {
if (db.enabled()) { await table(); await db.q('INSERT INTO admin_audit (ts, who, action, target, ok, ip, detail) VALUES (?, ?, ?, ?, ?, ?, ?)', [row.ts, row.who, row.action, row.target, row.ok, row.ip, row.detail]); }
else fs.appendFileSync(FILE(), JSON.stringify(row) + '\n');
return true;
} catch (er) { console.error('adminaudit', er.message); return false; }
}
async function list(limit) {
const n = Math.max(1, Math.min(500, Number(limit) || 100));
const parse = r => Object.assign({}, r, { ts: Number(r.ts), ok: !!Number(r.ok), detail: (() => { try { return JSON.parse(r.detail); } catch (e) { return r.detail; } })() });
if (db.enabled()) { await table(); return (await db.q('SELECT id, ts, who, action, target, ok, ip, detail FROM admin_audit ORDER BY id DESC LIMIT ?', [n])).map(parse); }
let lines = []; try { lines = fs.readFileSync(FILE(), 'utf8').split('\n').filter(Boolean); } catch (e) {}
return lines.slice(-n).reverse().map(l => { try { return parse(JSON.parse(l)); } catch (e) { return null; } }).filter(Boolean);
}
module.exports = { init, record, list };
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -105,4 +105,4 @@ function matcher(req) { const vid = cookieVid(req), soft = softKey(req); return
// admin Member content (2026-10-18): the audiences members made by hand (every member has an automatic one, not listed) // admin Member content (2026-10-18): the audiences members made by hand (every member has an automatic one, not listed)
function adminAll() { return Object.values(load().audiences).filter(a => !a.auto).map(a => Object.assign({}, a, sizes(a.id))); } function adminAll() { return Object.values(load().audiences).filter(a => !a.auto).map(a => Object.assign({}, a, sizes(a.id))); }
module.exports = { init, adminAll, list, create, rename, remove, owns, get, nameOf, defaultFor, hit, has, prune, flush, isId, cleanEvent, cookieVid, newVid, cookieHeader, softKey, matcher }; module.exports = { /* member erase (erase.js, 2026-11-15): the live copy */ _state: () => load(), _save: () => { save(); flush(); }, init, adminAll, list, create, rename, remove, owns, get, nameOf, defaultFor, hit, has, prune, flush, isId, cleanEvent, cookieVid, newVid, cookieHeader, softKey, matcher };
+29 -8
View File
@@ -15,7 +15,14 @@ let IS_PROD = false;
let SITE = SITE_HOST; let SITE = SITE_HOST;
const CHALLENGE_TTL = 10 * 60 * 1000; const CHALLENGE_TTL = 10 * 60 * 1000;
const SESSION_TTL = 24 * 60 * 60 * 1000; // 24h — forces a daily re-login so the login ad shows each day // Marty 2026-10-26: same as InstantAdPay, a session lasts 4 hours (SESSION_TTL_HOURS), then sign in again.
// Sessions minted under the old 24 h rule are cut back to issue time + the new length (cap below).
const SESSION_TTL = Number(process.env.SESSION_TTL_HOURS || 4) * 60 * 60 * 1000;
const LEGACY_TTL = 24 * 60 * 60 * 1000;
// new sessions carry `issued`; a stored session without it is a legacy 24 h one: its real end is issue time + SESSION_TTL
const sessEnd = s => (s.issued ? Number(s.expires) : Number(s.expires) - LEGACY_TTL + SESSION_TTL);
// MySQL mode has no issued column: cap anything with more than SESSION_TTL left (best effort; production uses the JSON store)
const capExp = exp => (Number(exp) - Date.now() > SESSION_TTL ? Number(exp) - LEGACY_TTL + SESSION_TTL : Number(exp));
const challenges = new Map(); // addressLower -> {message, exp} const challenges = new Map(); // addressLower -> {message, exp}
// ---- JSON session fallback ---- // ---- JSON session fallback ----
@@ -38,13 +45,13 @@ const J = {
async mint(fields) { async mint(fields) {
const token = crypto.randomBytes(32).toString('hex'); const token = crypto.randomBytes(32).toString('hex');
this.sessions.set(token, Object.assign({ email: null, address: null, memberId: 0 }, fields, this.sessions.set(token, Object.assign({ email: null, address: null, memberId: 0 }, fields,
{ expires: Date.now() + SESSION_TTL })); { issued: Date.now(), expires: Date.now() + SESSION_TTL }));
this.save(); this.save();
return token; return token;
}, },
async get(token) { async get(token) {
const s = this.sessions.get(token); const s = this.sessions.get(token);
if (!s || s.expires < Date.now()) return null; if (!s || sessEnd(s) < Date.now()) return null;
return Object.assign({ token }, s); return Object.assign({ token }, s);
}, },
async update(token, fields) { async update(token, fields) {
@@ -53,7 +60,9 @@ const J = {
this.sessions.set(token, Object.assign({}, s, fields)); this.sessions.set(token, Object.assign({}, s, fields));
this.save(); this.save();
}, },
async drop(token) { this.sessions.delete(token); this.save(); } async drop(token) { this.sessions.delete(token); this.save(); },
async renew(token) { const s = this.sessions.get(token); if (!s) return; s.expires = Date.now() + SESSION_TTL; s.issued = Date.now(); this.save(); },
async dropBy(email, address) { let n = 0; for (const [t, s] of this.sessions) if ((email && s.email === email) || (address && String(s.address || '').toLowerCase() === address)) { this.sessions.delete(t); n++; } if (n) this.save(); return n; }
}; };
// ---- MySQL session mode ---- // ---- MySQL session mode ----
@@ -68,6 +77,7 @@ const D = {
const rows = await db.q('SELECT * FROM sessions WHERE token=? AND expires>?', [token, Date.now()]); const rows = await db.q('SELECT * FROM sessions WHERE token=? AND expires>?', [token, Date.now()]);
if (!rows.length) return null; if (!rows.length) return null;
const r = rows[0]; const r = rows[0];
if (capExp(r.expires) < Date.now()) return null;
return { token, email: r.email, address: r.address, memberId: r.member_id, expires: Number(r.expires) }; return { token, email: r.email, address: r.address, memberId: r.member_id, expires: Number(r.expires) };
}, },
async update(token, fields) { async update(token, fields) {
@@ -79,7 +89,9 @@ const D = {
vals.push(token); vals.push(token);
await db.q('UPDATE sessions SET ' + sets.join(',') + ' WHERE token=?', vals); await db.q('UPDATE sessions SET ' + sets.join(',') + ' WHERE token=?', vals);
}, },
async drop(token) { await db.q('DELETE FROM sessions WHERE token=?', [token]); } async drop(token) { await db.q('DELETE FROM sessions WHERE token=?', [token]); },
async renew(token) { await db.q('UPDATE sessions SET expires=? WHERE token=?', [Date.now() + SESSION_TTL, token]); },
async dropBy(email, address) { const r = await db.q('DELETE FROM sessions WHERE ' + (email && address ? 'email=? OR LOWER(address)=?' : email ? 'email=?' : 'LOWER(address)=?'), [email, address].filter(Boolean)); return Number(r.affectedRows || 0); }
}; };
const impl = () => db.enabled() ? D : J; const impl = () => db.enabled() ? D : J;
@@ -138,13 +150,21 @@ async function verifyChallenge(address, signature) {
async function mintSession(fields) { return impl().mint(fields || {}); } async function mintSession(fields) { return impl().mint(fields || {}); }
async function updateSession(token, fields) { return impl().update(token, fields || {}); } async function updateSession(token, fields) { return impl().update(token, fields || {}); }
function sessionCookie(token) { function sessionCookie(token) {
return `iap.sid=${encodeURIComponent(token)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${SESSION_TTL / 1000}${IS_PROD ? '; Secure' : ''}`; return `iap.sid=${encodeURIComponent(token)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${Math.max(SESSION_TTL / 1000, 30 * 86400)}${IS_PROD ? '; Secure' : ''}`; // the cookie outlives the session; the server's sliding expiry decides (2026-11-15)
} }
function clearCookie() { return 'iap.sid=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0'; } function clearCookie() { return 'iap.sid=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0'; }
// onSeen (2026-10-26): told the email + request of every resolved session (conversion tracking keeps the soft keys a member
// signs in from, so their own clicks count as tests). Never throws into the caller.
let seenFn = null; function onSeen(fn) { seenFn = fn; }
async function fromRequest(req) { async function fromRequest(req) {
const m = /(?:^|;\s*)iap\.sid=([^;]+)/.exec(req.headers.cookie || ''); const m = /(?:^|;\s*)iap\.sid=([^;]+)/.exec(req.headers.cookie || '');
if (!m) return null; if (!m) return null;
return impl().get(decodeURIComponent(m[1])); const s = await impl().get(decodeURIComponent(m[1]));
// renewed on use (2026-11-15, the network hub era: sessions are SESSION_TTL_HOURS long, 168 = 7 days, and slide while the member
// is active; the login ad keeps its own clock, loginadclock.js). At most one write an hour per session.
if (s && Number(s.expires) && Number(s.expires) - Date.now() < SESSION_TTL - Math.min(3600000, SESSION_TTL / 4)) { try { await impl().renew(s.token || decodeURIComponent(m[1])); } catch (e) {} }
if (s && s.email && seenFn) { try { seenFn(s.email, req); } catch (e) {} }
return s;
} }
async function refreshMemberId(sess) { async function refreshMemberId(sess) {
if (!sess) return 0; if (!sess) return 0;
@@ -167,4 +187,5 @@ async function logout(req) {
if (s) await impl().drop(s.token); if (s) await impl().drop(s.token);
} }
module.exports = { init, makeChallenge, verifyChallenge, mintSession, updateSession, sessionCookie, clearCookie, fromRequest, refreshMemberId, logout }; async function endSessions(email, address) { return impl().dropBy(email ? String(email).toLowerCase() : null, address ? String(address).toLowerCase() : null); } // hub: blocked, erased, signed out everywhere
module.exports = { endSessions, init, makeChallenge, verifyChallenge, mintSession, updateSession, sessionCookie, clearCookie, fromRequest, onSeen, refreshMemberId, logout };
+47 -9
View File
@@ -21,6 +21,8 @@
// reloads count once per minute per banner. Clicks are rows like spin-link clicks, with the usual lsid click id // reloads count once per minute per banner. Clicks are rows like spin-link clicks, with the usual lsid click id
// ('k' + 11 hex, never valid hex so it can never collide with a rotator id), so joins / wallets / purchases and partner // ('k' + 11 hex, never valid hex so it can never collide with a rotator id), so joins / wallets / purchases and partner
// postbacks credit the banner (rotator.convert falls through to convert() here), and a traffic source's postback fires. // postbacks credit the banner (rotator.convert falls through to convert() here), and a traffic source's postback fires.
// Since 2026-10-26 a click that goes straight to a page also gets ?lsclk=<click id> when the owner tracks goals, so the
// conversion pixel (convtrack.js, clickById below) counts goals from Banner Spin banners that skip a spin link.
// //
// Access. Members with at least one own package of $25 or more. Starter 2 Banner Spins x 5 banners; Builder (level 2 // Access. Members with at least one own package of $25 or more. Starter 2 Banner Spins x 5 banners; Builder (level 2
// open, 2 qualifying buyers) 5 x 15; Leader (level 3 open, 5 qualifying buyers) 10 x 25. Facts come from server.js // open, 2 qualifying buyers) 5 x 15; Leader (level 3 open, 5 qualifying buyers) 10 x 25. Facts come from server.js
@@ -49,7 +51,7 @@ const TIERS = {
}; };
const ORDER = ['starter', 'builder', 'leader']; const ORDER = ['starter', 'builder', 'leader'];
const MAX_BYTES = 150 * 1024, MAX_BANNERS = 25; const MAX_BYTES = 150 * 1024, MAX_BANNERS = 25;
const NOTE_TTL = 15 * 60000, DEDUPE_MS = 60000, FLUSH_MS = 5000, UNIQ_CAP = 500, HOSTS_CAP = 200; const NOTE_TTL = 60 * 60000, DEDUPE_MS = 60000, FLUSH_MS = 5000, UNIQ_CAP = 500, HOSTS_CAP = 200;
const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i; const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i;
const norm = e => String(e || '').trim().toLowerCase(); const norm = e => String(e || '').trim().toLowerCase();
const CT_FMT = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' }); const CT_FMT = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' });
@@ -68,10 +70,14 @@ const J = { db: null, FILE: () => path.join(DATA_DIR, 'bannerspin.json'),
const C = { db: { v: 1, d: {} }, FILE: () => path.join(DATA_DIR, 'bannerspin-counts.json'), const C = { db: { v: 1, d: {} }, FILE: () => path.join(DATA_DIR, 'bannerspin-counts.json'),
read() { try { const x = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); return x && x.d ? x : { v: 1, d: {} }; } catch (e) { return { v: 1, d: {} }; } } }; read() { try { const x = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); return x && x.d ? x : { v: 1, d: {} }; } catch (e) { return { v: 1, d: {} }; } } };
let PENDING = { d: {} }, DIRTY = false, timer = null, lastPrune = 0; let PENDING = { d: {} }, DIRTY = false, timer = null, lastPrune = 0;
// conversion pixel (2026-10-26): a click that goes straight to a page (not a spin link) gets ?lsclk=<this click id> when
// the owner tracks goals, the same rule spin links follow. server.js hands in the goal check and convtrack's string insert.
let WANTS_CLICK_ID = () => false, WITH_CLICK_ID = (u) => u;
function init(opts) { function init(opts) {
DATA_DIR = opts.dataDir; UPLOADS_DIR = opts.uploadsDir || path.join(DATA_DIR, 'uploads'); rotator = opts.rotator || null; geo = opts.geo || null; SOURCES = opts.sources || null; DATA_DIR = opts.dataDir; UPLOADS_DIR = opts.uploadsDir || path.join(DATA_DIR, 'uploads'); rotator = opts.rotator || null; geo = opts.geo || null; SOURCES = opts.sources || null;
OWN_HOSTS = opts.ownHosts || OWN_HOSTS; FACTS = opts.facts || FACTS; ADMIN = norm(opts.adminEmail); OWN_HOSTS = opts.ownHosts || OWN_HOSTS; FACTS = opts.facts || FACTS; ADMIN = norm(opts.adminEmail);
if (opts.wantsClickId) WANTS_CLICK_ID = opts.wantsClickId; if (opts.withClickId) WITH_CLICK_ID = opts.withClickId;
J.load(); C.db = C.read(); J.load(); C.db = C.read();
if (opts.schedule !== false) { timer = setInterval(() => { flush(); sweep(); }, FLUSH_MS); if (timer.unref) timer.unref(); } if (opts.schedule !== false) { timer = setInterval(() => { flush(); sweep(); }, FLUSH_MS); if (timer.unref) timer.unref(); }
} }
@@ -86,6 +92,12 @@ const ipOf = req => String(req.headers['x-forwarded-for'] || (req.socket && req.
const vkey = (req, ts) => crypto.createHash('sha256').update(new Date(ts || Date.now()).toISOString().slice(0, 10) + '|' + ipOf(req) + '|' + String(req.headers['user-agent'] || '')).digest('hex').slice(0, 16); const vkey = (req, ts) => crypto.createHash('sha256').update(new Date(ts || Date.now()).toISOString().slice(0, 10) + '|' + ipOf(req) + '|' + String(req.headers['user-agent'] || '')).digest('hex').slice(0, 16);
// keys to try for a click: today's, and yesterday's for the first 15 minutes after UTC midnight (a note made at 23:59 still matches) // keys to try for a click: today's, and yesterday's for the first 15 minutes after UTC midnight (a note made at 23:59 still matches)
function vkeys(req) { const now = Date.now(); const k = [vkey(req, now)]; if (now % DAY < NOTE_TTL) k.push(vkey(req, now - DAY)); return k; } function vkeys(req) { const now = Date.now(); const k = [vkey(req, now)]; if (now % DAY < NOTE_TTL) k.push(vkey(req, now - DAY)); return k; }
// Second chance for a click (Michael Camire 2026-11-14: 3 clicks on his Banner Spin, every one unmatched, so no banner got
// credit): the same daily-salted hash WITHOUT the browser. A mail app or a traffic-exchange app shows the image in its own
// viewer and opens the click in the phone's or PC's browser: same IP, different user agent, so the full key never matches.
// Only used when the full key finds nothing; the most recent view of this Banner Spin from that IP wins.
const ipkey = (req, ts) => 'i' + crypto.createHash('sha256').update(new Date(ts || Date.now()).toISOString().slice(0, 10) + '|ip|' + ipOf(req)).digest('hex').slice(0, 15);
function ipkeys(req) { if (!ipOf(req)) return []; const now = Date.now(); const k = [ipkey(req, now)]; if (now % DAY < NOTE_TTL) k.push(ipkey(req, now - DAY)); return k; }
const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT.test(ua); }; const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT.test(ua); };
const isPrefetch = req => /prefetch|prerender|preview/i.test([req.headers.purpose, req.headers['sec-purpose'], req.headers['x-purpose'], req.headers['x-moz']].filter(Boolean).join(' ')); const isPrefetch = req => /prefetch|prerender|preview/i.test([req.headers.purpose, req.headers['sec-purpose'], req.headers['x-purpose'], req.headers['x-moz']].filter(Boolean).join(' '));
// a server fetching the image, not a browser (phase 3, 2026-10-20): mail image proxies and plain HTTP libraries. Kept out of // a server fetching the image, not a browser (phase 3, 2026-10-20): mail image proxies and plain HTTP libraries. Kept out of
@@ -193,8 +205,9 @@ function pub(s, extra) {
} }
async function list(owner) { return mine(owner).map(s => pub(s)); } async function list(owner) { return mine(owner).map(s => pub(s)); }
async function create(owner, body) { async function create(owner, body) {
// the owner (ADMIN_EMAIL) has no Banner Spin count cap (Marty 2026-11-09, same as the upload exemption); members keep their tier's count
const t = await tierFor(owner); if (!t.ok) return { error: t.reason, tier: t }; const t = await tierFor(owner); if (!t.ok) return { error: t.reason, tier: t };
if (mine(owner).length >= t.spins) return { error: 'Your ' + t.label + ' tier holds ' + t.spins + ' Banner Spins.' + (t.next ? ' ' + t.next.label + ' (' + t.next.need + ') holds ' + t.next.spins + '.' : ''), tier: t }; if (!(ADMIN && norm(owner) === ADMIN) && mine(owner).length >= t.spins) return { error: 'Your ' + t.label + ' tier holds ' + t.spins + ' Banner Spins.' + (t.next ? ' ' + t.next.label + ' (' + t.next.need + ') holds ' + t.next.spins + '.' : ''), tier: t };
const name = String(body.name || '').trim().slice(0, 80); if (!name) return { error: 'Give the Banner Spin a name.' }; const name = String(body.name || '').trim().slice(0, 80); if (!name) return { error: 'Give the Banner Spin a name.' };
const size = String(body.size || ''); if (!SIZES[size]) return { error: 'Pick one of the sizes: ' + Object.keys(SIZES).join(', ') + '.' }; const size = String(body.size || ''); if (!SIZES[size]) return { error: 'Pick one of the sizes: ' + Object.keys(SIZES).join(', ') + '.' };
const s = { id: J.db.spins.reduce((m, x) => Math.max(m, x.id), 0) + 1, owner: norm(owner), name, code: newCode(), size, mode: body.mode === 'visitor' ? 'visitor' : 'weight', fallback: httpsUrl(body.fallback) || '', fallbackImage: '', banners: [], nextBanner: 1, paused: false, created: Date.now() }; const s = { id: J.db.spins.reduce((m, x) => Math.max(m, x.id), 0) + 1, owner: norm(owner), name, code: newCode(), size, mode: body.mode === 'visitor' ? 'visitor' : 'weight', fallback: httpsUrl(body.fallback) || '', fallbackImage: '', banners: [], nextBanner: 1, paused: false, created: Date.now() };
@@ -272,7 +285,7 @@ function choose(s, req, opts) {
const kind = loaderKind(req); rawLoad(String(s.id), hostOf(req), v, kind); const kind = loaderKind(req); rawLoad(String(s.id), hostOf(req), v, kind);
if (!kind) { if (!kind) {
const bid = b ? b.id : 0; const host = hostOf(req); const bid = b ? b.id : 0; const host = hostOf(req);
note(v, s.id, host, bid); note(v, s.id, host, bid); if (ipOf(req)) note(ipkey(req), s.id, host, bid);
const k = v + '|' + s.id + '|' + bid; const last = SEEN.get(k); const k = v + '|' + s.id + '|' + bid; const last = SEEN.get(k);
if (!last || Date.now() - last >= DEDUPE_MS) { SEEN.set(k, Date.now()); bump(String(s.id), bid, host, v); } if (!last || Date.now() - last >= DEDUPE_MS) { SEEN.set(k, Date.now()); bump(String(s.id), bid, host, v); }
} }
@@ -306,7 +319,7 @@ async function click(code, req, reqHost) {
let b = null, m = 'none'; let b = null, m = 'none';
if (!live() || s.adminOff) m = 'off'; if (!live() || s.adminOff) m = 'off';
else if (xs != null && /^\d{1,4}$/.test(xs)) { b = Number(xs) ? s.banners.find(q => q.id === Number(xs) && !q.adminOff) || null : null; m = 'exact'; } else if (xs != null && /^\d{1,4}$/.test(xs)) { b = Number(xs) ? s.banners.find(q => q.id === Number(xs) && !q.adminOff) || null : null; m = 'exact'; }
else { const n = findNote(keys, s.id, h); if (n) { b = n.b ? s.banners.find(q => q.id === n.b && !q.adminOff) || null : null; m = 'note'; } } else { let n = findNote(keys, s.id, h), how = 'note'; if (!n) { n = findNote(ipkeys(req), s.id, h); how = 'ip'; } if (n) { b = n.b ? s.banners.find(q => q.id === n.b && !q.adminOff) || null : null; m = how; } }
// where to: the banner's target (its spin link, on the same link domain), else the fallback // where to: the banner's target (its spin link, on the same link domain), else the fallback
let url = null; let url = null;
if (b) { if (b.link) { const r = rotator && rotator.rawRotations ? rotator.rawRotations().find(x => x.id === b.link && x.owner === s.owner) : null; url = r ? 'https://' + (reqHost || 'linkspin.app') + '/r/' + r.code : null; } else url = b.target; } if (b) { if (b.link) { const r = rotator && rotator.rawRotations ? rotator.rawRotations().find(x => x.id === b.link && x.owner === s.owner) : null; url = r ? 'https://' + (reqHost || 'linkspin.app') + '/r/' + r.code : null; } else url = b.target; }
@@ -324,17 +337,31 @@ async function click(code, req, reqHost) {
for (const [k, val] of Object.entries(q)) if (vals[k] == null) vals[k] = val; for (const [k, val] of Object.entries(q)) if (vals[k] == null) vals[k] = val;
url = url.replace(/\{([a-z0-9_]{1,24})\}/gi, (mm, k) => encodeURIComponent(vals[k.toLowerCase()] == null ? '' : vals[k.toLowerCase()])); url = url.replace(/\{([a-z0-9_]{1,24})\}/gi, (mm, k) => encodeURIComponent(vals[k.toLowerCase()] == null ? '' : vals[k.toLowerCase()]));
try { const t = new URL(url); if (OWN_HOSTS().includes(t.hostname.toLowerCase()) && !t.searchParams.has('lsid') && !/^\/r\//.test(t.pathname)) { t.searchParams.set('lsid', id); url = t.toString(); } } catch (e) {} try { const t = new URL(url); if (OWN_HOSTS().includes(t.hostname.toLowerCase()) && !t.searchParams.has('lsid') && !/^\/r\//.test(t.pathname)) { t.searchParams.set('lsid', id); url = t.toString(); } } catch (e) {}
// straight to a page: the click id rides along for the landing tag (a spin-link target adds its own on the /r/ hop)
if (!bot) { let spinHop = false; try { spinHop = /^\/r\/[a-z0-9]{4,12}$/i.test(new URL(url).pathname); } catch (e) {} if (!spinHop) { try { if (WANTS_CLICK_ID(s.owner, url)) url = WITH_CLICK_ID(url, id); } catch (e) {} } }
} }
return { url, lsid: id, banner: b, matched: m }; return { url, lsid: id, banner: b, matched: m, owner: s.owner };
}
// conversion pixel (2026-10-26): a Banner Spin click by id, with its Banner Spin, banner and where it went
function clickById(id) {
id = String(id || ''); if (!/^k[a-f0-9]{11}$/.test(id)) return null;
const list = J.db.clicks; let c = null; for (let i = list.length - 1; i >= 0; i--) if (list[i].id === id) { c = list[i]; break; }
if (!c) return null;
const s = J.db.spins.find(x => x.id === c.s); if (!s) return null;
const b = c.b ? s.banners.find(x => x.id === c.b) || null : null;
return { click: c, owner: s.owner, spin: { id: s.id, code: s.code, name: s.name || '' }, banner: b ? { id: b.id, label: b.label || '' } : null, destUrl: b && !b.link ? (b.target || '') : (b ? '' : (s.fallback || '')) };
} }
// conversions (rotator.convert falls through to here for a 'k' click id): dedupe per click + event // conversions (rotator.convert falls through to here for a 'k' click id): dedupe per click + event
async function convert(lsid, ev, facts) { async function convert(lsid, ev, facts) {
const c = J.db.clicks.find(x => x.id === String(lsid)); if (!c) return null; const c = J.db.clicks.find(x => x.id === String(lsid)); if (!c) return null;
const s = J.db.spins.find(x => x.id === c.s); if (!s) return null; const s = J.db.spins.find(x => x.id === c.s); if (!s) return null;
if (!J.db.conv.some(x => x.lsid === c.id && x.ev === ev)) { J.db.conv.push({ lsid: c.id, s: s.id, b: c.b, ev, ts: Date.now(), value: Number(facts && facts.payout || 0) || 0, label: facts && facts.label ? String(facts.label).slice(0, 40) : undefined, sr: c.sr || undefined }); if (J.db.conv.length > 100000) J.db.conv = J.db.conv.slice(-80000); J.save(); } if (!J.db.conv.some(x => x.lsid === c.id && x.ev === ev)) { J.db.conv.push({ lsid: c.id, s: s.id, b: c.b, ev, ts: Date.now(), value: Number(facts && facts.payout || 0) || 0, label: facts && facts.label ? String(facts.label).slice(0, 40) : undefined, sr: c.sr || undefined, key: facts && facts.key ? String(facts.key) : undefined }); if (J.db.conv.length > 100000) J.db.conv = J.db.conv.slice(-80000); J.save(); }
return { owner: s.owner, code: s.code, rotationId: 0, bannerSpinId: s.id, bannerId: c.b, q: c.q || {}, s: c.h || 'direct', c: c.c || '', dv: c.dv, sourceId: c.sr || '' }; return { owner: s.owner, code: s.code, rotationId: 0, bannerSpinId: s.id, bannerId: c.b, q: c.q || {}, s: c.h || 'direct', c: c.c || '', dv: c.dv, sourceId: c.sr || '' };
} }
// a member's Banner Spin conversions as rows (netconv.unified); rows with a key are the ledger's and are skipped there
function convRows(owner, since) { const ids = new Set(J.db.spins.filter(x => x.owner === String(owner || '').trim().toLowerCase()).map(x => x.id)); return J.db.conv.filter(c => ids.has(c.s) && c.ts >= since); }
// ── stats (phase 3, 2026-10-20): one aggregation for the builder's Stats tab and the Reports screen ── // ── stats (phase 3, 2026-10-20): one aggregation for the builder's Stats tab and the Reports screen ──
// Views are the counted impressions (bots, prefetches and servers left out); bots and server loads are reported beside // Views are the counted impressions (bots, prefetches and servers left out); bots and server loads are reported beside
// them. Clicks are rows (bots flagged), so day / country / device come from human clicks, the same way spin links report. // them. Clicks are rows (bots flagged), so day / country / device come from human clicks, the same way spin links report.
@@ -362,7 +389,7 @@ function agg(spins, sinceTs) {
if (!ids.has(c.s) || (sinceTs && c.ts < sinceTs)) continue; if (!ids.has(c.s) || (sinceTs && c.ts < sinceTs)) continue;
const dd = at(days, ctDay(c.ts)); const dd = at(days, ctDay(c.ts));
if (c.bot) { T.botClicks++; dd.botClicks++; continue; } if (c.bot) { T.botClicks++; dd.botClicks++; continue; }
const ok = c.m === 'exact' || c.m === 'note'; const ok = c.m === 'exact' || c.m === 'note' || c.m === 'ip';
for (const o of [at(per, c.s + ':' + c.b), at(hosts, c.h || '(none)'), dd, T]) { o.clicks++; if (ok) o.matched++; else if (c.m === 'none') o.unmatched++; } for (const o of [at(per, c.s + ':' + c.b), at(hosts, c.h || '(none)'), dd, T]) { o.clicks++; if (ok) o.matched++; else if (c.m === 'none') o.unmatched++; }
const k = c.c || '(none)'; country[k] = (country[k] || 0) + 1; const dv = c.dv || '(none)'; device[dv] = (device[dv] || 0) + 1; const k = c.c || '(none)'; country[k] = (country[k] || 0) + 1; const dv = c.dv || '(none)'; device[dv] = (device[dv] || 0) + 1;
} }
@@ -398,7 +425,9 @@ async function stats(owner, id) {
const win = winnerOf(banners.filter(b => b.active)); for (const b of banners) b.winner = b.id === win; const win = winnerOf(banners.filter(b => b.active)); for (const b of banners) b.winner = b.id === win;
const fb = A.per[s.id + ':0'] || z; const fb = A.per[s.id + ':0'] || z;
return { spin: pub(s), totals: { imps: A.T.imps, clicks: A.T.clicks, ctr: ctrOf(A.T), matchRate: mrOf(A.T), matched: A.T.matched, unmatched: A.T.unmatched, uniquesSampled: A.T.uniq, conversions: A.T.conv, bots: A.T.botClicks, botLoads: A.T.bots, serverLoads: A.T.srv }, return { spin: pub(s), totals: { imps: A.T.imps, clicks: A.T.clicks, ctr: ctrOf(A.T), matchRate: mrOf(A.T), matched: A.T.matched, unmatched: A.T.unmatched, uniquesSampled: A.T.uniq, conversions: A.T.conv, bots: A.T.botClicks, botLoads: A.T.bots, serverLoads: A.T.srv },
banners, winner: win, winMin: WIN_MIN, fallback: { imps: fb.imps, clicks: fb.clicks, ctr: ctrOf(fb) }, // fallback = the fallback was SHOWN (views + the clicks matched to those views); unmatched = clicks we could not tie to any view,
// listed on their own row so the banner rows + these two add up to the Banner Spin's totals
banners, winner: win, winMin: WIN_MIN, fallback: { imps: fb.imps, clicks: fb.clicks - fb.unmatched, ctr: ctrOf({ imps: fb.imps, clicks: fb.clicks - fb.unmatched }) }, unmatched: { clicks: fb.unmatched },
placements: placementRows(A.hosts), days: dayRows(A.days, ctDay(Date.now() - 30 * DAY)), country: listOf(A.country), device: listOf(A.device), placements: placementRows(A.hosts), days: dayRows(A.days, ctDay(Date.now() - 30 * DAY)), country: listOf(A.country), device: listOf(A.device),
conversions: Object.entries(A.convBy).sort((a, b) => b[1] - a[1]).map(([k, n]) => ({ k, n })) }; conversions: Object.entries(A.convBy).sort((a, b) => b[1] - a[1]).map(([k, n]) => ({ k, n })) };
} }
@@ -437,6 +466,15 @@ function settings() { return { off: !!J.db.settings.off, grants: J.db.grants };
// image files Banner Spins use, for the admin upload list (file name -> owner + where) // image files Banner Spins use, for the admin upload list (file name -> owner + where)
function imageRefs() { const out = {}; for (const s of J.db.spins) for (const im of s.banners.map(b => b.image).concat(s.fallbackImage || [])) { const m = LOCAL_IMG.exec(im || ''); if (m) out[m[1]] = { email: s.owner, where: 'Banner Spin ' + s.code }; } for (const [n, r] of Object.entries(J.db.images)) if (!out[n]) out[n] = { email: r.owner, where: '' }; return out; } function imageRefs() { const out = {}; for (const s of J.db.spins) for (const im of s.banners.map(b => b.image).concat(s.fallbackImage || [])) { const m = LOCAL_IMG.exec(im || ''); if (m) out[m[1]] = { email: s.owner, where: 'Banner Spin ' + s.code }; } for (const [n, r] of Object.entries(J.db.images)) if (!out[n]) out[n] = { email: r.owner, where: '' }; return out; }
function totals() { return { spins: J.db.spins.length, banners: J.db.spins.reduce((n, s) => n + s.banners.length, 0), clicks: J.db.clicks.length }; } function totals() { return { spins: J.db.spins.length, banners: J.db.spins.reduce((n, s) => n + s.banners.length, 0), clicks: J.db.clicks.length }; }
// site-wide figures for the daily snapshot: impressions counted today (Central day, merged counts + pending deltas),
// clicks and new Banner Spins inside the `since` window
function window24(since) {
const day = ctDay(); let imps = 0;
const add = store => { try { for (const sid of Object.keys((store && store.d) || {})) { const r = (store.d[sid] || {})[day]; if (r && r.b) for (const k of Object.keys(r.b)) imps += Number(r.b[k]) || 0; } } catch (e) {} };
add(C.db); add(PENDING);
const clicks = J.db.clicks.filter(c => c.ts >= since && !c.bot);
return { spins: J.db.spins.length, banners: J.db.spins.reduce((n, s) => n + s.banners.length, 0), created: J.db.spins.filter(s => (s.created || 0) >= since).length, impsToday: imps, clicks: clicks.length };
}
// a transparent PNG at the exact banner size, for the blank image (admin off, nothing to show); cached per size // a transparent PNG at the exact banner size, for the blank image (admin off, nothing to show); cached per size
const BLANK = new Map(); const BLANK = new Map();
@@ -463,4 +501,4 @@ const rawSpins = () => J.db.spins;
const save = () => J.save(); const save = () => J.save();
function imageSource(img) { const m = LOCAL_IMG.exec(String(img || '')); return m ? { file: path.join(UPLOADS_DIR, m[1]) } : /^https:\/\//i.test(String(img || '')) ? { url: String(img) } : null; } function imageSource(img) { const m = LOCAL_IMG.exec(String(img || '')); return m ? { file: path.join(UPLOADS_DIR, m[1]) } : /^https:\/\//i.test(String(img || '')) ? { url: String(img) } : null; }
const _test = { notes: () => NOTES, flush, vkey, cacheFlag, winnerOf }; const _test = { notes: () => NOTES, flush, vkey, cacheFlag, winnerOf };
module.exports = { init, SIZES, TIERS, MAX_BYTES, tierFor, list, create, update, addBanner, updateBanner, noteImage, dims, image, script, click, convert, stats, summary, adminAll, adminSet, setGlobal, settings, imageRefs, totals, blankPng, readImage, flush, findMine, rawSpins, save, imageSource, live, _test }; module.exports = { init, SIZES, TIERS, MAX_BYTES, tierFor, list, create, update, addBanner, updateBanner, noteImage, dims, image, script, click, clickById, convert, stats, summary, adminAll, adminSet, setGlobal, settings, imageRefs, totals, window24, blankPng, readImage, flush, findMine, rawSpins, save, imageSource, live, _test };
+5 -4
View File
@@ -4,6 +4,7 @@
// /sitemap.xml, /robots.txt. SEO per post: title, description, canonical, Open Graph, Twitter // /sitemap.xml, /robots.txt. SEO per post: title, description, canonical, Open Graph, Twitter
// card, article dates, BlogPosting JSON-LD, breadcrumb JSON-LD, internal links, related posts. // card, article dates, BlogPosting JSON-LD, breadcrumb JSON-LD, internal links, related posts.
const { SITE_URL } = require('./host'); const { SITE_URL } = require('./host');
const themehead = require('./themehead'); // light/dark theme head script (2026-11-01)
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const db = require('./db'); const db = require('./db');
@@ -97,19 +98,19 @@ async function bumpViews(slug) { try { await impl().bumpViews(slug); } catch (e)
function head(o) { function head(o) {
const url = SITE + o.path; const url = SITE + o.path;
const img = o.image ? (o.image.startsWith('http') ? o.image : SITE + o.image) : SITE + '/banners/iap-hero-1200x630.png'; const img = o.image ? (o.image.startsWith('http') ? o.image : SITE + o.image) : SITE + '/banners/iap-hero-1200x630.png';
return '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">' return '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">'
+ '<title>' + esc(o.title) + '</title><meta name="description" content="' + esc(o.desc) + '"><link rel="canonical" href="' + esc(url) + '">' + '<title>' + esc(o.title) + '</title><meta name="description" content="' + esc(o.desc) + '"><link rel="canonical" href="' + esc(url) + '">'
+ '<meta name="robots" content="index,follow,max-image-preview:large"><meta name="theme-color" content="#043b2f">' + '<meta name="robots" content="index,follow,max-image-preview:large"><meta name="theme-color" content="#043b2f">'
+ '<meta property="og:type" content="' + (o.article ? 'article' : 'website') + '"><meta property="og:site_name" content="LinkSpin"><meta property="og:title" content="' + esc(o.title) + '"><meta property="og:description" content="' + esc(o.desc) + '"><meta property="og:url" content="' + esc(url) + '"><meta property="og:image" content="' + esc(img) + '">' + '<meta property="og:type" content="' + (o.article ? 'article' : 'website') + '"><meta property="og:site_name" content="LinkSpin"><meta property="og:title" content="' + esc(o.title) + '"><meta property="og:description" content="' + esc(o.desc) + '"><meta property="og:url" content="' + esc(url) + '"><meta property="og:image" content="' + esc(img) + '">'
+ (o.article ? '<meta property="article:published_time" content="' + new Date(o.article.publishedAt || o.article.created).toISOString() + '"><meta property="article:modified_time" content="' + new Date(o.article.updated).toISOString() + '"><meta property="article:author" content="' + esc(AUTHOR) + '">' + (o.article.tags || []).map(t => '<meta property="article:tag" content="' + esc(t) + '">').join('') : '') + (o.article ? '<meta property="article:published_time" content="' + new Date(o.article.publishedAt || o.article.created).toISOString() + '"><meta property="article:modified_time" content="' + new Date(o.article.updated).toISOString() + '"><meta property="article:author" content="' + esc(AUTHOR) + '">' + (o.article.tags || []).map(t => '<meta property="article:tag" content="' + esc(t) + '">').join('') : '')
+ '<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(o.title) + '"><meta name="twitter:description" content="' + esc(o.desc) + '"><meta name="twitter:image" content="' + esc(img) + '">' + '<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(o.title) + '"><meta name="twitter:description" content="' + esc(o.desc) + '"><meta name="twitter:image" content="' + esc(img) + '">'
+ '<link rel="alternate" type="application/rss+xml" title="LinkSpin blog" href="' + SITE + '/blog/feed.xml"><link rel="icon" type="image/png" href="/logo-icon.png">' + '<link rel="alternate" type="application/rss+xml" title="LinkSpin blog" href="' + SITE + '/blog/feed.xml"><link rel="icon" type="image/png" href="/logo-icon.png">'
+ '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap"><link rel="stylesheet" href="/assets/site.css?v=20260912b">' + '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=ls20261101t">'
+ '<style>.bl{max-width:760px}.bl h1{font-size:clamp(30px,4.6vw,44px);line-height:1.12;margin:10px 0 12px}.bl .meta{color:var(--muted);font-size:14px;margin:0 0 22px}.bl .cover{width:100%;border-radius:14px;border:1px solid var(--line);margin:0 0 26px;display:block}.bl article{font-size:17.5px;line-height:1.7}.bl article p{margin:0 0 18px;max-width:68ch}.bl article h2{font-size:26px;margin:36px 0 12px}.bl article h3{font-size:20px;margin:28px 0 10px}.bl article ul,.bl article ol{margin:0 0 18px 22px;max-width:66ch}.bl article li{margin:6px 0}.bl article blockquote{border-left:4px solid var(--mint);margin:0 0 18px;padding:8px 18px;color:var(--muted);font-style:italic}.bl article img{max-width:100%;border-radius:12px;border:1px solid var(--line)}.bl article a{color:var(--mint)}.bl article pre{background:rgba(4,8,7,.6);border:1px solid var(--line);border-radius:10px;padding:14px;overflow:auto;font-size:14px}.bl article table{border-collapse:collapse;width:100%;font-size:15px}.bl article th,.bl article td{border-bottom:1px solid var(--line);padding:8px 10px;text-align:left}.tags a{display:inline-block;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);border:1px solid rgba(67,232,195,.4);border-radius:999px;padding:3px 10px;margin:0 6px 6px 0;text-decoration:none}.post-card{display:block;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:20px 22px;margin:0 0 14px;color:inherit;text-decoration:none}.post-card:hover{border-color:var(--mint)}.post-card h2{font-size:22px;margin:0 0 6px}.post-card p{margin:0;color:var(--muted);font-size:15px;max-width:70ch}.post-card .meta{margin:8px 0 0;font-size:13px}.author{display:flex;gap:14px;align-items:center;border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:36px 0 0;background:var(--panel)}.author img{width:56px;height:56px;border-radius:50%;object-fit:cover}.author b{display:block}.author span{color:var(--muted);font-size:14px}.share a{margin-right:14px;font-size:14px}.pager{display:flex;justify-content:space-between;margin:26px 0}.related{margin-top:40px}.related h3{margin-bottom:10px}</style>' + '<style>.bl{max-width:760px}.bl h1{font-size:clamp(30px,4.6vw,44px);line-height:1.12;margin:10px 0 12px}.bl .meta{color:var(--muted);font-size:14px;margin:0 0 22px}.bl .cover{width:100%;border-radius:14px;border:1px solid var(--line);margin:0 0 26px;display:block}.bl article{font-size:17.5px;line-height:1.7}.bl article p{margin:0 0 18px;max-width:68ch}.bl article h2{font-size:26px;margin:36px 0 12px}.bl article h3{font-size:20px;margin:28px 0 10px}.bl article ul,.bl article ol{margin:0 0 18px 22px;max-width:66ch}.bl article li{margin:6px 0}.bl article blockquote{border-left:4px solid var(--mint);margin:0 0 18px;padding:8px 18px;color:var(--muted);font-style:italic}.bl article img{max-width:100%;border-radius:12px;border:1px solid var(--line)}.bl article a{color:var(--mint)}.bl article pre{background:rgba(4,8,7,.6);border:1px solid var(--line);border-radius:10px;padding:14px;overflow:auto;font-size:14px}.bl article table{border-collapse:collapse;width:100%;font-size:15px}.bl article th,.bl article td{border-bottom:1px solid var(--line);padding:8px 10px;text-align:left}.tags a{display:inline-block;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);border:1px solid rgba(67,232,195,.4);border-radius:999px;padding:3px 10px;margin:0 6px 6px 0;text-decoration:none}.post-card{display:block;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:20px 22px;margin:0 0 14px;color:inherit;text-decoration:none}.post-card:hover{border-color:var(--mint)}.post-card h2{font-size:22px;margin:0 0 6px}.post-card p{margin:0;color:var(--muted);font-size:15px;max-width:70ch}.post-card .meta{margin:8px 0 0;font-size:13px}.author{display:flex;gap:14px;align-items:center;border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:36px 0 0;background:var(--panel)}.author img{width:56px;height:56px;border-radius:50%;object-fit:cover}.author b{display:block}.author span{color:var(--muted);font-size:14px}.share a{margin-right:14px;font-size:14px}.pager{display:flex;justify-content:space-between;margin:26px 0}.related{margin-top:40px}.related h3{margin-bottom:10px}</style>'
+ '</head><body><div class="wrap bl">'; + '</head><body><div class="wrap bl">';
} }
function tail() { function tail() {
return '</div><script src="/assets/common.js?v=20260914a"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>'; return '</div><script src="/assets/common.js?v=20261117nw"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
} }
const authorBox = () => '<div class="author"><img src="/logo-icon.png" alt="LinkSpin"><div><b>' + AUTHOR + '</b><span>Founder of LinkSpin and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.</span></div></div>'; const authorBox = () => '<div class="author"><img src="/logo-icon.png" alt="LinkSpin"><div><b>' + AUTHOR + '</b><span>Founder of LinkSpin and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.</span></div></div>';
const cardHtml = p => '<a class="post-card" href="/blog/' + esc(p.slug) + '">' + (p.cover ? '<img src="' + esc(p.cover) + '" alt="" loading="lazy" style="width:100%;border-radius:10px;margin:0 0 12px">' : '') + '<h2>' + esc(p.title) + '</h2><p>' + esc(p.excerpt) + '</p><p class="meta">' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '</p></a>'; const cardHtml = p => '<a class="post-card" href="/blog/' + esc(p.slug) + '">' + (p.cover ? '<img src="' + esc(p.cover) + '" alt="" loading="lazy" style="width:100%;border-radius:10px;margin:0 0 12px">' : '') + '<h2>' + esc(p.title) + '</h2><p>' + esc(p.excerpt) + '</p><p class="meta">' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '</p></a>';
@@ -153,7 +154,7 @@ function rss(posts) {
return '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>LinkSpin blog</title><link>' + SITE + '/blog</link><description>Coaching and teaching articles from Marty Bostick.</description>' + items + '</channel></rss>'; return '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>LinkSpin blog</title><link>' + SITE + '/blog</link><description>Coaching and teaching articles from Marty Bostick.</description>' + items + '</channel></rss>';
} }
function sitemap(posts) { function sitemap(posts) {
const pages = ['/', '/blog', '/whats-new', '/leaderboard', '/ledger', '/contract', '/plays', '/wallets', '/earning', '/partners', '/publishers']; const pages = ['/', '/blog', '/whats-new', '/leaderboard', '/ledger', '/contract', '/plays', '/wallets', '/earning', '/partners', '/publishers', '/refuel', '/conversion-tracking'];
const u = pages.map(p => '<url><loc>' + SITE + p + '</loc><changefreq>weekly</changefreq></url>').join('') const u = pages.map(p => '<url><loc>' + SITE + p + '</loc><changefreq>weekly</changefreq></url>').join('')
+ posts.map(p => '<url><loc>' + SITE + '/blog/' + p.slug + '</loc><lastmod>' + new Date(p.updated).toISOString().slice(0, 10) + '</lastmod><changefreq>monthly</changefreq></url>').join(''); + posts.map(p => '<url><loc>' + SITE + '/blog/' + p.slug + '</loc><lastmod>' + new Date(p.updated).toISOString().slice(0, 10) + '</lastmod><changefreq>monthly</changefreq></url>').join('');
return '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + u + '</urlset>'; return '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + u + '</urlset>';
+61 -15
View File
@@ -15,7 +15,7 @@ let ethers = null; try { ethers = require('ethers'); } catch (e) {}
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
let X = {}; // { dataDir, accounts, registry, chain, mailer, messages, siteConfig, adminEmail } let X = {}; // { dataDir, accounts, registry, chain, mailer, messages, siteConfig, adminEmail, tankGate, claim, payoutBlocked, sendActivate + now (tests) }
const DAY = 86400000; const DAY = 86400000;
const ABI = ['function activateFor(address account, uint32 sponsorId) returns (uint32)', 'function engineSigner() view returns (address)']; const ABI = ['function activateFor(address account, uint32 sponsorId) returns (uint32)', 'function engineSigner() view returns (address)'];
const norm = e => String(e || '').trim().toLowerCase(); const norm = e => String(e || '').trim().toLowerCase();
@@ -145,27 +145,25 @@ async function ensureOnChain(acct, depth, why) {
if (acct.email && isHeld(acct.email)) await waitUnheld(acct.email); if (acct.email && isHeld(acct.email)) await waitUnheld(acct.email);
if (acct.email) { try { const fresh = await X.accounts.byEmail(acct.email); if (fresh && fresh.address) acct = fresh; } catch (e) {} } if (acct.email) { try { const fresh = await X.accounts.byEmail(acct.email); if (fresh && fresh.address) acct = fresh; } catch (e) {} }
try { const id = await X.chain.memberIdByAccount(acct.address); if (id) { if (Number(acct.memberId) !== Number(id)) await X.accounts.setMemberId(acct.email, id).catch(() => {}); return id; } } catch (e) {} try { const id = await X.chain.memberIdByAccount(acct.address); if (id) { if (Number(acct.memberId) !== Number(id)) await X.accounts.setMemberId(acct.email, id).catch(() => {}); return id; } } catch (e) {}
if (!engineReady() || depth > 25) return 0; // holding tank (2026-10-27, tank.gate): no sponsor here -> align to the network sponsor first (InstantAdPay knows one);
// nobody known and this is the member's OWN plain activation (wallet linked, admin seeding) -> held for an adopter, never
// bound under the fallback. A sponsor placed on the contract because someone below them is buying is never held.
if (!acct.sponsorRef && !(Number(acct.memberId) > 0) && X.tankGate) {
let g = null; try { g = await X.tankGate(acct, { own: depth === 0 && (why === 'wallet' || !!X.seeding) }); } catch (e) { g = null; }
if (g && g.aligned) { try { const fresh = await X.accounts.byEmail(acct.email); if (fresh) acct = fresh; } catch (e) {} }
else if (g && g.hold) { logEvent({ type: 'tankHold', email: acct.email, until: g.hold.until || null }); return 0; }
}
if (!sendReady() || depth > 25) return 0;
const me = norm(acct.email); inflight.add(me); let id = 0; // binding from here: the sponsor read below is the one the contract gets const me = norm(acct.email); inflight.add(me); let id = 0; // binding from here: the sponsor read below is the one the contract gets
let sponsorId = 0, txHash = null, lastErr = null; // read after the finally below, so declared out here (inside the try they were not defined there, 2026-10-22..27)
try { try {
let sponsorId = 0;
if (acct.sponsorRef) { if (acct.sponsorRef) {
let sp = await X.accounts.byCode(acct.sponsorRef); if (!sp) sp = await X.accounts.byUsername(acct.sponsorRef); let sp = await X.accounts.byCode(acct.sponsorRef); if (!sp) sp = await X.accounts.byUsername(acct.sponsorRef);
if (sp && sp.address) sponsorId = await ensureOnChain(sp, depth + 1); if (sp && sp.address) sponsorId = await ensureOnChain(sp, depth + 1);
} }
if (!sponsorId) sponsorId = Number((X.siteConfig && X.siteConfig().defaultSponsorId) || 1) || 1; if (!sponsorId) sponsorId = Number((X.siteConfig && X.siteConfig().defaultSponsorId) || 1) || 1;
try { if (sponsorId > await X.chain.memberCount()) sponsorId = 0; } catch (e) {} // first member on a fresh contract: no catch position exists yet try { if (sponsorId > await X.chain.memberCount()) sponsorId = 0; } catch (e) {} // first member on a fresh contract: no catch position exists yet
// send with provider rotation; after ANY error re-read the chain first (2026-10-15 seed: six activations const sent = await (X.sendActivate || sendActivateFor)(acct.address, sponsorId); id = sent.id; txHash = sent.txHash; lastErr = sent.lastErr;
// mined while a 403 on the follow-up read logged them as failures and skipped their notices)
let txHash = null, lastErr = null;
for (let attempt = 0; attempt < 3 && !id; attempt++) {
try {
const w = signer(attempt); const ctr = new ethers.Contract(X.chain.getConfig().contract, ABI, w);
const tx = await ctr.activateFor(acct.address, sponsorId, { gasLimit: 160000n }); txHash = tx.hash;
await tx.wait(1);
} catch (e) { lastErr = e; }
for (let k = 0; k < 4 && !id; k++) { try { id = Number(await X.chain.memberIdByAccount(acct.address)) || 0; } catch (e) {} if (!id) await sleep(3000); }
}
} finally { if (!id) inflight.delete(me); } // on success the flag stays until the member number is saved below } finally { if (!id) inflight.delete(me); } // on success the flag stays until the member number is saved below
if (!id) { logEvent({ type: 'activateFailed', email: acct.email, error: String((lastErr && (lastErr.shortMessage || lastErr.message)) || 'not on-chain after send').slice(0, 160) }); return 0; } if (!id) { logEvent({ type: 'activateFailed', email: acct.email, error: String((lastErr && (lastErr.shortMessage || lastErr.message)) || 'not on-chain after send').slice(0, 160) }); return 0; }
logEvent({ type: 'activated', email: acct.email, id, sponsorId, tx: txHash }); logEvent({ type: 'activated', email: acct.email, id, sponsorId, tx: txHash });
@@ -176,6 +174,54 @@ async function ensureOnChain(acct, depth, why) {
await noticeActivated(acct, why); await noticeActivated(acct, why);
return id; return id;
} }
// send with provider rotation; after ANY error re-read the chain first (2026-10-15 seed: six activations
// mined while a 403 on the follow-up read logged them as failures and skipped their notices)
async function sendActivateFor(address, sponsorId) {
let id = 0, txHash = null, lastErr = null;
for (let attempt = 0; attempt < 3 && !id; attempt++) {
try {
const w = signer(attempt); const ctr = new ethers.Contract(X.chain.getConfig().contract, ABI, w);
const tx = await ctr.activateFor(address, sponsorId, { gasLimit: 160000n }); txHash = tx.hash;
await tx.wait(1);
} catch (e) { lastErr = e; }
for (let k = 0; k < 4 && !id; k++) { try { id = Number(await X.chain.memberIdByAccount(address)) || 0; } catch (e) {} if (!id) await sleep(3000); }
}
return { id, txHash, lastErr };
}
const sendReady = () => !!X.sendActivate || engineReady();
// ---- holding tank: switch payouts on the moment a tank member gets a sponsor (Marty approved 2026-10-27) ----
// An adoption (manual or the 24-hour rotation) or a network alignment gives a held member a sponsor; with a wallet linked,
// the engine activates them right away UNDER THAT SPONSOR. Strict, unlike ensureOnChain: never the fallback position.
// - already on the contract: nothing sent ({ id, already })
// - the sponsor must be on the contract (the engine places a sponsor who has a wallet first, as ensureOnChain does) and not
// on a no-payout chain; otherwise nothing is sent and the caller retries on its next tick ({ error, retry })
// - one sender across app copies: a marks claim per member per 10-minute window (deploy overlap), plus the in-process flag
// Returns { id, tx, sponsorId, sponsorEmail } when this call activated them.
async function activateAssigned(email) {
let a = await X.accounts.byEmail(email); if (!a || !a.address) return { error: 'no wallet linked', retry: false };
if (isHeld(a.email)) { await waitUnheld(a.email); a = (await X.accounts.byEmail(email)) || a; }
let onId = 0; try { onId = Number(await X.chain.memberIdByAccount(a.address)) || 0; } catch (e) { return { error: 'chain read failed', retry: true }; }
if (onId) { if (Number(a.memberId) !== onId) await X.accounts.setMemberId(a.email, onId).catch(() => {}); return { id: onId, already: true }; }
if (!a.sponsorRef) return { error: 'no sponsor yet', retry: false };
let sp = await X.accounts.byCode(a.sponsorRef); if (!sp) sp = await X.accounts.byUsername(a.sponsorRef);
if (!sp) return { error: 'sponsor ' + a.sponsorRef + ' not found', retry: true };
if (!sp.address) return { error: 'sponsor has no wallet yet', retry: true };
if (!sendReady()) return { error: 'engine not configured', retry: true };
const me = norm(a.email); if (inflight.has(me)) return { error: 'activation already in flight', retry: true };
const sponsorId = await ensureOnChain(sp, 1);
if (!sponsorId) return { error: 'sponsor not on the contract yet', retry: true };
if (X.payoutBlocked && await Promise.resolve(X.payoutBlocked(sponsorId)).catch(() => true)) return { error: 'sponsor #' + sponsorId + ' is on a no-payout chain', retry: false };
if (X.claim && !(await Promise.resolve(X.claim('tankact:' + me + ':' + Math.floor((X.now ? X.now() : Date.now()) / 600000))).catch(() => false))) return { error: 'another app copy is sending it', retry: true };
inflight.add(me); let sent = { id: 0 };
try { sent = await (X.sendActivate || sendActivateFor)(a.address, sponsorId); }
finally { if (!sent.id) inflight.delete(me); }
if (!sent.id) { logEvent({ type: 'activateFailed', email: a.email, why: 'assigned', sponsorId, error: String((sent.lastErr && (sent.lastErr.shortMessage || sent.lastErr.message)) || 'not on-chain after send').slice(0, 160) }); return { error: 'activation failed', retry: true }; }
logEvent({ type: 'activated', email: a.email, id: sent.id, sponsorId, tx: sent.txHash, why: 'assigned' });
await X.accounts.setMemberId(a.email, sent.id).catch(() => {});
inflight.delete(me);
return { id: sent.id, tx: sent.txHash || null, sponsorId, sponsorEmail: sp.email };
}
async function noticeActivated(acct, why) { async function noticeActivated(acct, why) {
const own = X.seeding || why === 'wallet'; // switched on because their own wallet arrived, not because someone below them bought const own = X.seeding || why === 'wallet'; // switched on because their own wallet arrived, not because someone below them bought
await tell(acct.email, own ? 'Your LinkSpin payouts are switched on' : 'We set up your LinkSpin position so you would not miss a payout', await tell(acct.email, own ? 'Your LinkSpin payouts are switched on' : 'We set up your LinkSpin position so you would not miss a payout',
@@ -224,4 +270,4 @@ async function seedAll(limit) {
} }
function status() { const s = state(); return { engine: engineReady(), claims: Object.values(s.claims || {}), log: (s.log || []).slice(-50).reverse(), claimDays: claimDays() }; } function status() { const s = state(); return { engine: engineReady(), claims: Object.values(s.claims || {}), log: (s.log || []).slice(-50).reverse(), claimDays: claimDays() }; }
module.exports = { init, onJoin, resolveForChain, ensureOnChain, seedAll, status, engineReady, backfillMemberIds, hold, unhold, isHeld, isBinding }; module.exports = { init, onJoin, resolveForChain, ensureOnChain, activateAssigned, seedAll, status, engineReady, backfillMemberIds, hold, unhold, isHeld, isBinding };
+271
View File
@@ -1,4 +1,275 @@
[ [
{
"key": "viralbannerblitz",
"name": "Viral Banner Blitz",
"site": "viralbannerblitz.com",
"costModel": "CPM",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
},
{
"key": "placement",
"token": "{spot}",
"label": "Banner number",
"role": "param"
},
{
"key": "s1",
"token": "{type}",
"label": "Click type (loop or waiting)",
"role": "param"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network banner loop (125x125). Post a 125x125 Banner Spin in Viral Banner Blitz > My Banners: every click fills {clickid}, {spot} (the banner number) and {type}.",
"verified": true,
"source": "network"
},
{
"key": "downlinebanners",
"name": "Downline Banners",
"site": "downlinebanners.com",
"costModel": "CPM",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
},
{
"key": "placement",
"token": "{spot}",
"label": "Spot number",
"role": "param"
},
{
"key": "s1",
"token": "{type}",
"label": "Click type (gate or organic)",
"role": "param"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network banner board. A $5 spot buys 300 guaranteed views. Paste this source's link as a spot's Target link in Downline Banners > My Spots: every click fills {clickid}, {spot} and {type}.",
"verified": true,
"source": "network"
},
{
"key": "downlinehydra",
"name": "DownlineHydra",
"site": "downlinehydra.com",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
},
{
"key": "placement",
"token": "{program}",
"label": "Program",
"role": "param"
},
{
"key": "s1",
"token": "{program}",
"label": "Program (sub-id)",
"role": "param"
}
],
"postbackUrl": "",
"notes": "DownlineHydra downline builder. Your saved referral links for outside programs (wild heads and my heads) go out as LinkSpin links: every click carries the program id as placement and s1, so Reports split them by program.",
"verified": true,
"source": "network"
},
{
"key": "instantadpay",
"name": "InstantAdPay",
"site": "instantadpay.com",
"costModel": "",
"params": [],
"postbackUrl": "",
"notes": "Crypto Team Build Network site. Clicks that arrive from InstantAdPay (its footer, its Promo tools) carry ?src=iap and are counted under this source automatically.",
"verified": true,
"source": "network"
},
{
"key": "linkspin",
"name": "LinkSpin",
"site": "linkspin.app",
"costModel": "",
"params": [],
"postbackUrl": "",
"notes": "Crypto Team Build Network site. Clicks that arrive from LinkSpin pages carry ?src=linkspin and are counted under this source automatically.",
"verified": true,
"source": "network"
},
{
"key": "viraladblitz",
"name": "ViralAdBlitz",
"site": "viraladblitz.com",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
},
{
"key": "placement",
"token": "{ad}",
"label": "Text ad",
"role": "param"
},
{
"key": "s1",
"token": "{ad}",
"label": "Text ad (sub-id)",
"role": "param"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network text-ad site. Clicks that arrive from ViralAdBlitz (its footer, its promo kit) carry ?src=viraladblitz and are counted under this source automatically. Your own ViralAdBlitz text ad goes out as a LinkSpin link on your account: every click carries the ad id as placement and s1.",
"verified": true,
"source": "network"
},
{
"key": "videoappincome",
"name": "Video App Income",
"site": "videoappincome.com",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network video maker. Clicks that arrive from Video App Income carry ?src=videoappincome and are counted under this source automatically. Sign-ups, sponsor confirmations and credit purchases on Video App Income that follow one of your link clicks are reported back and show under Reports > Conversions.",
"verified": true,
"source": "network"
},
{
"key": "socialtube",
"name": "Social Tube",
"site": "socialtube.club",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network video gallery (members' short videos made with Video App Income). Clicks that arrive from Social Tube carry ?src=socialtube and are counted under this source automatically. Sign-ups and credit purchases on Video App Income that follow one of your clicks show in Reports > Conversions.",
"verified": true,
"source": "network"
},
{
"key": "viraladsource",
"name": "ViralAdSource",
"site": "viraladsource.com",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
},
{
"key": "placement",
"token": "{ad}",
"label": "Text ad",
"role": "param"
},
{
"key": "s1",
"token": "{ad}",
"label": "Text ad (sub-id)",
"role": "param"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network text-ad site. Clicks that arrive from ViralAdSource (its footer, its promo kit) carry ?src=viraladsource and are counted under this source automatically. Your own ViralAdSource text ad goes out as a LinkSpin link on your account: every click carries the ad id as placement and s1.",
"verified": true,
"source": "network"
},
{
"key": "yourprogrambuilder",
"name": "YourProgramBuilder",
"site": "yourprogrambuilder.com",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
},
{
"key": "placement",
"token": "{packet}",
"label": "Program",
"role": "param"
},
{
"key": "s1",
"token": "{packet}",
"label": "Program (sub-id)",
"role": "param"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network program directory (the Seed Bed). Clicks that arrive from YourProgramBuilder (its footer, its promo kit) carry ?src=yourprogrambuilder and are counted under this source automatically. Your saved referral IDs there go out as LinkSpin links: every click carries the program as placement and s1.",
"verified": true,
"source": "network"
},
{
"key": "5xyourteam",
"name": "5xYourTeam",
"site": "5xyourteam.com",
"costModel": "",
"params": [],
"postbackUrl": "",
"notes": "Crypto Team Build Network team-building site. Clicks that arrive from 5xYourTeam (its footer, its promo kit) carry ?src=fivex and are counted under this source automatically.",
"verified": true,
"source": "network"
},
{
"key": "stackpol",
"name": "Stack POL",
"site": "stackpol.com",
"costModel": "",
"params": [],
"postbackUrl": "",
"notes": "Crypto Team Build Network site. Clicks that arrive from Stack POL carry ?src=stackpol and are counted under this source automatically.",
"verified": true,
"source": "network"
},
{
"key": "earnerscorner",
"name": "Earners Corner",
"site": "earnerscorner.com",
"costModel": "",
"params": [],
"postbackUrl": "",
"notes": "Crypto Team Build Network forum. Clicks that arrive from Earners Corner carry ?src=earnerscorner and are counted under this source automatically.",
"verified": true,
"source": "network"
},
{ {
"key": "7search-ppc", "key": "7search-ppc",
"name": "7Search PPC", "name": "7Search PPC",
+39
View File
@@ -1,9 +1,48 @@
[ [
{
"id": "linkspin-tour",
"group": "Start here",
"first": true,
"title": "How LinkSpin works: the whole site in one walkthrough",
"desc": "Start here. A short tour in Marty's voice: what LinkSpin is for (one link that rotates the pages you promote), then step by step: signing in with an email code, making a spin link with weights, a fallback and hours, the Share kit, pointing a link at a traffic source, reading Reports, building a page, adding a zone to your own site, and what ad packages do. Then go on to the Monthly Refuel and Conversion tracking lessons below.",
"videoUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/linkspin-tour.mp4?v=20261118a",
"posterUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/linkspin-tour.jpg?v=20261118a"
},
{ {
"id": "banner-spin", "id": "banner-spin",
"group": "Banner Spin", "group": "Banner Spin",
"title": "Banner Spin: one banner slot, a whole campaign", "title": "Banner Spin: one banner slot, a whole campaign",
"desc": "Banner Spin gives you one image address and one click address that rotate up to 25 banners, each with its own target page or spin link. Put it in one banner slot on a traffic exchange, a safelist, a forum signature or your own site once, then change the banners from your Control Room whenever you like. Nobody has to update anything on their side.\n\nWho gets it. It is a free add-on that opens with your own package of $25 or more. Starter holds 2 Banner Spins with 5 banners each. Builder (level 2 open, 2 qualifying buyers) holds 5 with 15 each. Leader (level 3 open, 5 qualifying buyers) holds 10 with 25 each. If you drop below a tier, everything you built keeps serving; you just cannot add more until you are back.\n\nStep 1, name and size. Open Links, switch to Banner Spins and press New Banner Spin. Pick one size: a slot on an exchange has one size, so every banner in a Banner Spin should be that exact size (468x60, 728x90, 300x250, 125x125, 160x600, 120x600, 336x280, 250x250 or 320x50). Set a fallback page: that is where a click goes when we cannot tell which banner the visitor saw.\n\nStep 2, add banners. Upload a JPG, PNG or GIF (animated is fine, 150 KB at most) or paste an https image address. The builder previews it at real size and warns you when it is the wrong size. Pick where a click goes: any page, or one of your own spin links, so a banner can rotate pages behind it too.\n\nStep 3, weights and mode. A banner with weight 20 shows twice as often as one with 10. Random by weight picks again on every view. One per visitor shows the same person the same banner all day, which keeps a split test clean on exchanges that reload pages. You can also give the whole Banner Spin, or one banner, its own hours.\n\nStep 4, get the code. Open Get the code and copy the embed that fits the place: the image address plus click address for exchanges, safelists and downline builders; the HTML snippet for your own site or blog; the script tag wherever scripts are allowed (it writes the banner and its own link together, so every click lands on the right target); the forum code for signatures. Every link domain answers every code, so if one domain ever has trouble you swap only the domain.\n\nWhere it will not rotate. Paid ad networks copy your image to their own servers when you upload a creative, so it freezes on one banner there: upload real banners to them instead. Gmail and some mail apps fetch images once through their own proxy, so most email readers see one banner and their clicks go to the fallback. For email, use a Banner Spin with a single banner (still tracked) and swap it when you want a change.\n\nReading the numbers. The Stats tab and the Reports screen show views, unique viewers, clicks, click rate, match rate and conversions for every banner and every placement (the page your banner sits on), by day, country and device. Bots, link previews and servers are never counted as views; they are shown on their own line. A WINNER badge appears once two or more live banners have 1,000 views each and one leads on click rate. LinkSpin never changes your weights for you: raise the winner or pause the rest when you are ready. A placement marked CACHED copies banners to its own server, so the rotation is frozen there; spend your credits elsewhere.\n\nHealth checks. Every 30 minutes LinkSpin checks each live banner: the image must load as an image of the right size, and its target must not be dead or parked. Three failures in a row pause that banner and it comes back on its own after two clean checks. The last live banner in a Banner Spin is never paused. You see the status on every banner row.\n\nTeach it forward. When someone in your line buys their first $25 package, show them this lesson and help them build their first Banner Spin with two banners for the same offer. Two weeks of numbers tell them which banner to keep.", "desc": "Banner Spin gives you one image address and one click address that rotate up to 25 banners, each with its own target page or spin link. Put it in one banner slot on a traffic exchange, a safelist, a forum signature or your own site once, then change the banners from your Control Room whenever you like. Nobody has to update anything on their side.\n\nWho gets it. It is a free add-on that opens with your own package of $25 or more. Starter holds 2 Banner Spins with 5 banners each. Builder (level 2 open, 2 qualifying buyers) holds 5 with 15 each. Leader (level 3 open, 5 qualifying buyers) holds 10 with 25 each. If you drop below a tier, everything you built keeps serving; you just cannot add more until you are back.\n\nStep 1, name and size. Open Links, switch to Banner Spins and press New Banner Spin. Pick one size: a slot on an exchange has one size, so every banner in a Banner Spin should be that exact size (468x60, 728x90, 300x250, 125x125, 160x600, 120x600, 336x280, 250x250 or 320x50). Set a fallback page: that is where a click goes when we cannot tell which banner the visitor saw.\n\nStep 2, add banners. Upload a JPG, PNG or GIF (animated is fine, 150 KB at most) or paste an https image address. The builder previews it at real size and warns you when it is the wrong size. Pick where a click goes: any page, or one of your own spin links, so a banner can rotate pages behind it too.\n\nStep 3, weights and mode. A banner with weight 20 shows twice as often as one with 10. Random by weight picks again on every view. One per visitor shows the same person the same banner all day, which keeps a split test clean on exchanges that reload pages. You can also give the whole Banner Spin, or one banner, its own hours.\n\nStep 4, get the code. Open Get the code and copy the embed that fits the place: the image address plus click address for exchanges, safelists and downline builders; the HTML snippet for your own site or blog; the script tag wherever scripts are allowed (it writes the banner and its own link together, so every click lands on the right target); the forum code for signatures. Every link domain answers every code, so if one domain ever has trouble you swap only the domain.\n\nWhere it will not rotate. Paid ad networks copy your image to their own servers when you upload a creative, so it freezes on one banner there: upload real banners to them instead. Gmail and some mail apps fetch images once through their own proxy, so most email readers see one banner and their clicks go to the fallback. For email, use a Banner Spin with a single banner (still tracked) and swap it when you want a change.\n\nReading the numbers. The Stats tab and the Reports screen show views, unique viewers, clicks, click rate, match rate and conversions for every banner and every placement (the page your banner sits on), by day, country and device. Bots, link previews and servers are never counted as views; they are shown on their own line. A WINNER badge appears once two or more live banners have 1,000 views each and one leads on click rate. LinkSpin never changes your weights for you: raise the winner or pause the rest when you are ready. A placement marked CACHED copies banners to its own server, so the rotation is frozen there; spend your credits elsewhere.\n\nHealth checks. Every 30 minutes LinkSpin checks each live banner: the image must load as an image of the right size, and its target must not be dead or parked. Three failures in a row pause that banner and it comes back on its own after two clean checks. The last live banner in a Banner Spin is never paused. You see the status on every banner row.\n\nTeach it forward. When someone in your line buys their first $25 package, show them this lesson and help them build their first Banner Spin with two banners for the same offer. Two weeks of numbers tell them which banner to keep.",
"docUrl": "/links#b" "docUrl": "/links#b"
},
{
"id": "video-spin",
"group": "Video Spin",
"title": "Video Spins: one link, all of your videos",
"desc": "A Video Spin is one short link that plays a different video each time it is opened. This lesson shows the whole thing: making one under Links, picking the videos you made on Video App Income, adding any member's video by its Social Tube address, sharing the link, reading each video's clicks, opens, plays and button taps, and putting the rotating player on a web page. Video Spins come with your tier: Starter 2 with 5 videos each, Builder 5 with 15, Leader 10 with 25.",
"docUrl": "/links#v",
"docLabel": "Open Video Spins",
"videoUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/video-spins.mp4?v=20261122a",
"posterUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/video-spins.jpg?v=20261122a"
},
{
"id": "refuel-guide",
"group": "Fuel Your Offers",
"title": "Fuel Your Offers: how the Monthly Refuel streak works",
"desc": "Refuel your ads every month and the bonus climbs. A new package of $25 or more under Credits (or $20 or more on InstantAdPay) starts your streak and sets your own refuel day. Each monthly refuel inside your window (5 days before to 5 days after your refuel day) adds bonus ad credits: +10%, +15%, +20%, then +25% from month 4. Refuel both sites in the same cycle and both get +15%, +20%, +30%, then +40%. Either site alone keeps the streak going.\n\nThe guide walks through the whole flow with a diagram: Pit Stops, the one free miss a year, the Refuel Kit that loads into your Banner Spin, the Engine Room on Ads, and the reminders. Bonus credits buy ad delivery only; they are never cash.",
"docUrl": "/refuel",
"docLabel": "Read the guide",
"videoUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/refuel-ls.mp4?v=20261024",
"posterUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/refuel-ls.jpg?v=20261024"
},
{
"id": "conversion-guide",
"group": "Track your results",
"title": "Conversion tracking: see which ad, link and page bring sign-ups",
"desc": "Clicks tell you who looked. The conversion pixel tells you which ad, spin link, page and traffic source brought a subscriber or a sale, with a cost per goal in credits. It is free for every member.\n\nFour steps, one time: create a goal under Conversions (subscriber, sale), paste the landing tag on the page your traffic lands on, paste the goal pixel on your thank-you page, and send a test conversion. The guide has copy-paste examples for a plain HTML page, WordPress, page builders and Aweber or GetResponse thank-you pages, what to do when you cannot put code on the thank-you page, how to read the report (match methods, cost per goal, the 30-day window) and a troubleshooting checklist.",
"docUrl": "/conversion-tracking",
"docLabel": "Read the guide",
"videoUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/conversion-tracking-ls.mp4?v=20261026",
"posterUrl": "https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/conversion-tracking-ls.jpg?v=20261026"
} }
] ]
+123 -24
View File
File diff suppressed because one or more lines are too long
+11 -4
View File
@@ -56,12 +56,16 @@ async function member(id) {
const STALL_DAYS = 3; const STALL_DAYS = 3;
async function describe(acct, now = Date.now()) { async function describe(acct, now = Date.now()) {
const mm = await member(acct.memberId); const mm = await member(acct.memberId);
// unknown = the member is on chain but the read failed just now (member() swallows RPC errors and caches null for a
// minute); rungFor would call them "payouts on, no purchase" and the coach would mail a buyer the first-package nudge
// (2026-10-31: Marty, 4 purchases and 7 buyers, got "See a payout land"). Callers that mail must skip unknown.
const unknown = !!(acct.memberId && !mm);
const rung = rungFor(acct, mm); const rung = rungFor(acct, mm);
const last = Math.max(acct.created || 0, acct.lastSeen || 0); const last = Math.max(acct.created || 0, acct.lastSeen || 0);
const quietDays = Math.floor((now - last) / DAY); const quietDays = Math.floor((now - last) / DAY);
const stalled = rung < 6 && quietDays >= STALL_DAYS; const stalled = !unknown && rung < 6 && quietDays >= STALL_DAYS;
const R = RUNGS[rung]; const R = RUNGS[rung];
return { rung, label: R.label, next: R.next, say: R.say, quietDays, stalled, buyerCount: mm ? mm.buyerCount : 0, return { rung, label: R.label, next: R.next, say: R.say, quietDays, stalled, unknown, buyerCount: mm ? mm.buyerCount : 0,
counted: !!(mm && mm.countedAsBuyer), joined: acct.created, lastSeen: acct.lastSeen || 0, onchainSponsorId: mm ? mm.sponsorId : null }; counted: !!(mm && mm.countedAsBuyer), joined: acct.created, lastSeen: acct.lastSeen || 0, onchainSponsorId: mm ? mm.sponsorId : null };
} }
// coaching view for a sponsor: every direct, ladder rung, stalled flag, what to say // coaching view for a sponsor: every direct, ladder rung, stalled flag, what to say
@@ -177,6 +181,8 @@ function clickSource(referer) {
} catch (e) { return 'unknown'; } } catch (e) { return 'unknown'; }
} }
async function recordClick(campaignId, referer) { try { await impl().addClick(Number(campaignId), clickSource(referer), Date.now()); } catch (e) {} } async function recordClick(campaignId, referer) { try { await impl().addClick(Number(campaignId), clickSource(referer), Date.now()); } catch (e) {} }
// clicks on these campaigns since a moment (the Engine Room's clicks-this-week dial, 2026-10-24)
async function clicksSince(campaignIds, since) { if (!campaignIds.length) return 0; const rows = await impl().clicksFor(campaignIds.map(Number)); return rows.filter(r => Number(r.ts) >= since).length; }
async function clickSources(campaignIds) { async function clickSources(campaignIds) {
const rows = await impl().clicksFor(campaignIds.map(Number)); const rows = await impl().clicksFor(campaignIds.map(Number));
const out = {}; const out = {};
@@ -219,6 +225,7 @@ async function nudgeTick() {
const all = await accounts.listAll(5000); const all = await accounts.listAll(5000);
for (const acct of all) { for (const acct of all) {
if (!acct.email || !acct.created || now - acct.created < STALL_DAYS * DAY) continue; if (!acct.email || !acct.created || now - acct.created < STALL_DAYS * DAY) continue;
if (X.adminEmail && String(acct.email).toLowerCase() === String(X.adminEmail).toLowerCase()) continue; // the site owner is never coached (2026-10-31)
if (!acct.lastSeen || acct.joinedVia === 'carried' && !acct.lastSeen) continue; // never signed in here (carried-over shells from InstantAdPay): no coaching mail, ever (2026-10-11: Harvey got a nudge for a site he never joined) if (!acct.lastSeen || acct.joinedVia === 'carried' && !acct.lastSeen) continue; // never signed in here (carried-over shells from InstantAdPay): no coaching mail, ever (2026-10-11: Harvey got a nudge for a site he never joined)
const c = await describe(acct, now); const c = await describe(acct, now);
if (!c.stalled) continue; if (!c.stalled) continue;
@@ -235,7 +242,7 @@ async function nudgeTick() {
// weekly member email (Marty, 2026-09-14, modelled on the mailer.gold weekly): credits sitting unspent, // weekly member email (Marty, 2026-09-14, modelled on the mailer.gold weekly): credits sitting unspent,
// the streak, the contest standings with the member's own rank, the tank, and the line for sponsors // the streak, the contest standings with the member's own rank, the tank, and the line for sponsors
let lbWeek = null; try { lbWeek = X.lb ? await X.lb().view('week') : null; } catch (e) {} let lbWeek = null; try { lbWeek = X.lb ? await X.lb().view('week') : null; } catch (e) {}
let tankN = 0; try { tankN = X.tank ? (await X.tank.waiting()).length : 0; } catch (e) {} let tankN = 0; try { tankN = X.tank ? (await X.tank.adoptable()).length : 0; } catch (e) {}
for (const acct of all) { for (const acct of all) {
if (!acct.email || !acct.lastSeen) continue; // weekly mail only to people who have actually signed in here if (!acct.email || !acct.lastSeen) continue; // weekly mail only to people who have actually signed in here
const lastD = await impl().lastDigest(acct.email); const lastD = await impl().lastDigest(acct.email);
@@ -292,4 +299,4 @@ function init(opts) { X = arguments[0] || {};
J.load(); J.load();
} }
async function viewsSince(since) { return impl().viewsSince(since); } async function viewsSince(since) { return impl().viewsSince(since); }
module.exports = { init, RUNGS, rungFor, describe, coachView, prospects, saveProspect, removeProspect, STATUSES, recordView, linkStats, nudgeTick, recordClick, clickSources, refHost, viewsSince }; module.exports = { /* member erase (erase.js, 2026-11-15): the live copy */ _json: { state: () => J.db, save: () => J.save() }, init, RUNGS, rungFor, describe, coachView, prospects, saveProspect, removeProspect, STATUSES, recordView, linkStats, nudgeTick, recordClick, clickSources, clicksSince, refHost, viewsSince };
+318
View File
@@ -0,0 +1,318 @@
// Conversion pixel (Marty approved 2026-10-23, "Go with the conversion pixel"). LinkSpin is the single source of truth
// for goals and goal conversions, for its own members AND for InstantAdPay members (their LinkSpin shell account, same
// email, holds the goals; InstantAdPay reads and edits them over the signed partner call).
//
// - Goals: a member names a goal ("subscriber", "sale", optional default value). Each goal has a PUBLIC pixel id
// (px + 10 hex). It is not a secret: it can only ever count conversions for clicks its owner owns.
// - Ad clicks: every LinkSpin ad click (/api/ads/click, zone clicks) gets a click id 'a' + 11 hex; every InstantAdPay
// ad click is pushed here with its own id 'i' + 11 hex (/api/partner/clicks). Spin-link clicks keep the rotator's
// 10-hex lsid; a spin-link click that arrived through an ad carries that ad click as `ac` (rotator.js).
// - Landing tag (/t.js) stores the click id on the member's own site; the goal pixel (/cv.gif, /cv.js) reports it.
// Matching order: the click id in the URL > the landing tag's stored id > LinkSpin's cookie > the 24 h IP+UA soft key.
// The method that matched is kept on the conversion so Reports can say how solid each count is.
// - Rules: each goal counts once per click (per ROOT click: an ad click and the spin-link click it led to are one
// click), only within 30 days of a real click, only for clicks the pixel's owner owns (the ad's owner or the spin
// link's owner), per-pixel and per-IP rate limits. A test conversion is recorded apart and never counted. The goal
// owner's own click (any type: ad, spin link, Banner Spin) is kept as a test, never counted (2026-10-26).
// - Banner Spin clicks ('k' + 11 hex) that go straight to a page carry lsclk too since 2026-10-26 (bannerspin.js).
// Storage: DATA_DIR/convtrack.json (JSON in both modes, like rotator.json / postbacks.json), debounced writes.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const DAY = 86400000, WINDOW_MS = 30 * DAY, SOFT_MS = 24 * 3600000, MAX_GOALS = 20;
const MAX_CLICKS = 300000, MAX_CONV = 100000;
let FILE = null, S = null, dirty = false, rotator = null, bannerspin = null, campaignOf = async () => null;
function load() {
if (S) return S;
try { S = JSON.parse(fs.readFileSync(FILE, 'utf8')); } catch (e) { S = null; }
if (!S || typeof S !== 'object') S = {};
S.v = 1; S.goals = S.goals || {}; S.clicks = S.clicks || {}; S.soft = S.soft || {}; S.conv = Array.isArray(S.conv) ? S.conv : []; S.camps = S.camps || {}; S.tests = S.tests || {};
S.own = S.own || {}; S.selfIds = S.selfIds || {}; // own-click tests (2026-10-26): soft key -> { owner email: last seen }, click id -> marked at
return S;
}
function save() { dirty = true; }
function flush() { if (!dirty || !S || !FILE) return; dirty = false; try { fs.writeFileSync(FILE + '.tmp', JSON.stringify(S)); fs.renameSync(FILE + '.tmp', FILE); } catch (e) { console.error('convtrack save', e.message); } }
function init(opts) {
FILE = path.join(opts.dataDir, 'convtrack.json'); rotator = opts.rotator || null; bannerspin = opts.bannerspin || null; if (opts.campaignOf) campaignOf = opts.campaignOf;
S = null; load();
if (!opts.noTimers) { setInterval(flush, 3000).unref(); setInterval(prune, 3600000).unref(); }
}
const norm = e => String(e || '').trim().toLowerCase();
const isPx = v => /^px[a-f0-9]{10}$/.test(String(v || ''));
const isClickId = v => /^[a-z0-9]{6,24}$/i.test(String(v || ''));
const isAdId = v => /^[ai][a-f0-9]{11}$/.test(String(v || ''));
const cleanName = v => { const s = String(v == null ? '' : v).trim().toLowerCase().replace(/\s+/g, '_'); return /^[a-z0-9_-]{1,32}$/.test(s) ? s : ''; };
const cleanValue = v => { if (v === '' || v == null) return 0; const n = Number(v); return Number.isFinite(n) && n >= 0 ? Math.min(Math.round(n * 100) / 100, 100000) : 0; };
const newPx = () => { for (;;) { const id = 'px' + crypto.randomBytes(5).toString('hex'); if (!load().goals[id]) return id; } };
const newAdClickId = () => 'a' + crypto.randomBytes(6).toString('hex').slice(0, 11);
function ipOf(req) { return String(req.headers['x-forwarded-for'] || (req.socket && req.socket.remoteAddress) || '').split(',')[0].trim(); }
// the soft key: InstantAdPay computes exactly the same thing for its ad clicks (contract 2026-10-23)
function softKey(req) { return 's:' + crypto.createHash('sha256').update(ipOf(req) + '|' + String(req.headers['user-agent'] || '')).digest('hex').slice(0, 20); }
// ── own clicks are tests, on every click type (Marty approved 2026-10-26) ───────────────────────────────────────
// A member clicking their OWN ad, spin link or Banner Spin and converting is a test, never a count. Known by: the click
// was made while signed in as the owner (ads), or the clicking / converting browser's soft key is one the owner has been
// seen signed in from (LinkSpin sessions, noted by auth.js; InstantAdPay sessions, pushed with its clicks). Linked
// positions sit on the owner's own email, so they are the owner here too. Soft keys kept 31 days (the click window).
const OWN_MS = WINDOW_MS + DAY, ownNoted = new Map();
const isSk = sk => /^s:[a-f0-9]{20}$/.test(String(sk || ''));
function noteOwner(email, sk, ts) {
const e = norm(email); if (!e || e.length > 190 || !isSk(sk)) return false;
const at = Math.min(Number(ts) || Date.now(), Date.now()); const k = e + '|' + sk;
if ((ownNoted.get(k) || 0) > at - 600000) return false; ownNoted.set(k, at); if (ownNoted.size > 20000) ownNoted.clear();
const st = load(); const m = st.own[sk] = st.own[sk] || {};
if (!(m[e] >= at)) m[e] = at;
const keys = Object.keys(m); if (keys.length > 8) { keys.sort((a, b) => m[a] - m[b]); for (const x of keys.slice(0, keys.length - 8)) delete m[x]; }
save(); return true;
}
function noteSession(email, req) { try { return noteOwner(email, softKey(req)); } catch (e) { return false; } }
// InstantAdPay's pushed rows: [{ owner, sk, ts }] (its members' own sessions)
function importOwners(rows) { let n = 0; for (const r of (Array.isArray(rows) ? rows.slice(0, 2000) : [])) if (r && noteOwner(r.owner, r.sk, r.ts)) n++; return n; }
function isOwnerSk(owner, sk) { const m = isSk(sk) && load().own[sk]; const t = m && m[norm(owner)]; return !!(t && Date.now() - t <= OWN_MS); }
// spin-link and Banner Spin clicks: marked when the owner made them (signed in on this host, or from an owner soft key)
function markSelfClick(id, owner, req, sessionEmail) {
if (!isClickId(id) || !owner) return false;
const mine = (sessionEmail && norm(sessionEmail) === norm(owner)) || isOwnerSk(owner, softKey(req));
if (mine) { load().selfIds[id] = Date.now(); save(); }
return !!mine;
}
// ── goals ───────────────────────────────────────────────────────────────────────────────────────────────────────
function pubGoal(g) { return { px: g.px, name: g.name, value: g.value || 0, created: g.created, lastTest: (load().tests[g.px] || 0) || null }; }
function goalsOf(owner) { const o = norm(owner); return Object.values(load().goals).filter(g => g.owner === o).sort((a, b) => a.created - b.created); }
function goal(px) { return load().goals[String(px || '')] || null; }
function createGoal(owner, body) {
const o = norm(owner); if (!o) return { error: 'Sign in first.' };
const name = cleanName(body && body.name); if (!name) return { error: 'Name the goal with letters, numbers, - or _ (for example subscriber or sale), up to 32.' };
const mine = goalsOf(o);
if (mine.length >= MAX_GOALS) return { error: 'Up to ' + MAX_GOALS + ' goals per account. Remove one first.' };
if (mine.some(g => g.name === name)) return { error: 'You already have a goal called ' + name + '.' };
const g = { px: newPx(), owner: o, name, value: cleanValue(body && body.value), created: Date.now() };
load().goals[g.px] = g; save(); flush(); return { ok: true, goal: pubGoal(g) };
}
function updateGoal(owner, px, body) {
const g = goal(px); if (!g || g.owner !== norm(owner)) return { error: 'No such goal.' };
if (body.remove) { delete load().goals[g.px]; delete load().tests[g.px]; save(); flush(); return { ok: true, removed: true }; } // its past conversions stay in the log (the reports show them under the name)
if (body.name != null) { const n = cleanName(body.name); if (!n) return { error: 'Name the goal with letters, numbers, - or _ , up to 32.' }; if (goalsOf(g.owner).some(x => x.px !== g.px && x.name === n)) return { error: 'You already have a goal called ' + n + '.' }; g.name = n; }
if (body.value != null) g.value = cleanValue(body.value);
save(); flush(); return { ok: true, goal: pubGoal(g) };
}
// ── clicks ──────────────────────────────────────────────────────────────────────────────────────────────────────
function noteSoft(sk, id, owner, ts) {
if (!sk || !/^s:[a-f0-9]{20}$/.test(sk) || !id) return;
const st = load(); const now = ts || Date.now();
const list = (st.soft[sk] || []).filter(x => now - x[1] <= SOFT_MS && x[0] !== id);
list.push([id, now, norm(owner)]); st.soft[sk] = list.slice(-6); save();
}
// a LinkSpin ad click (banner, text, zone). Returns the click id to append to the target.
function recordAdClick(camp, req, extra) {
if (!camp || !camp.id) return null;
const st = load(); const id = newAdClickId(); const ua = String(req.headers['user-agent'] || '');
const sk = softKey(req);
let pl = String((extra && extra.placement) || ''); if (!pl) { try { const r = new URL(String(req.headers.referer || '')); pl = (r.hostname.replace(/^www\./, '') + r.pathname).slice(0, 80); } catch (e) {} }
st.clicks[id] = { id, k: 'ad', camp: Number(camp.id), cname: String(camp.name || camp.title || '').slice(0, 80), type: camp.type || '', owner: norm(camp.owner), ts: Date.now(), sk,
c: (extra && extra.country) || '', dv: /mobile|android|iphone|ipad/i.test(ua) ? 'mobile' : 'desktop', pl, self: (extra && extra.self) || isOwnerSk(camp.owner, sk) ? 1 : undefined, target: String(camp.targetUrl || '').slice(0, 300) };
noteSoft(sk, id, camp.owner); trimClicks(); save();
return id;
}
// InstantAdPay pushes its ad clicks (signed partner call); an upsert by id, so a row sent twice is harmless
function importClicks(rows) {
const st = load(); let n = 0;
for (const r of (Array.isArray(rows) ? rows.slice(0, 500) : [])) {
const id = String(r && r.id || ''); if (!/^i[a-f0-9]{11}$/.test(id)) continue;
const owner = norm(r.owner); if (!owner || owner.length > 190) continue;
const ts = Number(r.ts) || Date.now(); if (ts > Date.now() + 600000 || Date.now() - ts > WINDOW_MS) continue;
const sk = /^s:[a-f0-9]{20}$/.test(String(r.sk || '')) ? String(r.sk) : '';
const had = !!st.clicks[id];
st.clicks[id] = { id, k: 'iap', camp: Number(r.camp) || 0, cname: String(r.cname || '').slice(0, 80), type: String(r.type || '').slice(0, 12), owner, ts, sk,
c: String(r.c || '').toUpperCase().replace(/[^A-Z]/g, '').slice(0, 2), dv: r.dv === 'mobile' ? 'mobile' : 'desktop', pl: String(r.pl || '').slice(0, 80), self: r.self || isOwnerSk(owner, sk) ? 1 : undefined, target: String(r.target || '').slice(0, 300) };
if (r.camp) { const key = 'iap:' + Number(r.camp); const cur = st.camps[key] || {}; if (!cur.ts || ts >= cur.ts) st.camps[key] = { owner, name: String(r.cname || '').slice(0, 80), spent: Math.max(0, Number(r.spent) || 0), ts }; }
if (!had && sk) noteSoft(sk, id, owner, ts);
n++;
}
if (n) { trimClicks(); save(); }
return n;
}
function trimClicks() {
const st = load(); const keys = Object.keys(st.clicks); if (keys.length <= MAX_CLICKS) return;
keys.sort((a, b) => st.clicks[a].ts - st.clicks[b].ts); for (const k of keys.slice(0, keys.length - Math.floor(MAX_CLICKS * 0.8))) delete st.clicks[k];
}
function prune() {
const st = load(); const now = Date.now();
for (const k in st.clicks) if (now - st.clicks[k].ts > WINDOW_MS + DAY) delete st.clicks[k];
for (const k in st.soft) { const l = st.soft[k].filter(x => now - x[1] <= SOFT_MS); if (l.length) st.soft[k] = l; else delete st.soft[k]; }
for (const k in st.camps) if (now - st.camps[k].ts > 400 * DAY) delete st.camps[k];
for (const k in st.selfIds) if (now - st.selfIds[k] > OWN_MS) delete st.selfIds[k];
for (const k in st.own) { const m = st.own[k]; for (const e in m) if (now - m[e] > OWN_MS) delete m[e]; if (!Object.keys(m).length) delete st.own[k]; }
if (st.conv.length > MAX_CONV) st.conv = st.conv.slice(-Math.floor(MAX_CONV * 0.8));
save(); flush();
}
// What a click id is, who owns it, where it came from. Spin-link clicks live in rotator.json.
function lookup(id) {
id = String(id || ''); if (!isClickId(id)) return null;
const st = load();
const ad = st.clicks[id];
if (ad) return { id, root: id, ts: ad.ts, owners: [ad.owner], ad };
if (rotator && rotator.hitById && id[0] !== 'k') { // spin-link ids are 10 hex, never 'k' (that is Banner Spin's)
const h = rotator.hitById(id); if (!h || !h.hit || h.hit.bot) return null;
const via = h.hit.ac && st.clicks[h.hit.ac] ? st.clicks[h.hit.ac] : null;
return { id, root: via ? via.id : id, ts: via ? Math.min(via.ts, h.hit.ts) : h.hit.ts, owners: [h.owner].concat(via ? [via.owner] : []), ad: via, spin: h };
}
// a Banner Spin click ('k' + 11 hex) that went straight to a page (2026-10-26: those now carry lsclk too)
if (bannerspin && bannerspin.clickById && id[0] === 'k') {
const b = bannerspin.clickById(id); if (!b || !b.click || b.click.bot) return null;
return { id, root: id, ts: b.click.ts, owners: [b.owner], bspin: b };
}
return null;
}
// ── the goal pixel ─────────────────────────────────────────────────────────────────────────────────────────────
const RL = { px: new Map(), ip: new Map() };
function rateOk(map, key, max, ms) { const now = Date.now(); const a = (map.get(key) || []).filter(t => now - t < ms); if (a.length >= max) { map.set(key, a); return false; } a.push(now); map.set(key, a); if (map.size > 50000) map.clear(); return true; }
setInterval(() => { const now = Date.now(); for (const m of [RL.px, RL.ip]) for (const [k, a] of m) if (!a.some(t => now - t < 3600000)) m.delete(k); }, 600000).unref();
const LIMITS = { pxPerMin: 60, pxPerHour: 1000, ipPerMin: 20 };
// q: { px, goal, value, c (click id from the page), m ('url'|'stored', who found it), test }
// cookies: { 'ls.clk', 'ls.click' }. Returns { result, method?, conv? } where result is counted | dup | nomatch | unknown | limited | test | refused
function record(q, req, cookies) {
const g = goal(q.px); if (!g) return { result: 'unknown' };
const sk = softKey(req); const ip = sk; // the soft key doubles as the per-visitor rate key (no raw IP held)
if (!rateOk(RL.ip, ip, LIMITS.ipPerMin, 60000)) return { result: 'limited' };
if (!rateOk(RL.px, g.px + ':m', LIMITS.pxPerMin, 60000) || !rateOk(RL.px, g.px + ':h', LIMITS.pxPerHour, 3600000)) return { result: 'limited' };
if (q.test) { load().tests[g.px] = Date.now(); save(); return { result: 'test', at: load().tests[g.px] }; }
const now = Date.now(); let refused = 0;
const tryId = (id, method) => {
const L = lookup(id); if (!L) return null;
if (!L.owners.includes(g.owner)) { refused++; return null; } // someone else's click: never counted for this pixel
if (now - L.ts > WINDOW_MS) return null;
return Object.assign(L, { method });
};
let hit = null;
if (isClickId(q.c)) hit = tryId(q.c, q.m === 'stored' ? 'stored' : 'url');
if (!hit) for (const ck of ['ls.clk', 'ls.click']) { const v = cookies && cookies[ck]; if (!hit && isClickId(v)) hit = tryId(v, 'cookie'); }
if (!hit) { const list = (load().soft[sk] || []).filter(x => x[2] === g.owner && now - x[1] <= SOFT_MS).sort((a, b) => b[1] - a[1]); for (const x of list) { hit = tryId(x[0], 'soft'); if (hit) break; } }
if (!hit) return { result: refused ? 'refused' : 'nomatch' };
const st = load();
if (st.conv.some(c => c.px === g.px && (c.root === hit.root || c.click === hit.id || c.root === hit.id))) return { result: 'dup', method: hit.method };
const ad = hit.ad, sp = hit.spin, bs = hit.bspin;
const value = q.value != null && q.value !== '' ? cleanValue(q.value) : (g.value || 0);
// the goal owner's own click, on ANY click type (ad, spin link, Banner Spin): kept as a test, never in the counts.
// Own = the ad click was flagged self for this owner, the spin / Banner Spin click was marked at click time, or the
// clicking or converting browser is one the owner has been seen signed in from (2026-10-26).
const self = (ad && ad.self && ad.owner === g.owner) || st.selfIds[hit.id] || st.selfIds[hit.root] || isOwnerSk(g.owner, sk) || (ad && ad.sk && isOwnerSk(g.owner, ad.sk)) ? 1 : undefined;
const conv = { id: crypto.randomBytes(6).toString('hex'), ts: now, px: g.px, goal: g.name, owner: g.owner, click: hit.id, root: hit.root, method: hit.method, value,
k: ad ? ad.k : (bs ? 'bspin' : 'spin'), camp: ad ? ad.camp : undefined, cname: ad ? ad.cname : undefined, ctype: ad ? ad.type : undefined,
rot: sp ? sp.rotation.id : undefined, rcode: sp ? sp.rotation.code : undefined, rname: sp ? sp.rotation.name : undefined,
bs: bs ? bs.spin.id : undefined, bcode: bs ? bs.spin.code : undefined, bname: bs ? bs.spin.name : undefined, bban: bs && bs.banner ? bs.banner.id : undefined,
dest: sp ? sp.destUrl : (bs ? bs.destUrl : (ad ? ad.target : undefined)), sr: sp ? (sp.hit.sr || undefined) : (bs ? (bs.click.sr || undefined) : undefined), src: sp ? sp.hit.s : (bs ? (bs.click.h || 'direct') : (ad ? ad.pl : undefined)),
c: (sp ? sp.hit.c : (bs ? bs.click.c : ad && ad.c)) || '', dv: (sp ? sp.hit.dv : (bs ? bs.click.dv : ad && ad.dv)) || '', self };
for (const k of Object.keys(conv)) if (conv[k] === undefined) delete conv[k];
st.conv.push(conv); save();
return { result: 'counted', method: hit.method, conv, hit };
}
// the postback context for a counted conversion (postbacks.fire)
function postbackCtx(r) {
const c = r.conv, sp = r.hit && r.hit.spin, bs = r.hit && r.hit.bspin;
return { q: sp ? (sp.hit.q || {}) : (bs ? (bs.click.q || {}) : {}), source: c.src || '', country: c.c || '', device: c.dv || '', lsid: c.click, code: c.rcode || c.bcode || '', sourceId: c.sr || '', payout: c.value || 0, currency: 'USD', label: c.goal };
}
// the landing tag's beacon: it saw a click id on the member's page. Returns the id when it is a real click of the pixel's owner.
function landing(px, id, req) {
const g = goal(px); if (!g || !isClickId(id)) return null;
if (!rateOk(RL.ip, softKey(req) + ':t', 60, 60000)) return null;
const L = lookup(id); if (!L || !L.owners.includes(g.owner) || Date.now() - L.ts > WINDOW_MS) return null;
noteSoft(softKey(req), id, g.owner); return id;
}
// ── reports ─────────────────────────────────────────────────────────────────────────────────────────────────────
// per goal: totals, match methods, and breakdowns by ad campaign (LinkSpin + InstantAdPay), spin link, destination
// and traffic source. Cost per goal on ad campaigns = the campaign's credits spent / its conversions of that goal.
async function report(owner, days, opts) {
const o = norm(owner); const since = Date.now() - (Math.max(1, Math.min(400, Number(days) || 30))) * DAY;
const goals = goalsOf(o); const st = load();
const conv = st.conv.filter(c => c.owner === o && c.ts >= since && !c.self);
const selfTests = st.conv.filter(c => c.owner === o && c.ts >= since && c.self).length;
const methods = { url: 0, stored: 0, cookie: 0, soft: 0 };
const byGoal = {};
const at = (gname) => (byGoal[gname] = byGoal[gname] || { goal: gname, n: 0, value: 0, methods: { url: 0, stored: 0, cookie: 0, soft: 0 }, campaigns: {}, links: {}, banners: {}, dests: {}, sources: {} });
for (const c of conv) {
const G = at(c.goal); G.n++; G.value += c.value || 0; G.methods[c.method] = (G.methods[c.method] || 0) + 1; methods[c.method] = (methods[c.method] || 0) + 1;
if (c.camp) { const key = (c.k === 'iap' ? 'iap:' : 'ls:') + c.camp; const x = G.campaigns[key] = G.campaigns[key] || { key, site: c.k === 'iap' ? 'InstantAdPay' : 'LinkSpin', id: c.camp, name: c.cname || '', n: 0, value: 0 }; x.n++; x.value += c.value || 0; }
if (c.rot) { const x = G.links[c.rot] = G.links[c.rot] || { id: c.rot, code: c.rcode, name: c.rname || '', n: 0, value: 0 }; x.n++; x.value += c.value || 0; }
if (c.bs) { const x = G.banners[c.bs] = G.banners[c.bs] || { id: c.bs, code: c.bcode, name: c.bname || '', n: 0, value: 0 }; x.n++; x.value += c.value || 0; }
if (c.dest) { let d = c.dest; try { const u = new URL(c.dest); d = u.hostname.replace(/^www\./, '') + u.pathname.replace(/\/$/, ''); } catch (e) {} const x = G.dests[d] = G.dests[d] || { k: d, n: 0 }; x.n++; }
{ const key = c.sr ? 'src:' + c.sr : (c.src || '(direct)'); const x = G.sources[key] = G.sources[key] || { k: key, sourceId: c.sr || '', n: 0 }; x.n++; }
}
// clicks per ad campaign in the same window, and the cost basis
const clicksBy = {}; for (const k in st.clicks) { const a = st.clicks[k]; if (a.owner !== o || a.ts < since || a.self) continue; const key = (a.k === 'iap' ? 'iap:' : 'ls:') + a.camp; clicksBy[key] = (clicksBy[key] || 0) + 1; }
const meta = (opts && opts.sourceMeta) || {};
const out = [];
for (const gname of new Set(goals.map(g => g.name).concat(Object.keys(byGoal)))) {
const G = byGoal[gname] || at(gname);
const campaigns = [];
for (const x of Object.values(G.campaigns)) {
let spent = null, asOf = null;
if (x.site === 'LinkSpin') { try { const cp = await campaignOf(x.id); if (cp && norm(cp.owner) === o) { spent = Number(cp.spent || 0) + Number(cp.accrued || 0); if (!x.name) x.name = cp.name || ''; } } catch (e) {} }
else { const cm = st.camps['iap:' + x.id]; if (cm && cm.owner === o) { spent = cm.spent; asOf = cm.ts; if (!x.name) x.name = cm.name; } }
campaigns.push(Object.assign(x, { clicks: clicksBy[x.key] || 0, spent, spentAsOf: asOf, costPer: spent != null && x.n ? Math.round(spent / x.n * 100) / 100 : null, rate: clicksBy[x.key] ? Math.round(x.n / clicksBy[x.key] * 1000) / 10 : null }));
}
campaigns.sort((a, b) => b.n - a.n);
const sources = Object.values(G.sources).map(x => Object.assign(x, { name: x.sourceId ? ((meta[x.sourceId] || {}).name || 'Deleted source') : x.k })).sort((a, b) => b.n - a.n).slice(0, 15);
const g = goals.find(y => y.name === gname);
out.push({ goal: gname, px: g ? g.px : null, removed: !g, n: G.n, value: Math.round(G.value * 100) / 100, methods: G.methods, campaigns,
links: Object.values(G.links).sort((a, b) => b.n - a.n).slice(0, 15), banners: Object.values(G.banners).sort((a, b) => b.n - a.n).slice(0, 15), dests: Object.values(G.dests).sort((a, b) => b.n - a.n).slice(0, 15), sources });
}
return { days: Number(days) || 30, goals: goals.map(g => Object.assign(pubGoal(g), { conv: conv.filter(c => c.px === g.px).length, lastAt: (conv.filter(c => c.px === g.px).pop() || {}).ts || null })),
byGoal: out, methods, total: conv.length, selfTests };
}
// goal conversions as rows, own-click tests left out. goalRows() = every row that came through a spin link, in the rotator's own
// shape, so per-link counts include goals (2026-11-07); memoized on the length of the log, the pixel only ever appends to it.
let GR = { n: -1, rows: [] };
function goalRows() { const c = load().conv; if (GR.n !== c.length) GR = { n: c.length, rows: c.filter(x => x.rot && !x.self).map(x => ({ r: x.rot, lsid: x.click, ev: 'goal: ' + x.goal, ts: x.ts, value: x.value || 0, sr: x.sr })) }; return GR.rows; }
function goalRowsOf(owner, since) { const o = norm(owner); return load().conv.filter(c => c.owner === o && c.ts >= since && !c.self); }
// the click-side test of "is this the owner's own": the click was theirs, or the converting browser is one they sign in from
function selfFor(L, owner, sk) {
const st = load(), ad = L.ad, o = norm(owner);
return !!(st.selfIds[L.id] || st.selfIds[L.root] || (ad && ad.owner === o && (ad.self || (ad.sk && isOwnerSk(o, ad.sk)))) || (sk && isOwnerSk(o, sk)));
}
// InstantAdPay's view: goals + per IAP campaign conversions (and clicks) for this owner
// goal conversions (not the owner's own tests) since a moment, for the Engine Room's goals dial (2026-10-24)
function countSince(owner, since) { const o = norm(owner); return load().conv.filter(c => c.owner === o && c.ts >= since && !c.self).length; }
function partnerSummary(owner, days) {
const o = norm(owner); const since = Date.now() - (Math.max(1, Math.min(90, Number(days) || 30))) * DAY; const st = load();
const conv = st.conv.filter(c => c.owner === o && c.ts >= since && !c.self);
const byCampaign = {};
for (const k in st.clicks) { const a = st.clicks[k]; if (a.k !== 'iap' || a.owner !== o || a.ts < since || a.self) continue; const b = byCampaign[a.camp] = byCampaign[a.camp] || { clicks: 0, conv: {}, value: {} }; b.clicks++; }
for (const c of conv) if (c.k === 'iap' && c.camp) { const b = byCampaign[c.camp] = byCampaign[c.camp] || { clicks: 0, conv: {}, value: {} }; b.conv[c.px] = (b.conv[c.px] || 0) + 1; b.value[c.px] = Math.round(((b.value[c.px] || 0) + (c.value || 0)) * 100) / 100; }
const methods = { url: 0, stored: 0, cookie: 0, soft: 0 }; for (const c of conv) methods[c.method] = (methods[c.method] || 0) + 1;
const goals = goalsOf(o).map(g => { const mine = conv.filter(c => c.px === g.px); return Object.assign(pubGoal(g), { conv: mine.length, convDays: Number(days) || 30, lastAt: mine.length ? mine[mine.length - 1].ts : null }); });
const selfTests = st.conv.filter(c => c.owner === o && c.ts >= since && c.self).length; // own clicks, kept as tests (InstantAdPay shows "N from your own clicks")
return { ok: true, goals, byCampaign, methods, selfTests };
}
function csv(owner, days) {
const o = norm(owner); const since = Date.now() - (Math.max(1, Math.min(400, Number(days) || 30))) * DAY;
const esc = v => { const s = v == null ? '' : String(v); return /[",\n]/.test(s) || /^[=+\-@]/.test(s) ? '"' + (/^[=+\-@]/.test(s) ? "'" : '') + s.replace(/"/g, '""') + '"' : s; };
const ctFmt = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false });
const lines = ['time_central,goal,value,match_method,site,campaign_id,campaign,spin_link,destination,source,country,device,click_id'];
for (const c of load().conv) if (c.owner === o && c.ts >= since && !c.self) lines.push([ctFmt.format(new Date(c.ts)).replace(',', ''), c.goal, c.value || 0, c.method, c.k === 'iap' ? 'InstantAdPay' : (c.k === 'ad' ? 'LinkSpin ad' : (c.k === 'bspin' ? 'Banner Spin' : 'Spin link')), c.camp || '', c.cname || '', c.rcode || (c.bcode ? 'c/' + c.bcode : ''), c.dest || '', c.src || '', c.c || '', c.dv || '', c.click].map(esc).join(','));
return lines.join('\n') + '\n';
}
// "Send a test conversion" from a screen (InstantAdPay's partner call, or the Control Room when it cannot load the image)
function testGoal(owner, px) { const g = goal(px); if (!g || g.owner !== norm(owner)) return { error: 'No such goal.' }; load().tests[g.px] = Date.now(); save(); flush(); return { ok: true, at: load().tests[g.px] }; }
function adminCounts() { const st = load(); return { goals: Object.keys(st.goals).length, clicks: Object.keys(st.clicks).length, conversions: st.conv.length }; }
// append lsclk=<id> the way InstantAdPay's lsconv.withClickId does: string insert (every existing param keeps its exact
// encoding), before any #hash, an lsclk already there never replaced, a URL that does not parse goes out unchanged
function withClickId(target, id) {
const t = String(target || '');
let u; try { u = new URL(t); } catch (e) { return t; }
if (!/^https?:$/.test(u.protocol) || u.searchParams.has('lsclk') || !isClickId(id)) return t;
const hashAt = t.indexOf('#'); const base = hashAt >= 0 ? t.slice(0, hashAt) : t; const hash = hashAt >= 0 ? t.slice(hashAt) : '';
const sep = base.includes('?') ? (/[?&]$/.test(base) ? '' : '&') : '?';
return base + sep + 'lsclk=' + encodeURIComponent(id) + hash;
}
module.exports = { /* member erase (erase.js, 2026-11-15): the live copy */ _state: () => load(), _save: () => { save(); flush(); }, goalRows, goalRowsOf, selfFor, noteOwner, noteSession, importOwners, isOwnerSk, markSelfClick, withClickId, countSince, init, flush, prune, softKey, isPx, isClickId, isAdId, cleanName, cleanValue, goalsOf, goal, createGoal, updateGoal, recordAdClick, importClicks, lookup, record, postbackCtx, landing, report, partnerSummary, csv, adminCounts, testGoal, LIMITS, WINDOW_MS, SOFT_MS };
+7
View File
@@ -81,6 +81,7 @@ async function bootstrap() {
catch (e) { if (!['ER_DUP_FIELDNAME', 'ER_DUP_KEYNAME'].includes(e.code)) throw e; } catch (e) { if (!['ER_DUP_FIELDNAME', 'ER_DUP_KEYNAME'].includes(e.code)) throw e; }
}; };
await alterSafe('ALTER TABLE promo_codes ADD COLUMN funder VARCHAR(190) NULL'); // member-funded partner codes (Nexus), 2026-09-14 await alterSafe('ALTER TABLE promo_codes ADD COLUMN funder VARCHAR(190) NULL'); // member-funded partner codes (Nexus), 2026-09-14
await alterSafe('ALTER TABLE promo_codes ADD COLUMN starts BIGINT NOT NULL DEFAULT 0'); // 2026-11-17 Network Weekend: a code can open at a set time (0 = open now)
await alterSafe('ALTER TABLE accounts ADD COLUMN username VARCHAR(30) NULL'); await alterSafe('ALTER TABLE accounts ADD COLUMN username VARCHAR(30) NULL');
await alterSafe('ALTER TABLE accounts ADD UNIQUE KEY uq_username (username)'); await alterSafe('ALTER TABLE accounts ADD UNIQUE KEY uq_username (username)');
await alterSafe('ALTER TABLE accounts ADD COLUMN member_id INT NULL'); await alterSafe('ALTER TABLE accounts ADD COLUMN member_id INT NULL');
@@ -90,6 +91,8 @@ async function bootstrap() {
await alterSafe('ALTER TABLE accounts ADD COLUMN socials VARCHAR(1200) NULL'); // JSON {platform:url} await alterSafe('ALTER TABLE accounts ADD COLUMN socials VARCHAR(1200) NULL'); // JSON {platform:url}
await alterSafe('ALTER TABLE accounts ADD COLUMN line_banner_url VARCHAR(500) NULL'); await alterSafe('ALTER TABLE accounts ADD COLUMN line_banner_url VARCHAR(500) NULL');
await alterSafe('ALTER TABLE accounts ADD COLUMN line_target_url VARCHAR(500) NULL'); await alterSafe('ALTER TABLE accounts ADD COLUMN line_target_url VARCHAR(500) NULL');
await alterSafe('ALTER TABLE accounts ADD COLUMN profile_quarantined TINYINT NOT NULL DEFAULT 0');
await alterSafe('ALTER TABLE accounts ADD COLUMN theme VARCHAR(8) NULL'); // 2026-11-01 appearance: auto | light | dark // 2026-10-30 link-farm rule: first profile save of a new free account carried a link (spamscan.js)
await q(`CREATE TABLE IF NOT EXISTS daily_views ( await q(`CREATE TABLE IF NOT EXISTS daily_views (
email VARCHAR(190) NOT NULL, email VARCHAR(190) NOT NULL,
day CHAR(10) NOT NULL, day CHAR(10) NOT NULL,
@@ -120,6 +123,8 @@ async function bootstrap() {
await alterSafe('ALTER TABLE campaigns ADD COLUMN height INT NULL'); // banner size (IAB) → also NAS height await alterSafe('ALTER TABLE campaigns ADD COLUMN height INT NULL'); // banner size (IAB) → also NAS height
await alterSafe('ALTER TABLE campaigns ADD COLUMN nas_ad_id INT NULL'); // syndicated NAS sponsorads.ID await alterSafe('ALTER TABLE campaigns ADD COLUMN nas_ad_id INT NULL'); // syndicated NAS sponsorads.ID
await alterSafe('ALTER TABLE campaigns ADD COLUMN nas_served INT NOT NULL DEFAULT 0'); // NAS impressions already reconciled into spend await alterSafe('ALTER TABLE campaigns ADD COLUMN nas_served INT NOT NULL DEFAULT 0'); // NAS impressions already reconciled into spend
await alterSafe('ALTER TABLE campaigns ADD COLUMN syn_imps INT NOT NULL DEFAULT 0'); // views in other members' zones (charged at 1/synRateDivisor)
await alterSafe('ALTER TABLE campaigns ADD COLUMN syn_batch INT NOT NULL DEFAULT 0'); // partner-zone views toward the next 1/N batch
await alterSafe('ALTER TABLE campaigns ADD COLUMN expires BIGINT NULL'); // featured rotation end time await alterSafe('ALTER TABLE campaigns ADD COLUMN expires BIGINT NULL'); // featured rotation end time
await alterSafe('ALTER TABLE campaigns ADD COLUMN starts BIGINT NULL'); // featured run start (booked day); any type: scheduled start await alterSafe('ALTER TABLE campaigns ADD COLUMN starts BIGINT NULL'); // featured run start (booked day); any type: scheduled start
await q(`CREATE TABLE IF NOT EXISTS camp_hours ( await q(`CREATE TABLE IF NOT EXISTS camp_hours (
@@ -249,6 +254,8 @@ async function bootstrap() {
// per-account chat settings: availability toggle (default on) + muted-member list (JSON emails) // per-account chat settings: availability toggle (default on) + muted-member list (JSON emails)
await alterSafe('ALTER TABLE accounts ADD COLUMN chat_available TINYINT NOT NULL DEFAULT 1'); await alterSafe('ALTER TABLE accounts ADD COLUMN chat_available TINYINT NOT NULL DEFAULT 1');
await alterSafe('ALTER TABLE accounts ADD COLUMN chat_mutes VARCHAR(4000) NULL'); await alterSafe('ALTER TABLE accounts ADD COLUMN chat_mutes VARCHAR(4000) NULL');
await alterSafe('ALTER TABLE accounts ADD COLUMN first_seen BIGINT NULL'); // earliest signed-in visit (Founder badge, 2026-11-05)
await alterSafe('ALTER TABLE accounts ADD COLUMN founder BIGINT NULL'); // Founder badge granted at (ms)
await q(`CREATE TABLE IF NOT EXISTS video_seen ( await q(`CREATE TABLE IF NOT EXISTS video_seen (
email VARCHAR(190) NOT NULL, email VARCHAR(190) NOT NULL,
campaign_id INT NOT NULL, campaign_id INT NOT NULL,
+210
View File
@@ -0,0 +1,210 @@
// Database-backed data documents (Marty 2026-11-13, standing rule: "everything database-driven ... files only for early
// prototyping"). Every *.json / *.jsonl data document under DATA_DIR that a module reads or writes with the fs *Sync calls lives
// in MySQL instead of on the volume: table `docs` (name = path relative to DATA_DIR, body LONGTEXT, updated_at). The modules keep
// their code; install() routes their fs calls on those paths to an in-memory copy that init() loads from MySQL at boot, and every
// change is written through to MySQL (coalesced per document, newest body wins, in order, retried until it lands).
//
// One writer at a time: init() claims the `docs_writer` row; an older app copy still running during a deploy finds the row taken
// and stops writing (logged), so it can never put stale data over the new copy's (the 2026-11-13 rotator.json loss).
// First boot: a document missing from MySQL is imported from its file, and the file is renamed <name>.imported-<date> (kept, not
// read again). Files the volume keeps on purpose: KEEP (rebuildable caches, uploads, images, the geo database, queues read by
// listing a folder). The SAME file ships in InstantAdPay and LinkSpin.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const KEEP_FILES = new Set(['chain-index.json']); // a rebuildable cache of the blockchain
const KEEP_DIRS = ['uploads', 'geo', 'refuel-pending', 'backups', 'marks', 'kits', 'kitimg']; // binary files, or folders read by listing
const O = { readFileSync: fs.readFileSync, writeFileSync: fs.writeFileSync, existsSync: fs.existsSync, renameSync: fs.renameSync,
unlinkSync: fs.unlinkSync, statSync: fs.statSync, appendFileSync: fs.appendFileSync };
let ROOT = null, pool = null, ME = crypto.randomBytes(8).toString('hex'), ready = false, writer = true;
const cache = new Map(); // name -> { body: string, at: ms }
const pending = new Map(); // name -> body string | null (delete)
const stored = new Map(); // name -> body as last read from or written to MySQL: an unchanged save is not rewritten (2026-11-15: whole-document rewrites filled core with 115 GB of binlogs)
let flushing = false, timer = null;
const stats = { writes: 0, deletes: 0, refused: 0, errors: 0, imported: 0, lastError: null };
function nameOf(p) {
if (!ROOT || typeof p !== 'string' || !/\.jsonl?$/i.test(p)) return null;
const abs = path.resolve(p); if (!abs.startsWith(ROOT + path.sep)) return null;
const rel = abs.slice(ROOT.length + 1).split(path.sep).join('/');
if (KEEP_FILES.has(rel) || KEEP_DIRS.some(d => rel === d || rel.startsWith(d + '/'))) return null;
return rel;
}
const enoent = p => { const e = new Error("ENOENT: no such file or directory, open '" + p + "'"); e.code = 'ENOENT'; e.errno = -2; e.path = p; return e; };
const enc = o => (typeof o === 'string' ? o : o && o.encoding) || null;
function put(name, body) {
cache.set(name, { body, at: Date.now() });
if (stored.get(name) === body) { pending.delete(name); return; } // same as what MySQL already holds: nothing to write
pending.set(name, body); kick();
}
function drop(name) { cache.delete(name); pending.set(name, null); kick(); }
function kick() { if (!timer) timer = setTimeout(() => { timer = null; flush().catch(() => {}); }, 300); }
async function flush() {
if (!pool || flushing || !pending.size) return;
flushing = true;
try {
for (const [name, body] of [...pending]) {
if (pending.get(name) !== body) continue; // replaced while we were busy: the newer body goes next round
if (!writer) { pending.delete(name); stats.refused++; continue; }
const c = await pool.getConnection();
try {
await c.beginTransaction();
const [[w]] = await c.query('SELECT owner FROM docs_writer WHERE id = 1 FOR UPDATE');
if (!w || w.owner !== ME) { await c.rollback(); writer = false; pending.delete(name); stats.refused++; console.error('docstore: another app copy took over writing; this copy stops writing'); continue; }
if (body === null) { await c.query('DELETE FROM docs WHERE name = ?', [name]); stats.deletes++; }
else { await c.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), updated_at = VALUES(updated_at)', [name, body, Date.now()]); stats.writes++; }
await c.commit();
if (body === null) stored.delete(name); else stored.set(name, body);
if (pending.get(name) === body) pending.delete(name);
} catch (e) { try { await c.rollback(); } catch (x) {} stats.errors++; stats.lastError = String(e.message).slice(0, 200); console.error('docstore write', name, e.message); }
finally { c.release(); }
}
} finally { flushing = false; if (pending.size) setTimeout(() => flush().catch(() => {}), 1000); }
}
// Route the fs *Sync calls on data documents. Installed before any module runs; until init() the documents read from disk.
function install(dataDir) {
if (ROOT) return; ROOT = path.resolve(dataDir);
fs.readFileSync = function (p, o) {
if (!ready && process.env.DOCSTORE_URL && nameOf(p)) console.error('docstore: read before init', p, new Error().stack.split('\n')[2]);
const n = ready ? nameOf(p) : null; if (!n) return O.readFileSync.apply(fs, arguments);
const d = cache.get(n); if (!d) throw enoent(p);
return enc(o) ? d.body : Buffer.from(d.body, 'utf8');
};
fs.existsSync = function (p) { const n = ready ? nameOf(p) : null; return n ? cache.has(n) : O.existsSync.apply(fs, arguments); };
fs.writeFileSync = function (p, data, o) {
const n = ready ? nameOf(p) : null; if (!n) return O.writeFileSync.apply(fs, arguments);
const flag = o && typeof o === 'object' ? o.flag : null;
const s = Buffer.isBuffer(data) ? data.toString('utf8') : String(data);
put(n, flag && flag[0] === 'a' ? ((cache.get(n) || {}).body || '') + s : s);
};
fs.appendFileSync = function (p, data) {
const n = ready ? nameOf(p) : null; if (!n) return O.appendFileSync.apply(fs, arguments);
put(n, ((cache.get(n) || {}).body || '') + (Buffer.isBuffer(data) ? data.toString('utf8') : String(data)));
};
fs.renameSync = function (a, b) {
const nb = ready ? nameOf(b) : null; const na = ready ? nameOf(a) : null;
if (!nb && !na) return O.renameSync.apply(fs, arguments);
let body;
if (na) { const d = cache.get(na); if (!d) throw enoent(a); body = d.body; drop(na); }
else { body = O.readFileSync.call(fs, a, 'utf8'); try { O.unlinkSync.call(fs, a); } catch (e) {} }
if (nb) put(nb, body); else O.writeFileSync.call(fs, b, body);
};
fs.unlinkSync = function (p) { const n = ready ? nameOf(p) : null; if (!n) return O.unlinkSync.apply(fs, arguments); if (!cache.has(n)) throw enoent(p); drop(n); };
fs.statSync = function (p, o) {
const n = ready ? nameOf(p) : null; if (!n) return O.statSync.apply(fs, arguments);
const d = cache.get(n); if (!d) { if (o && o.throwIfNoEntry === false) return undefined; throw enoent(p); }
const size = Buffer.byteLength(d.body, 'utf8'); const t = new Date(d.at);
return { size, mtimeMs: d.at, mtime: t, ctime: t, birthtime: t, isFile: () => true, isDirectory: () => false, isSymbolicLink: () => false };
};
}
// Connect, claim writing, load every document, import files MySQL does not have yet. Throws if MySQL is unreachable: the app
// must not run on an empty copy.
async function init(opts) {
const url = String(process.env.DOCSTORE_URL || '').trim();
if (!url) { console.log('docstore: no DOCSTORE_URL, documents stay files (prototype mode)'); return false; }
const mysql = require('mysql2/promise');
pool = mysql.createPool({ uri: url, connectionLimit: 6, charset: 'utf8mb4' });
await pool.query('CREATE TABLE IF NOT EXISTS docs (name VARCHAR(190) PRIMARY KEY, body LONGTEXT NOT NULL, updated_at BIGINT NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
await pool.query('CREATE TABLE IF NOT EXISTS docs_writer (id TINYINT PRIMARY KEY, owner VARCHAR(40) NOT NULL, at BIGINT NOT NULL) ENGINE=InnoDB');
await pool.query('INSERT INTO docs_writer (id, owner, at) VALUES (1, ?, ?) ON DUPLICATE KEY UPDATE owner = VALUES(owner), at = VALUES(at)', [ME, Date.now()]);
const [rows] = await pool.query('SELECT name, body, updated_at FROM docs');
for (const r of rows) { cache.set(r.name, { body: r.body, at: Number(r.updated_at) }); stored.set(r.name, r.body); }
for (const sp of (opts && opts.splits) || []) await openSplit(sp);
// first boot for any document: import its file, then set the file aside
const stamp = new Date().toISOString().slice(0, 10);
const walk = dir => { let out = []; let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) {} for (const e of ents) { const p = path.join(dir, e.name); if (e.isDirectory()) out = out.concat(walk(p)); else out.push(p); } return out; };
for (const p of walk(ROOT)) {
const n = nameOf(p); if (!n || cache.has(n)) continue;
const body = O.readFileSync.call(fs, p, 'utf8');
if (/\.json$/i.test(n) && body.trim()) { try { JSON.parse(body); } catch (e) { throw new Error('docstore: ' + n + ' is not valid JSON; fix or move it before switching to MySQL'); } }
await pool.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE name = name', [n, body, Date.now()]);
const [[got]] = await pool.query('SELECT body FROM docs WHERE name = ?', [n]);
cache.set(n, { body: got.body, at: Date.now() }); stats.imported++;
O.renameSync.call(fs, p, p + '.imported-' + stamp);
}
for (const sp of (opts && opts.splits) || []) await migrateSplit(sp);
ready = true;
console.log('docstore: MySQL documents ready,', cache.size, 'documents,', stats.imported, 'imported from files this boot');
const shut = () => { flush().catch(() => {}).finally(() => {}); };
process.once('beforeExit', shut);
return true;
}
// ---- row tables: an ever-growing array (spin-link clicks) is one row per item, never a rewrite of the whole document ----
// spec { doc: 'rotator.json', field: 'hits', table: 'rot_hits', key: 'id', ts: 'ts' }. rows(table) gives the loaded items (oldest
// first); the module inserts / deletes rows itself and saves its document WITHOUT the field.
const ROWS = new Map(); const rowQ = []; let rowBusy = false;
async function openSplit(sp) {
await pool.query('CREATE TABLE IF NOT EXISTS `' + sp.table + '` (id VARCHAR(64) PRIMARY KEY, ts BIGINT NOT NULL, body MEDIUMTEXT NOT NULL, KEY ts (ts)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
const [r] = await pool.query('SELECT body FROM `' + sp.table + '` ORDER BY ts, id');
ROWS.set(sp.table, r.map(x => JSON.parse(x.body)));
}
async function insertMany(table, items, key, ts) {
for (let i = 0; i < items.length; i += 500) {
const part = items.slice(i, i + 500);
await pool.query('INSERT INTO `' + table + '` (id, ts, body) VALUES ? ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [part.map(x => [String(x[key]), Number(x[ts]) || 0, JSON.stringify(x)])]);
}
}
// first boot: the array still inside the document moves to its table, then the document is saved without it
async function migrateSplit(sp) {
const d = cache.get(sp.doc); if (!d) return;
let obj; try { obj = JSON.parse(d.body); } catch (e) { return; }
const arr = Array.isArray(obj[sp.field]) ? obj[sp.field] : null; if (!arr || !arr.length) return;
await insertMany(sp.table, arr, sp.key, sp.ts);
const [[{ n }]] = await pool.query('SELECT COUNT(*) n FROM `' + sp.table + '`');
if (n < arr.length) throw new Error('docstore: ' + sp.table + ' holds ' + n + ' rows after moving ' + arr.length + '; stopping before the document is changed');
const seen = new Set((ROWS.get(sp.table) || []).map(x => String(x[sp.key]))); const merged = (ROWS.get(sp.table) || []).concat(arr.filter(x => !seen.has(String(x[sp.key]))));
merged.sort((a, b) => (Number(a[sp.ts]) || 0) - (Number(b[sp.ts]) || 0)); ROWS.set(sp.table, merged);
obj[sp.field] = []; const body = JSON.stringify(obj);
await pool.query('UPDATE docs SET body = ?, updated_at = ? WHERE name = ?', [body, Date.now(), sp.doc]); cache.set(sp.doc, { body, at: Date.now() });
console.log('docstore:', arr.length, sp.field, 'moved from', sp.doc, 'to table', sp.table);
}
function rows(table) { return ROWS.get(table) || null; }
function rowOp(op) { if (!pool || !writer) return; rowQ.push(op); if (!rowBusy) runRows(); }
async function runRows() {
rowBusy = true;
try {
while (rowQ.length && writer) {
const op = rowQ[0];
try {
if (op.del) await pool.query('DELETE FROM `' + op.table + '` WHERE id IN (?)', [op.ids]);
else await pool.query('INSERT INTO `' + op.table + '` (id, ts, body) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [op.id, op.ts, op.body]);
rowQ.shift();
} catch (e) { stats.errors++; stats.lastError = String(e.message).slice(0, 200); await new Promise(r => setTimeout(r, 1000)); }
}
} finally { rowBusy = false; }
}
const rowPut = (table, id, ts, obj) => rowOp({ table, id: String(id), ts: Number(ts) || 0, body: JSON.stringify(obj) });
const rowDel = (table, ids) => { const list = [...ids].map(String); for (let i = 0; i < list.length; i += 1000) rowOp({ table, del: true, ids: list.slice(i, i + 1000) }); };
function isOn() { return ready && !!pool; }
// once across app copies (two run side by side during a deploy): true for the first caller of a key, false after. Without MySQL: true.
async function claim(key) {
if (!pool) return true;
await pool.query('CREATE TABLE IF NOT EXISTS doc_claims (k VARCHAR(190) PRIMARY KEY, at BIGINT NOT NULL) ENGINE=InnoDB');
const [r] = await pool.query('INSERT IGNORE INTO doc_claims (k, at) VALUES (?, ?)', [String(key).slice(0, 190), Date.now()]);
return r.affectedRows === 1;
}
// SIGTERM during a deploy: write what is pending, then exit
async function drain(ms) { const end = Date.now() + (ms || 8000); while ((pending.size || flushing || rowQ.length || rowBusy) && Date.now() < end) { await flush().catch(() => {}); await new Promise(r => setTimeout(r, 100)); } }
function view() { return Object.assign({ ready, writer, documents: cache.size, pending: pending.size, rowQueue: rowQ.length, rowTables: Object.fromEntries([...ROWS].map(([k, v]) => [k, v.length])), bytes: [...cache.values()].reduce((t, d) => t + d.body.length, 0) }, stats); }
const names = () => [...cache.keys()]; // every document name (the member erase walks them all, 2026-11-15)
// member erase (2026-11-15): count or delete the rows of a row table whose JSON body has `field` (e.g. '$.r') in `values`. Waits
// for queued row writes first, so a click queued before the erase cannot land after it.
async function rowsWhere(table, field, values, del) {
if (!pool || !values.length) return 0;
for (let i = 0; i < 100 && (rowQ.length || rowBusy); i++) await new Promise(r => setTimeout(r, 100));
const vals = values.map(String); const where = 'CAST(JSON_UNQUOTE(JSON_EXTRACT(body, ?)) AS CHAR) IN (?)';
if (!del) { const [[r]] = await pool.query('SELECT COUNT(*) n FROM `' + table + '` WHERE ' + where, [field, vals]); return Number(r.n); }
if (!writer) return 0;
const [r] = await pool.query('DELETE FROM `' + table + '` WHERE ' + where, [field, vals]);
const mem = ROWS.get(table); if (mem) { const k = field.replace(/^\$\./, ''); ROWS.set(table, mem.filter(x => !vals.includes(String(x[k])))); }
return Number(r.affectedRows || 0);
}
module.exports = { install, init, drain, flush, view, nameOf, rows, rowPut, rowDel, isOn, claim, names, rowsWhere };
+158
View File
@@ -0,0 +1,158 @@
// The Engine Room (Fuel Your Offers stage 4, Marty approved the build 2026-10-24). The SAME file ships in InstantAdPay and
// LinkSpin. Each site gathers its OWN facts (facts shape below) and answers the other's signed /api/partner/engine call
// with them; build() turns both sites' facts + the refuel streak (InstantAdPay is its source of truth) + the member's goal
// into one plain dashboard: three dials, the streak panel, warning lights, six part lights and one "next move".
//
// facts (per site): { site: 'iap'|'linkspin', ok, credits: { available, inCampaigns }, campaigns: [{ id, name, type, status,
// budget, delivered, clicks, created }], clicksWeek, loginFree, buyUrl, adsUrl,
// LinkSpin only: goalsMonth, goalsCount, conv30, parts: { bannerSpin, spinLink, page, testing } each { state, note } }
// Everything is credits and counts. Nothing here is money or a promise.
'use strict';
const DAY = 86400000;
const n0 = v => (typeof v === 'number' && isFinite(v) ? v : Number(v) || 0);
const LINKS = {
iapBuy: 'https://instantadpay.com/my#buy', iapCampaigns: 'https://instantadpay.com/my#campaigns', iapTracking: 'https://instantadpay.com/my#conversions',
lsBuy: 'https://linkspin.app/credits#buy', lsAds: 'https://linkspin.app/ads', lsLinks: 'https://linkspin.app/links', lsBanner: 'https://linkspin.app/links#b', lsPages: 'https://linkspin.app/pages', lsConv: 'https://linkspin.app/conversions',
};
// 2026-10-25 (Marty: "the flow from InstantAdPay to LinkSpin is confusing"): every link points at the screen on the site the
// member is ON when that site can do the job (buy, campaigns, conversion goals: InstantAdPay's Campaigns > Conversion
// tracking card writes the same LinkSpin goals). Only LinkSpin-only tools (Banner Spin, spin links, pages) cross over, and
// engine-room.js tags those links with ?from=<site>&task=<key> so LinkSpin shows an arrival strip with the first step.
const linksFor = site => site === 'linkspin'
? { buy: LINKS.lsBuy, campaigns: LINKS.lsAds, tracking: LINKS.lsConv }
: { buy: LINKS.iapBuy, campaigns: LINKS.iapCampaigns, tracking: LINKS.iapTracking };
const ACTIVE = new Set(['active', 'paused']);
// credits a day across recent campaigns: what each delivered over the days it has run (30 at most), summed
function burnPerDay(camps, now) {
let b = 0;
for (const c of camps) {
const age = Math.max(1, Math.min(30, (now - n0(c.created)) / DAY));
if (c.status !== 'active' && now - n0(c.created) > 30 * DAY) continue;
b += n0(c.delivered) / age;
}
return b;
}
function part(state, label, note, link, key) { return { state, label, note, link, key }; }
function build(o) {
const now = o.now || Date.now();
const rf = o.refuel || { on: false };
if (!rf.on) return { on: false };
const sites = [o.iap, o.ls].filter(f => f && f.ok);
const camps = sites.flatMap(f => (f.campaigns || []).map(c => Object.assign({ site: f.site }, c)));
const recent = camps.filter(c => ACTIVE.has(c.status) || now - n0(c.created) <= 30 * DAY || c.status === 'out');
const locked = !rf.started;
const here = o.site === 'linkspin' ? 'linkspin' : 'iap', L = linksFor(here);
// ---- dial 1: fuel left vs this cycle's refuel ----
const left = sites.reduce((s, f) => s + n0(f.credits && f.credits.available) + n0(f.credits && f.credits.inCampaigns), 0);
const cy = rf.cycle || null;
const refuelCredits = cy ? ['iap', 'linkspin'].reduce((s, k) => s + (cy[k] && cy[k].refueled ? n0(cy[k].credits) + n0(cy[k].bonus) : 0), 0) : 0;
const burn = burnPerDay(recent, now);
const daysLeft = burn > 0 ? Math.floor(left / burn) : null;
const fuel = { left: Math.round(left), refuelCredits: Math.round(refuelCredits), pct: refuelCredits > 0 ? Math.max(0, Math.min(100, Math.round(left / refuelCredits * 100))) : null,
burnPerDay: Math.round(burn), daysLeft, label: 'Fuel left' };
// ---- dial 2: clicks this week, and per 1,000 credits on recent campaigns ----
const clicksWeek = sites.reduce((s, f) => s + n0(f.clicksWeek), 0), clicksPrev = sites.reduce((s, f) => s + n0(f.clicksPrevWeek), 0);
const del = recent.reduce((s, c) => s + n0(c.delivered), 0), clk = recent.reduce((s, c) => s + n0(c.clicks), 0);
// the dial reads this week against last week: half way = the same as last week
const clicks = { week: clicksWeek, prevWeek: clicksPrev, pct: clicksPrev > 0 ? Math.min(100, Math.round(clicksWeek / (2 * clicksPrev) * 100)) : null, per1000: del >= 100 ? Math.round(clk / del * 1000 * 10) / 10 : null, label: 'Clicks this week' };
// ---- dial 3: goals this month (conversion pixel, LinkSpin keeps it for both sites) vs the member's own goal ----
const lsF = o.ls && o.ls.ok ? o.ls : null;
const goalTarget = Math.max(0, Math.round(n0(o.goal))) || null;
const goals = { month: lsF ? n0(lsF.goalsMonth) : null, target: goalTarget, pct: goalTarget && lsF ? Math.min(100, Math.round(n0(lsF.goalsMonth) / goalTarget * 100)) : null, tracking: lsF ? n0(lsF.goalsCount) > 0 : null, label: 'Goals this month' };
// ---- warning lights ----
const low = camps.filter(c => c.status === 'active' && n0(c.budget) > 0 && n0(c.delivered) >= n0(c.budget) * 0.8);
const out = camps.filter(c => c.status === 'out' && now - n0(c.created) <= 60 * DAY);
const running = camps.filter(c => c.status === 'active');
const refuelSoon = rf.active && rf.daysToRefuel != null && rf.daysToRefuel <= 5;
const loginFree = sites.filter(f => n0(f.loginFree) > 0).map(f => f.site);
const warnings = [
{ key: 'low', on: low.length > 0, label: 'Ads at 80%', note: low.length ? low.length + ' ad' + (low.length === 1 ? ' is' : 's are') + ' past 80% of budget' : 'none running low' },
{ key: 'out', on: out.length > 0, label: 'Ads out', note: out.length ? out.length + ' ad' + (out.length === 1 ? '' : 's') + ' finished delivering' + (running.length ? '' : ', nothing running now') : 'none out' },
{ key: 'refuel', on: !!refuelSoon, label: 'Refuel day coming', note: rf.active ? (rf.windowOpen ? 'window open: refuel day ' + rf.refuelDayLabel : 'refuel day ' + rf.refuelDayLabel) : 'no refuel day yet' },
{ key: 'login', on: loginFree.length > 0, label: 'Login slot open', note: loginFree.length ? 'a login-ad slot is free on ' + loginFree.map(s => s === 'iap' ? 'InstantAdPay' : 'LinkSpin').join(' and ') : 'all login slots taken' },
];
// ---- the six parts ----
const P = (lsF && lsF.parts) || {};
const pFuel = !camps.length ? part('grey', 'Fuel', 'no ads yet', L.campaigns, 'ads')
: out.length && !running.length ? part('amber', 'Fuel', 'nothing running', L.campaigns, 'ads')
: low.length || (daysLeft != null && daysLeft < 5) ? part('amber', 'Fuel', daysLeft != null && daysLeft < 5 ? 'about ' + daysLeft + ' days left at your burn' : 'an ad is running low', L.buy, 'refuel')
: running.length ? part('green', 'Fuel', running.length + ' ad' + (running.length === 1 ? '' : 's') + ' running', L.campaigns, 'ads') : part('amber', 'Fuel', 'nothing running', L.campaigns, 'ads');
const pick = (k, label, link, key) => { const x = P[k]; return x ? part(x.state, label, x.note, link, key) : part('grey', label, lsF ? 'not set up' : 'LinkSpin did not answer', link, key); };
const parts = [pFuel, pick('bannerSpin', 'Banner spin', LINKS.lsBanner, 'bannerspin'), pick('spinLink', 'Spin link', LINKS.lsLinks, 'spinlink'), pick('page', 'Page', LINKS.lsPages, 'page'), pick('testing', 'Testing', LINKS.lsLinks, 'testing'),
lsF ? (n0(lsF.goalsCount) === 0 ? part('grey', 'Conversion tracking', 'no goal set', L.tracking, 'conversions') : n0(lsF.conv30) === 0 ? part('amber', 'Conversion tracking', 'no conversions tracked yet', L.tracking, 'conversions') : part('green', 'Conversion tracking', n0(lsF.conv30) + ' in 30 days', L.tracking, 'conversions'))
: part('grey', 'Conversion tracking', 'LinkSpin did not answer', L.tracking, 'conversions')];
// ---- one next move ----
const per1000 = c => n0(c.delivered) >= 200 ? n0(c.clicks) / n0(c.delivered) * 1000 : null;
const ranked = running.filter(c => per1000(c) != null).sort((a, b) => per1000(b) - per1000(a));
const linkFor = c => c.site === 'linkspin' ? LINKS.lsAds : LINKS.iapCampaigns;
const availAll = sites.reduce((s, f) => s + n0(f.credits && f.credits.available), 0);
let next;
const mIap = rf.minUsd ? rf.minUsd.iap : 20, mLs = rf.minUsd ? rf.minUsd.linkspin : 25;
const firstWhy = here === 'linkspin' ? 'A package of $' + mLs + ' or more here (or $' + mIap + '+ on InstantAdPay) starts the streak and lights this room.' : 'A package of $' + mIap + ' or more here (or $' + mLs + '+ on LinkSpin) starts the streak and lights this room.';
if (locked) next = { key: 'start', label: 'Refuel to start your engine', why: firstWhy, link: L.buy, guide: '/refuel' };
else if (rf.windowOpen) next = { key: 'refuel', label: 'Refuel now', why: 'Your refuel window is open: +' + rf.next.single + '% on one site, +' + rf.next.both + '% on each with both. A $' + (here === 'linkspin' ? mLs : mIap) + '+ package here counts.', link: L.buy, guide: '/refuel' };
else if (out.length && !running.length && availAll >= 100) next = { key: 'relaunch', label: 'Relaunch an ad', why: 'Nothing is running and you have ' + Math.round(availAll).toLocaleString('en-US') + ' credits free.', link: linkFor(out[0]) };
else if (daysLeft != null && daysLeft < 5) next = { key: 'pitstop', label: 'Top up' + (rf.pitStop && (rf.pitStop.iap || rf.pitStop.linkspin) ? ' (Pit Stop +' + rf.pitStop.pct + '%)' : ''), why: 'About ' + daysLeft + ' days of fuel left at your current burn.', link: L.buy };
else if (low.length) { const best = low.slice().sort((a, b) => (per1000(b) || 0) - (per1000(a) || 0))[0]; next = { key: 'topup', label: 'Top up the winner', why: '"' + (best.name || 'your ad') + '" is past 80% of its budget.', link: linkFor(best) }; }
else if (parts[5].state === 'grey') next = { key: 'tracking', label: 'Set up conversion tracking', why: here === 'linkspin' ? 'Count signups and sales back to the ad that sent them. Step 1: add a goal, then paste its two snippets on your pages.' : 'Count signups and sales back to the ad that sent them. Step 1: add a goal under Campaigns > Conversion tracking, then paste its two snippets on your pages.', link: parts[5].link, guide: '/conversion-tracking' };
else if (parts[1].state === 'grey') next = { key: 'bannerspin', label: 'Make a Banner Spin', why: 'Test up to 5 banners in one ad slot and let the winner show.' + (here === 'linkspin' ? '' : ' Banner Spin is a LinkSpin tool: the same email signs you in there.'), link: LINKS.lsBanner };
else if (parts[4].state !== 'green') next = { key: 'testing', label: 'Test A against B', why: 'Add a second page to your spin link so the rotation can pick a winner.' + (here === 'linkspin' ? '' : ' Spin links live on LinkSpin: the same email signs you in there.'), link: LINKS.lsLinks };
else if (ranked.length >= 2 && per1000(ranked[0]) > per1000(ranked[ranked.length - 1]) * 1.5) { const worst = ranked[ranked.length - 1]; next = { key: 'cut', label: 'Cut the loser', why: '"' + (worst.name || 'an ad') + '" brings the fewest clicks per 1,000 credits. Pause it and move the credits to "' + (ranked[0].name || 'your best ad') + '".', link: linkFor(worst) }; }
else next = { key: 'cruise', label: 'Keep it running', why: 'Every part is lit. Check again on your refuel day.', link: L.campaigns };
return {
on: true, locked, fuel, clicks, goals,
streak: { active: !!rf.active, months: rf.streak || 0, best: rf.best || 0, refuelDay: rf.refuelDayLabel || null, graceEnd: rf.graceLabel || null, windowOpen: !!rf.windowOpen, next: rf.next || null, pitStop: rf.pitStop || null, freeMiss: rf.freeMiss || null, both: !!(cy && cy.both), note: streakNote(rf, cy) },
warnings, parts, next, site: here, sites: { iap: !!(o.iap && o.iap.ok), linkspin: !!(o.ls && o.ls.ok) }, at: now,
};
}
// this site's own facts for one member. d: { site, adminMember, ads, coach, now?, bannerspin?, rotator?, pages?, convtrack? }
const monthStartCT = now => { const day = new Date(now).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); const [y, m] = day.split('-').map(Number);
for (const off of [5, 6]) { const ts = Date.UTC(y, m - 1, 1, off); const t = new Date(ts); if (t.toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) === day.slice(0, 8) + '01' && Number(t.toLocaleString('en-US', { timeZone: 'America/Chicago', hour: 'numeric', hour12: false })) % 24 === 0) return ts; } return Date.UTC(y, m - 1, 1, 6); };
async function facts(d, email) {
const now = d.now || Date.now(); const e = String(email || '').toLowerCase();
const out = { site: d.site, ok: true, credits: { available: 0, inCampaigns: 0 }, campaigns: [], clicksWeek: 0, loginFree: 0 };
try { const v = await d.adminMember.view(e); if (v && v.credits) out.credits = { available: n0(v.credits.available), inCampaigns: n0(v.credits.inCampaigns) }; } catch (er) {}
let list = []; try { list = (await d.ads.listCampaigns(e)).filter(c => !c.house && c.type !== 'game'); } catch (er) {}
out.campaigns = list.map(c => ({ id: c.id, name: c.name || null, type: c.type, status: c.status, budget: n0(c.budget), delivered: n0(c.spent), clicks: n0(c.clicks), created: n0(c.created) }));
try { out.clicksWeek = await d.coach.clicksSince(list.map(c => c.id), now - 7 * DAY); out.clicksPrevWeek = Math.max(0, (await d.coach.clicksSince(list.map(c => c.id), now - 14 * DAY)) - out.clicksWeek); } catch (er) {}
try { out.loginFree = n0((await d.ads.loginSlots()).free); } catch (er) {}
if (d.site === 'linkspin') {
const since30 = now - 30 * DAY;
try { out.goalsCount = d.convtrack.goalsOf(e).length; out.goalsMonth = d.convtrack.countSince(e, monthStartCT(now)); out.conv30 = d.convtrack.countSince(e, since30); } catch (er) { out.goalsCount = 0; out.goalsMonth = 0; out.conv30 = 0; }
const parts = {};
let spins = [], rots = [], pgs = [];
try { spins = await d.bannerspin.list(e); } catch (er) {}
try { rots = await d.rotator.list(e); } catch (er) {}
try { pgs = await d.pages.list(e); } catch (er) {}
const liveB = s => s.banners.filter(b => b.active && !b.adminOff);
if (!spins.length) parts.bannerSpin = { state: 'grey', note: 'not set up' };
else { const seen = spins.filter(s => !s.paused && s.imps30 > 0); parts.bannerSpin = seen.length ? { state: 'green', note: seen.reduce((n, s) => n + s.imps30, 0).toLocaleString('en-US') + ' views in 30 days' } : { state: 'amber', note: 'no views yet' }; }
if (!rots.length) parts.spinLink = { state: 'grey', note: 'not set up' };
else { const w = rots.reduce((n, r) => n + n0(r.hits7), 0); parts.spinLink = w > 0 ? { state: 'green', note: w.toLocaleString('en-US') + ' clicks this week' } : { state: 'amber', note: 'no clicks this week' }; }
const pub = pgs.filter(p => p.status === 'published');
parts.page = !pgs.length ? { state: 'grey', note: 'not set up' } : !pub.length ? { state: 'amber', note: 'draft only, not published' } : pub.some(p => n0(p.views) > 0) ? { state: 'green', note: pub.length + ' published' } : { state: 'amber', note: 'published, no views yet' };
const rotTest = rots.some(r => !r.paused && r.destinations.filter(x => x.active).length >= 2);
const rotTraffic = rots.some(r => !r.paused && r.destinations.filter(x => x.active && x.hits7 > 0).length >= 2);
const bsTest = spins.some(s => !s.paused && liveB(s).length >= 2);
const bsTraffic = spins.some(s => !s.paused && liveB(s).filter(b => b.imps30 > 0).length >= 2);
parts.testing = rotTraffic || bsTraffic ? { state: 'green', note: 'two or more versions getting traffic' } : rotTest || bsTest ? { state: 'amber', note: 'two versions set up, waiting for traffic' } : (rots.length || spins.length) ? { state: 'amber', note: 'only one version: add a second to test' } : { state: 'grey', note: 'not set up' };
out.parts = parts;
}
return out;
}
// the streak panel's one line about the next refuel (2026-10-24): once BOTH sites are refueled this cycle it says so,
// and only a cycle with one site done asks for the other one, by name
function streakNote(rf, cy) {
const nx = rf && rf.next; if (!rf || !rf.active || !nx) return '';
if (rf.windowOpen) return 'Window open: next refuel +' + nx.single + '% (+' + nx.both + '% on each with both).';
const iapDone = !!(cy && cy.iap && cy.iap.refueled), lsDone = !!(cy && cy.linkspin && cy.linkspin.refueled);
if ((cy && cy.both) || (iapDone && lsDone)) return 'Both engines fueled this cycle: +' + (nx.secondEngine || (cy.iap && cy.iap.pct) || 0) + '% on each.';
if (nx.secondEngine) return 'Refuel ' + (iapDone ? 'LinkSpin' : 'InstantAdPay') + ' this cycle for +' + nx.secondEngine + '% on both.';
return '';
}
module.exports = { streakNote, build, facts, burnPerDay, monthStartCT, LINKS };
+120
View File
@@ -0,0 +1,120 @@
// Member erase (Marty 2026-11-15, ticket LS-1021: "I want delete my account data from all your sites"). One named admin action
// that takes a person out of LinkSpin from INSIDE the running app, so the documents the modules keep in memory and the MySQL
// `docs` rows stay consistent (an edit straight in the database would be written back over by the next save).
// POST /api/admin/erase {email, dryRun (default true), force} (admin) and the hub's member.erased event (hubsync.js)
// Refused unless force: a linked main wallet, an on-chain member number, linked positions, anyone sponsored under them here,
// an ad still running or queued. What goes:
// - the account (accounts.removeAccount), their spin links with every click row (rot_hits) and conversion (rotator.eraseOwner);
// - every data document that mentions them (scrub.js: their keys, list items and records; another member's record only loses
// the pointer), through the owning module's live copy when it keeps one in memory, else read and written through docstore:
// accounts, audiences, coach, convtrack, earned (their unspent credits simply go away), hubsync, iapsync, mail-intro,
// postbacks, registry, rotator, sponsorfollow, updates-log, and any other document that names them.
// Their help-desk tickets live in the shared InstantAdPay desk (InstantAdPay's erase scrubs those). A tombstone (SHA-256 of the
// email, kept 30 days in erase.json) stops the InstantAdPay registry sync and hub events from bringing them back while the other
// sites catch up. The log keeps hashes and counts, never the email. Dry run = the same counts, nothing changed.
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const { scrubDeep, scrubText, mentions } = require('./scrub');
let R = null; // { dataDir, accounts, ads, rotator, docstore, owners: {doc: {state, save}}, reload: {doc: fn}, forget: [fn(email)] }
const TOMB_MS = 30 * 86400000;
const norm = v => String(v || '').trim().toLowerCase();
const hashOf = email => crypto.createHash('sha256').update(norm(email)).digest('hex');
const FILE = () => path.join(R.dataDir, 'erase.json');
let st = null;
function load() {
if (st) return st;
try { st = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { st = null; }
if (!st || typeof st !== 'object') st = {};
st.v = 1; st.tomb = st.tomb || {}; st.log = st.log || [];
return st;
}
function save() { try { const f = FILE(); fs.writeFileSync(f + '.tmp', JSON.stringify(load())); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('erase save', e.message); } }
function init(deps) { R = deps; st = null; load(); }
function isErased(email) {
const s = load(); const h = hashOf(email); const t = s.tomb[h];
if (!t) return false;
if (Date.now() - t > TOMB_MS) { delete s.tomb[h]; save(); return false; }
return true;
}
function docNames() {
if (R.docstore && R.docstore.isOn && R.docstore.isOn()) return R.docstore.names();
const out = []; const walk = (d, pre) => { let ents = []; try { ents = fs.readdirSync(d, { withFileTypes: true }); } catch (e) {} for (const x of ents) { const p = path.join(d, x.name); if (x.isDirectory()) walk(p, pre + x.name + '/'); else if (/\.jsonl?$/i.test(x.name)) out.push(pre + x.name); } };
walk(R.dataDir, ''); return out;
}
// every data document that mentions them: counted (dry run) or scrubbed, through the module that holds it in memory if any
function docs(needles, dryRun) {
const out = {};
for (const name of docNames()) {
if (name === 'erase.json') continue; // hashes only
const file = path.join(R.dataDir, name); let body;
try { body = fs.readFileSync(file, 'utf8'); } catch (e) { continue; }
if (!mentions(body, needles)) continue;
const own = R.owners[name];
try {
if (own) {
const live = own.state(); const n = scrubDeep(dryRun ? JSON.parse(JSON.stringify(live)) : live, needles);
if (!dryRun && n) own.save(); out[name] = n;
} else {
const r = scrubText(body, needles, /\.jsonl$/i.test(name));
if (!dryRun && r.removed) { fs.writeFileSync(file, r.body); if (R.reload && R.reload[name]) R.reload[name](); }
out[name] = r.removed;
}
} catch (e) { out[name] = 'error: ' + String(e.message).slice(0, 80); }
}
return out;
}
function docResidue(needles) { return docNames().filter(n => n !== 'erase.json').filter(n => { try { return mentions(fs.readFileSync(path.join(R.dataDir, n), 'utf8'), needles); } catch (e) { return false; } }); }
async function blockersOf(acct, E) {
const out = [];
if (acct.address) out.push('main wallet linked');
if (Number(acct.memberId) > 0) out.push('on-chain member #' + acct.memberId);
try { const pos = await R.accounts.positions(E); if (pos && pos.length) out.push('linked positions: ' + pos.length); } catch (e) {}
const refs = [acct.username, acct.code].filter(Boolean).map(norm);
if (refs.length) { const team = (await R.accounts.listByReferrer(refs)).filter(a => norm(a.email) !== E); if (team.length) out.push('sponsored under them here: ' + team.length); }
try { const live = ((R.ads && await R.ads.listCampaigns(E)) || []).filter(c => ['active', 'queued', 'paused'].includes(c.status)); if (live.length) out.push('ads still running or queued: ' + live.length); } catch (e) {}
return out;
}
// email -> {ok, dryRun, emailHash, found, blockers, account, spinLinks, docs: {doc: removed}, docResidue}
async function erase(email, opts) {
const o = Object.assign({ dryRun: true, force: false, by: 'admin', sweep: true }, opts || {});
const E = norm(email); if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E)) return { error: 'A valid email is required.' };
const h = hashOf(E); const acct = await R.accounts.byEmail(E);
const exact = acct ? [acct.username, acct.code].filter(Boolean).map(norm) : [];
const needles = { emails: [E], exact };
const blockers = acct ? await blockersOf(acct, E) : [];
const res = { dryRun: !!o.dryRun, emailHash: h, found: !!acct, blockers, forced: !!o.force && blockers.length > 0, account: 0, spinLinks: null, docs: {} };
if (blockers.length && !o.force && !o.dryRun) return Object.assign(res, { error: 'Not erased: ' + blockers.join('; ') + '. Send force: true to erase anyway.' });
if (!o.dryRun) { load().tomb[h] = Date.now(); save(); } // before anything goes: the syncs refuse them from here on
if (acct) { if (o.dryRun) res.account = 1; else { const r = await R.accounts.removeAccount(E); res.account = r && r.ok ? 1 : 0; } }
if (R.rotator && R.rotator.eraseOwner) res.spinLinks = await R.rotator.eraseOwner(E, o.dryRun);
res.docs = docs(needles, o.dryRun);
if (!o.dryRun) for (const f of R.forget || []) { try { f(E); } catch (e) {} } // caches that are not documents (hub lookups, pending pushes)
for (const k of Object.keys(res.docs)) if (!res.docs[k]) delete res.docs[k];
if (o.sweep) res.docResidue = o.dryRun ? [] : docResidue(needles);
if (!o.dryRun) {
const s = load(); s.log.push({ at: Date.now(), by: String(o.by).slice(0, 20), hash: h.slice(0, 16), forced: res.forced, found: res.found,
spinLinks: res.spinLinks ? res.spinLinks.rotations : 0, docs: Object.keys(res.docs).length, residue: (res.docResidue || []).length });
if (s.log.length > 500) s.log = s.log.slice(-500); save();
console.log('member erase', h.slice(0, 16), 'by', o.by, 'account', res.account, 'spin links', JSON.stringify(res.spinLinks), 'docs', JSON.stringify(res.docs));
}
res.ok = true; return res;
}
// the hub's member.erased event carries only the SHA-256 of the email: find who here has it
async function byHash(hash, by) {
const h = norm(hash); if (!/^[0-9a-f]{64}$/.test(h)) return { result: 'bad-hash' };
let email = null;
for (const a of await R.accounts.listAll(1e7, { shells: true })) if (hashOf(a.email) === h) { email = norm(a.email); break; }
if (!email) { const s = load(); s.tomb[h] = Date.now(); save(); return { result: 'not-here' }; }
const r = await erase(email, { dryRun: false, by: by || 'hub', sweep: false });
return { result: r.error ? 'refused' : 'erased', error: r.error || null, docs: r.docs };
}
function view() { const s = load(); return { tombstones: Object.keys(s.tomb).length, recent: s.log.slice(-20).reverse() }; }
module.exports = { init, erase, byHash, isErased, hashOf, view, _reset: () => { st = null; } };
+8 -3
View File
@@ -60,6 +60,8 @@ const frameBlocked = h => {
return false; return false;
}; };
// classify one URL -> { state, code, ms, note, frameBlocked, finalUrl } // classify one URL -> { state, code, ms, note, frameBlocked, finalUrl }
// a spin-link destination as a click with no params reaches it: every {macro} empty (2026-11-14, the network links carry {s1}/{s2})
const fillEmpty = u => String(u || '').replace(/\{[a-z0-9_]{1,24}\}/gi, '');
async function check(url) { async function check(url) {
const t0 = Date.now(); const t0 = Date.now();
let out = { state: 'dead', code: 0, ms: 0, note: '', frameBlocked: false, finalUrl: url }; let out = { state: 'dead', code: 0, ms: 0, note: '', frameBlocked: false, finalUrl: url };
@@ -108,10 +110,12 @@ function apply(r, d, c) {
} }
return null; return null;
} }
const toldToday = new Set();
async function tell(r, d, change) { async function tell(r, d, change) {
if (!notify || !change || change.kind !== 'paused' || /^demo:/.test(r.owner)) return; 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 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><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>'; + '<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) {} try { await notify(r.owner, 'A destination in ' + r.name + ' was paused', html); } catch (e) {}
@@ -225,7 +229,7 @@ async function tick() {
for (const d of r.destinations) { for (const d of r.destinations) {
const due = d.active || (d.autoPaused && (!d.health || now - (d.health.checkedAt || 0) >= RECHECK_PAUSED)); const due = d.active || (d.autoPaused && (!d.health || now - (d.health.checkedAt || 0) >= RECHECK_PAUSED));
if (!due) continue; if (!due) continue;
jobs.push(async () => { const c = await check(d.url); const ch = apply(r, d, c); changed = true; n++; if (ch) await tell(r, d, ch); }); jobs.push(async () => { const c = await check(fillEmpty(d.url)); const ch = apply(r, d, c); changed = true; n++; 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 }; changed = true; }); 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 }; changed = true; });
} }
@@ -239,8 +243,9 @@ async function checkRotation(owner, id) {
const r = rotator.findMine(owner, id); if (!r) return { error: 'No such rotation.' }; const r = rotator.findMine(owner, id); if (!r) return { error: 'No such rotation.' };
const last = lastManual.get(r.id) || 0; if (Date.now() - last < MANUAL_GAP) return { error: 'Checked less than a minute ago. Give it a moment.' }; const last = lastManual.get(r.id) || 0; if (Date.now() - last < MANUAL_GAP) return { error: 'Checked less than a minute ago. Give it a moment.' };
lastManual.set(r.id, Date.now()); 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); }); const jobs = r.destinations.map(d => async () => { const c = await check(fillEmpty(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 (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(); await runAll(jobs); rotator.save();
return { ok: true, rotation: rotator.pub(r) }; return { ok: true, rotation: rotator.pub(r) };
} }
+66
View File
@@ -0,0 +1,66 @@
// House Banner Spins (Marty 2026-11-16: "no proper Banner Spins for your house ads"). The admin creates or updates Banner Spins
// on a house account (ADMIN_EMAIL or NETWORK_LINKS_OWNER, i.e. Marty's own account) for house ads such as the Network Ad Space
// rows, WITHOUT signing in as that member: no member session is read or minted. Every step goes through the same bannerspin.js
// calls the member Links screen uses (create, update, addBanner, updateBanner), with the account's email as the owner, so the
// checks (sizes, https images and targets, the source belonging to the account, the tier's banner count) are the member's.
// server.js wires it as POST /api/admin/house-spins (admin only) and writes every call to the admin action log (adminaudit.js).
//
// Body: { email, host?, spins: [ { id?, name, size, mode?, fallback?, sourceId?, paused?, prune?,
// banners: [ { label, image, target, weight?, active? } ] } ] }
// id given -> that Banner Spin (it must belong to the account) is updated; without id, a Banner Spin of the same name and size on
// the account is reused, else one is created. Banners match by image address: a match is updated, a new image is
// added, and with prune: true a banner whose image is no longer listed is removed.
// Reply: { ok, email, host, spins: [ { id, code, name, size, created, added, updated, removed, img, click, errors } ] }
'use strict';
let R = null; // { bannerspin, houseAccounts(): [email], host(wanted): the link domain (wanted when it is one of ours, else the first) }
function init(refs) { R = refs; }
const norm = e => String(e || '').trim().toLowerCase();
async function apply(body) {
const email = norm(body && body.email);
if (!email) return { error: 'Which account? Pass email.' };
if (!R.houseAccounts().includes(email)) return { error: 'House Banner Spins go on a house account only (the admin account).' };
const list = Array.isArray(body.spins) ? body.spins : [];
if (!list.length || list.length > 40) return { error: 'Pass 1 to 40 spins.' };
const BS = R.bannerspin; const host = R.host(body.host); const out = [];
for (const want of list) {
const row = { name: String(want.name || ''), size: String(want.size || ''), created: false, added: 0, updated: 0, removed: 0, errors: [] };
out.push(row);
let spin = null;
const mine = await BS.list(email);
if (want.id != null) { spin = mine.find(s => s.id === Number(want.id)) || null; if (!spin) { row.errors.push('No Banner Spin ' + want.id + ' on this account.'); continue; } }
else spin = mine.find(s => s.name === String(want.name || '').trim() && s.size === row.size) || null;
if (!spin) {
const r = await BS.create(email, { name: want.name, size: want.size, mode: want.mode, fallback: want.fallback });
if (r.error) { row.errors.push(r.error); continue; }
spin = r.spin; row.created = true;
}
const patch = {};
if (want.name != null && String(want.name).trim() !== spin.name) patch.name = want.name;
if (want.mode != null) patch.mode = want.mode;
if (want.fallback != null) patch.fallback = want.fallback;
if (want.sourceId != null) patch.sourceId = want.sourceId;
if (want.paused != null) patch.paused = !!want.paused;
if (Object.keys(patch).length) { const r = await BS.update(email, spin.id, patch); if (r.error) row.errors.push(r.error); else spin = r.spin; }
const banners = Array.isArray(want.banners) ? want.banners : [];
for (const b of banners) {
const have = spin.banners.find(x => x.image === String(b.image || '').trim());
if (have) {
const p = {}; if (b.label != null && b.label !== have.label) p.label = b.label; if (b.weight != null && Number(b.weight) !== have.weight) p.weight = b.weight;
if (b.target != null && b.target !== have.target) p.target = b.target; const act = b.active == null ? true : !!b.active; if (act !== have.active) p.active = act;
if (Object.keys(p).length) { const r = await BS.updateBanner(email, spin.id, have.id, p); if (r.error) row.errors.push(have.id + ': ' + r.error); else { spin = r.spin; row.updated++; } }
} else {
const r = await BS.addBanner(email, spin.id, { label: b.label, image: b.image, target: b.target, weight: b.weight });
if (r.error) row.errors.push(String(b.image).slice(0, 80) + ': ' + r.error); else { spin = r.spin; row.added++; }
}
}
if (want.prune) {
const keep = new Set(banners.map(b => String(b.image || '').trim()));
for (const x of spin.banners.filter(x => !keep.has(x.image))) { const r = await BS.updateBanner(email, spin.id, x.id, { remove: true }); if (r.error) row.errors.push(x.id + ': ' + r.error); else { spin = r.spin; row.removed++; } }
}
Object.assign(row, { id: spin.id, code: spin.code, name: spin.name, size: spin.size, sourceId: spin.sourceId || '', fallback: spin.fallback || '', banners: spin.banners.length,
img: 'https://' + host + '/i/' + spin.code + '.gif', click: 'https://' + host + '/c/' + spin.code });
}
return { ok: out.every(r => !r.errors.length), email, host, spins: out };
}
module.exports = { init, apply };
+54
View File
@@ -0,0 +1,54 @@
// The network AI ad writer, asked through the hub (Marty 2026-11-17: "the AI generation of the ads worked really well. Let's go
// ahead and do it on the other sites too."). The hub reads the member's page, asks the model and filters the copy
// (network-hub lib/adwriter.js); this file only signs the call for this site's signed-in member and passes the answer on.
// status(member?) -> {on, daily, left?} (cached 60 s; on: false when the hub is unset, unreachable or switched off)
// write(member, url, limits) -> {ok, options: [{headline, line?}], url, cached, left} | {error (member-friendly), code, status, left?}
// Signed as HUB_SITE with HUB_SECRET: X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + newline + raw body), like every /v1 call.
// AI_WRITER=0 hides the button on this site. Nothing is posted: the member picks an option, edits it and saves it themselves.
'use strict';
const crypto = require('crypto');
const DEFAULT_SITE = 'linkspin';
const hubUrl = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
const secret = () => String(process.env.HUB_SECRET || '').trim();
const site = () => String(process.env.HUB_SITE || DEFAULT_SITE).trim();
const configured = () => !/^(0|false|no|off)$/i.test(String(process.env.AI_WRITER || '').trim()) && !!hubUrl() && secret().length >= 32;
async function call(route, body, timeoutMs) {
const raw = JSON.stringify(body); const ts = String(Date.now());
const sig = crypto.createHmac('sha256', secret()).update(ts + '\n' + raw).digest('hex');
const r = await fetch(hubUrl() + route, { method: 'POST', body: raw, signal: AbortSignal.timeout(timeoutMs),
headers: { 'Content-Type': 'application/json', 'X-Hub-Site': site(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig } });
let j = null; try { j = await r.json(); } catch (e) { j = null; }
return { status: r.status, body: j || {} };
}
let st = { at: 0, v: { on: false, daily: 0 } };
async function status(member) {
if (!configured()) return { on: false, daily: 0 };
if (!member && Date.now() - st.at < 60000) return st.v;
try {
const r = await call('/v1/adwriter/status', member ? { member: String(member) } : {}, 3000);
const v = r.status === 200 && r.body && typeof r.body.on === 'boolean' ? r.body : { on: false, daily: 0 };
if (!member) st = { at: Date.now(), v: { on: v.on, daily: v.daily || 0 } };
return v;
} catch (e) { if (!member) st = { at: Date.now() - 45000, v: { on: false, daily: 0 } }; return { on: false, daily: 0 }; } // a down hub is asked again in 15 s
}
// the button shows only when the hub says the writer is on (60 s cache, never waits on a slow hub for long)
async function enabled() { return (await status()).on === true; }
async function write(member, url, limits) {
if (!configured()) return { error: 'The ad writer is switched off right now. You can still write your ad yourself.', code: 'off', status: 503 };
try {
const r = await call('/v1/adwriter', { member: String(member), url: String(url || '').trim().slice(0, 600), limits }, 75000);
const b = r.body || {};
if (r.status === 200 && b.ok && Array.isArray(b.options)) return { ok: true, options: b.options, url: b.url, cached: !!b.cached, left: b.left };
if (r.status === 401 || r.status === 403 || !b.message) { console.error('hubadwriter: hub answered ' + r.status + ' ' + String(b.error || '')); return { error: 'The ad writer is busy right now. Try again in a minute, or write your ad yourself.', code: 'hub', status: 502 }; }
return { error: String(b.message), code: b.error || b.code || 'error', status: r.status >= 400 && r.status < 600 ? r.status : 502, left: b.left };
} catch (e) {
console.error('hubadwriter: ' + (e.name === 'TimeoutError' || e.name === 'AbortError' ? 'timeout' : String(e.message).slice(0, 120)));
return { error: 'The ad writer did not answer in time. Try again in a minute, or write your ad yourself.', code: 'hub', status: 504 };
}
}
module.exports = { status, enabled, write, configured, _reset: () => { st = { at: 0, v: { on: false, daily: 0 } }; } };
+342
View File
@@ -0,0 +1,342 @@
// Network hub link (2026-11-12, Marty 2026-11-06: one membership from any door; the hub is the single identity; the contract
// sponsor is the truth; with no binding, the earliest join wins). Two directions, both OFF unless HUB_ENABLED=1:
// IN POST /api/hub/events body {events:[{seq, at, type, personId, data}]}, headers X-Hub-Ts (ms) + X-Hub-Sig = hex
// HMAC-SHA256(ts + "\n" + rawBody) with HUB_SECRET (network-hub lib/signing.js). Older than 5 minutes = refused. The hub
// only moves its cursor on a 2xx, so events can arrive twice: each seq is applied once (DATA_DIR/hubsync.json lastSeq).
// member.erased (2026-11-15): the hub erased someone; erase.js finds them by the SHA-256 of the email and takes them out.
// member.joined from another door: /v1/resolve {id} for the person, then the SAME waiting (shell) account the InstantAdPay
// registry sync makes (/api/partner/registry in server.js): accounts.ensure(email, '', 'carried', 'network'), then only
// EMPTY fields are filled (username, sponsor, wallet last, while carry.hold keeps activation off). The sponsor is placed
// first (up to 25 levels up) so the line exists. A sponsor already set here is never moved: a disagreement is logged.
// wallet.connected: fills an empty wallet here, same as the registry sync. Every other event is acknowledged and ignored
// (sponsor.changed included, on purpose). 2026-11-14: the sponsor written is person.locks.linkspin's sponsor when that lock
// exists (rule 2), and a wallet filled from the hub never switches payouts on (isQuiet): no gas, no lock, no mail.
// OUT accounts.onChange -> touch(email): a persisted outbox (DATA_DIR/hubsync.json) reports LinkSpin's own joins
// (/v1/join, sponsor named by email) and wallet links (/v1/wallet). Never blocks sign-up; failures retry with backoff.
// Gaps closed 2026-11-13 (Marty: "let's get the gaps report built"), still one way: a DELIBERATE sponsor change
// (sponsorfollow: adopt, rescue, release, expiry, admin) also goes to /v1/sponsor-change; BTC4Hits accounts (carried
// here with joinedRef 'btc4hits', no other door reports them) are reported like LinkSpin's own; every MemberActivated on
// the LinkSpin contract goes to /v1/contract-bind (contract 'linkspin', sponsor by wallet) from its own queue (binds).
// 2026-11-14: every paid Purchase goes to /v1/contract-spend (queue spends, after the binds) for the hub's rule 2.
// The InstantAdPay<->LinkSpin sync (iapsync.js, /api/partner/registry) is not touched by any of this.
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
let R = null, state = null, timer = null, flushing = false, inbound = Promise.resolve();
const ENABLED = () => /^(1|true|on|yes)$/i.test(String(process.env.HUB_ENABLED || '').trim());
const URL_ = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
const SECRET = () => String(process.env.HUB_SECRET || '').trim();
const SITE = () => String(process.env.HUB_SITE || 'linkspin').trim().toLowerCase();
const on = () => ENABLED() && SECRET().length >= 32 && /^https?:\/\//.test(URL_());
const WINDOW_MS = 5 * 60 * 1000;
const MAX_UP = 25; // how far up a sponsor line is placed for one event (bad data must not hang a request)
const FILE = () => path.join(R.dataDir, 'hubsync.json');
const norm = v => String(v || '').trim().toLowerCase();
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2'); // logs and the admin view never show a full address
function load() {
if (state) return state;
try { state = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { state = null; }
if (!state || typeof state !== 'object') state = {};
state.lastSeq = Number(state.lastSeq) || 0; state.outbox = state.outbox || {}; state.sent = state.sent || {};
state.disagree = state.disagree || {}; state.made = state.made || {}; /* made: waiting copies created here from hub events, email -> door */ state.stats = state.stats || { events: 0, shells: 0, filled: 0, joins: 0, wallets: 0, dropped: 0, errors: 0 };
return state;
}
function save() { try { fs.writeFileSync(FILE(), JSON.stringify(load())); } catch (e) {} }
function init(deps) { R = deps; state = null; load(); } // { dataDir, accounts, registry, carry, follow (sponsorfollow store) }
const sign = (ts, raw) => crypto.createHmac('sha256', SECRET()).update(String(ts) + '\n' + raw).digest('hex');
async function call(route, body, timeout) {
const raw = JSON.stringify(body); const ts = String(Date.now());
let r;
try { r = await fetch(URL_() + route, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Hub-Site': SITE(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sign(ts, raw) }, body: raw, signal: AbortSignal.timeout(timeout || 15000) }); }
catch (e) { throw new Error('hub ' + route + ' unreachable'); }
let out = null; try { out = await r.json(); } catch (e) {}
if (r.status >= 500 || r.status === 401) throw new Error('hub ' + route + ' ' + r.status); // down, redeploying (503) or misconfigured: try again later
return { status: r.status, body: out || {} };
}
async function resolveId(id) {
if (!id) return null;
const r = await call('/v1/resolve', { id });
return r.status === 200 && r.body.person ? r.body.person : null;
}
const refEmail = async ref => { if (!ref) return null; const a = (await R.accounts.byUsername(ref)) || (await R.accounts.byCode(ref)); return a ? norm(a.email) : null; };
function noteDisagree(e, hubSponsor, here, how) {
load().disagree[e] = { at: Date.now(), hub: hubSponsor || null, here: here || null, how }; save();
console.log('hubsync sponsor differs', how, mask(e));
}
// ---- inbound -------------------------------------------------------------------------------------------------------------
// Rule 2 (Marty 2026-11-14): the sponsor written here is the one the LinkSpin CONTRACT holds for them when it holds them
// (person.locks.linkspin, null = the top of that tree), never the plain network sponsor, which may come from another
// contract where they spent money. Each contract pays whoever it holds.
const CONTRACT = 'linkspin';
const sponsorFor = p => { const l = p && p.locks && p.locks[CONTRACT]; return l ? (l.sponsor || null) : ((p && p.sponsor) || null); };
// QUIET wallet fills (Marty 2026-11-14): accounts.onWalletLinked would have the engine switch payouts on for a wallet that lands
// here (carry.ensureOnChain: gas, a lock on the LinkSpin contract, the 'Your LinkSpin payouts are switched on' email and the
// chain-event mail and posts). A wallet filled from a hub event does none of that: server.js's wallet hook skips an email
// while isQuiet(email). The switch-on happens later the usual ways (the member's own Switch on payouts, or a purchase below).
const quiet = new Set(); const isQuiet = email => quiet.has(norm(email));
// a hub person gets a LinkSpin account the way an InstantAdPay person does: a waiting shell, empty fields filled, nothing moved.
// QUIET (Marty 2026-11-14, "join one = join all"): nothing here sends mail, a notice or a post; qa/hubsync.test.cjs checks it.
async function place(p, depth, seen) {
const e = norm(p.email); if (!e || p.blocked || seen.has(e)) return null; seen.add(e);
if (R.erased && R.erased(e)) return null; // erased here (erase.js, 2026-11-15): a hub event never brings them back
const ps = sponsorFor(p);
let sp = ps && ps.email ? await R.accounts.byEmail(ps.email) : null;
if (!sp && ps && ps.id && depth < MAX_UP) { // the sponsor is new here too: their line first
const up = await resolveId(ps.id);
if (up && up.email) { await place(up, depth + 1, seen); sp = await R.accounts.byEmail(up.email); }
}
R.carry.hold([e]);
try {
if (!(await R.registry.get(e))) { // a new row only: the registry is what InstantAdPay told us, iapsync's loop guard reads it
try { await R.registry.upsert({ email: e, username: p.username || null, wallet: p.wallet || null, sponsorEmail: sp ? sp.email : null, joinedAt: p.firstDoor && p.firstDoor.at, firstProperty: (p.firstDoor && p.firstDoor.site) || 'network' }); } catch (err) {}
}
let a = await R.accounts.byEmail(e);
// joinedRef 'hub' (2026-11-14): a quiet waiting account the hub made; accounts.listAll leaves it out of every mailing until they sign in
if (!a) { const x = await R.accounts.ensure(e, '', 'carried', 'hub'); if (x.created) { const st = load(); st.stats.shells++; st.made[e] = (p.firstDoor && p.firstDoor.site) || 'network'; } a = await R.accounts.byEmail(e); }
if (!a) return null;
if (p.username && !a.username) { try { const r = await R.accounts.setUsername(e, p.username); if (r && !r.error) load().stats.filled++; } catch (err) {} }
if (sp && norm(sp.email) !== e) {
if (!a.sponsorRef) {
const pv = R.follow && R.follow.get(e); // emptied on purpose here (released / rescued): an ordinary fill does not refill it
const deliberate = pv && pv.by && ['adopt', 'rescue', 'release', 'expiry', 'admin'].includes(pv.by) && !pv.sponsorEmail;
if (!deliberate && (sp.username || sp.code)) { try { await R.accounts.setSponsorRef(e, sp.username || sp.code); load().stats.filled++; } catch (err) {} }
} else {
const here = await refEmail(a.sponsorRef);
if (here !== norm(sp.email)) noteDisagree(e, sp.email, here, 'inbound'); // LinkSpin's line stands; TODO(Marty): who settles these
}
}
if (p.wallet && !a.address) { quiet.add(e); try { const r = await R.accounts.linkWallet(e, p.wallet); if (r && !r.error) load().stats.filled++; } catch (err) {} finally { quiet.delete(e); } }
return a;
} finally { R.carry.unhold([e]); }
}
async function apply(ev) {
const type = String(ev.type || '');
if (type === 'member.joined') {
if (norm(ev.data && ev.data.site) === SITE()) return; // our own join coming back
const p = await resolveId(ev.personId);
if (p && p.email) await place(p, 0, new Set());
} else if (type === 'member.erased') { // the hub erased someone (2026-11-15): erase.js finds them by the SHA-256 of the email
if (!R.erase) return;
const r = await R.erase.byHash(ev.data && ev.data.emailHash, 'hub');
if (r.result === 'refused') console.error('hubsync member.erased refused here:', String(r.error || '').slice(0, 200));
} else if (type === 'member.blocked' || type === 'member.signedout') { // network sign-in (2026-11-15): blocked, or "Sign out everywhere" on any site
if (!R.endSessions) return;
const p = await resolveId(ev.personId); if (!p || !p.email) return;
await R.endSessions(p.email, p.wallet || null);
} else if (type === 'wallet.connected') { // fill an empty wallet only, same rule as the InstantAdPay registry sync
const p = await resolveId(ev.personId); if (!p || !p.email || !p.wallet || p.blocked) return;
const a = await R.accounts.byEmail(p.email);
if (a && !a.address) { const k = norm(a.email); R.carry.hold([k]); quiet.add(k); try { await R.accounts.linkWallet(a.email, p.wallet); } finally { quiet.delete(k); R.carry.unhold([k]); } }
}
// sponsor.changed is IGNORED on purpose (checked 2026-11-14 for the switch-on): it would need the sponsorfollow.js decision
// (chain binding, window, provenance), and a member locked on the LinkSpin contract must never move anyway (the contract pays
// whoever it holds). qa/hubsync.test.cjs proves a locked member stays put.
// TODO(hub): member.blocked / unblocked, entitlement.changed, wallet.changed and the wallet-change events: ignored for now.
}
function verify(headers, raw) {
const ts = String(headers['x-hub-ts'] || ''), sig = String(headers['x-hub-sig'] || '');
if (!/^\d{10,16}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > WINDOW_MS) return false;
const want = sign(ts, raw);
return want.length === sig.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig));
}
// -> {status, body}. One batch at a time, in seq order; a seq already applied is skipped. A hub that cannot be reached
// answers 503 so the hub sends the batch again; a bad event is counted and passed (it must not stop every later one).
function receive(headers, raw) {
const run = inbound.then(async () => {
if (!on()) return { status: 404, body: { error: 'not_found' } };
if (!verify(headers, raw)) return { status: 401, body: { error: 'unauthorized' } };
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return { status: 400, body: { error: 'bad_json' } }; }
const st = load(); const events = (Array.isArray(b.events) ? b.events : []).slice().sort((x, y) => Number(x.seq) - Number(y.seq));
let applied = 0, skipped = 0;
for (const ev of events) {
const seq = Number(ev && ev.seq) || 0;
if (!seq || seq <= st.lastSeq) { skipped++; continue; }
try { await apply(ev); applied++; st.stats.events++; }
catch (e) {
if (/^hub /.test(e.message)) { save(); return { status: 503, body: { error: 'retry', seq } }; }
st.stats.errors++; st.lastError = { at: Date.now(), seq, error: String(e.message).slice(0, 160) }; console.error('hubsync event', seq, e.message);
}
st.lastSeq = seq; save();
}
return { status: 200, body: { ok: true, applied, skipped, lastSeq: st.lastSeq } };
});
inbound = run.catch(() => {});
return run;
}
// ---- outbound ------------------------------------------------------------------------------------------------------------
function touch(email) {
if (!on() || !email) return;
const e = norm(email); const st = load();
if (!st.outbox[e]) { st.outbox[e] = { at: Date.now(), tries: 0, next: 0 }; save(); }
if (!timer) timer = setTimeout(() => { timer = null; flush().catch(err => console.error('hubsync flush', err.message)); }, 3000);
}
async function report(e) {
const a = await R.accounts.byEmail(e); if (!a) return;
const st = load(); const s = st.sent[e] || {};
if (a.joinedVia !== 'carried' || a.joinedRef === 'btc4hits') { // a waiting copy of someone from another door: that door reports them (BTC4Hits has no door of its own)
const sp = a.sponsorRef ? await R.accounts.sponsorOf(e) : null;
const ref = sp ? norm(sp.email) : (a.sponsorRef || null);
const key = (a.username || '') + '|' + (ref || '');
if (s.j !== key) {
const r = await call('/v1/join', { email: e, ref: ref || undefined, username: a.username || undefined });
if (r.status === 200) {
st.stats.joins++;
const hubSp = r.body.person && r.body.person.sponsor ? norm(r.body.person.sponsor.email) : null;
if (sp && hubSp && hubSp !== norm(sp.email)) noteDisagree(e, hubSp, sp.email, 'join'); // TODO(Marty): hub says earliest join elsewhere
} else { st.stats.dropped++; console.log('hubsync join refused', r.status, r.body.error || '', mask(e)); }
s.j = key;
}
}
const w = norm(a.address);
if (w && s.w !== w) {
const r = await call('/v1/wallet', { email: e, wallet: w });
if (r.status === 200) st.stats.wallets++;
else { // 404: a waiting copy the hub has not heard of (its own door reports it); 409: the hub holds another wallet
st.stats.dropped++; console.log('hubsync wallet refused', r.status, r.body.error || '', mask(e)); }
s.w = w;
}
const rec = R.follow && R.follow.get ? R.follow.get(e) : null;
const spNow = a.sponsorRef ? await R.accounts.sponsorOf(e) : null;
if (rec && DELIBERATE.has(rec.by) && Number(rec.at) > 0 && norm(rec.sponsorEmail) === (spNow ? norm(spNow.email) : '') && s.sc !== Number(rec.at)) {
const r = await call('/v1/sponsor-change', { email: e, sponsorEmail: spNow ? spNow.email : null, by: rec.by });
if (r.status === 200) st.stats.sponsorChanges = (st.stats.sponsorChanges || 0) + 1;
else { st.stats.dropped++; noteDisagree(e, '(hub refused: ' + (r.body.error || r.status) + ')', spNow ? spNow.email : '', 'sponsor-change'); console.log('hubsync sponsor-change refused', r.status, r.body.error || '', mask(e)); }
s.sc = Number(rec.at);
}
st.sent[e] = s;
}
const DELIBERATE = new Set(['adopt', 'rescue', 'release', 'expiry', 'admin']); // sponsorfollow.js kinds the hub accepts
// chain.onEvent: a payout switch-on on the LinkSpin contract -> /v1/contract-bind (queued, retried with backoff)
function onChain(ev) {
if (ev && ev.type === 'Purchase') return onPurchase(ev);
if (!R || !on() || !ev || ev.type !== 'MemberActivated' || !ev.account) return;
(async () => {
let spW = null; try { const m = ev.sponsorId ? await R.chain.member(ev.sponsorId) : null; spW = m && m.account ? norm(m.account) : null; } catch (e) {}
const st = load(); st.binds = st.binds || [];
if (st.binds.length < 20000 && !st.binds.some(b => b.wallet === norm(ev.account))) { st.binds.push({ wallet: norm(ev.account), sponsorWallet: spW, tries: 0, next: 0 }); save(); }
})().catch(err => console.error('hubsync onChain', err.message));
}
// chain.onEvent: money paid into the LinkSpin contract (a Purchase with POL in; activation alone is not a spend) -> the hub's
// /v1/contract-spend (Marty 2026-11-14, rule 2: when two contracts hold different sponsors, the one with money spent decides
// the network sponsor). Sent after the binds in each flush; the tx hash makes a resend count once; a 404 (bind not there yet)
// waits and retries.
function onPurchase(ev) {
if (!R || !on() || !ev.buyerId || !(Number(ev.priceCents) > 0)) return;
try { if (BigInt(ev.paidWei || '0') <= 0n) return; } catch (e) { return; }
(async () => {
const m = await R.chain.member(ev.buyerId); const w = m && m.account ? norm(m.account) : null; if (!w) return;
const st = load(); st.spends = st.spends || [];
if (st.spends.length < 20000 && !st.spends.some(x => x.tx && x.tx === ev.tx)) { st.spends.push({ wallet: w, cents: Number(ev.priceCents), tx: ev.tx || null, paidAt: Number(ev.ts) || Date.now(), tries: 0, next: 0 }); save(); }
})().catch(err => console.error('hubsync onPurchase', err.message));
}
async function flushSpends() {
const st = load(); st.spends = st.spends || []; const now = Date.now();
const waitingBind = new Set((st.binds || []).map(b => b.wallet));
for (const x of st.spends.slice()) {
if (x.next > now || waitingBind.has(x.wallet)) continue; // its bind goes first
let owner = null; try { owner = await R.accounts.byAddress(x.wallet); } catch (e) {}
let r; try { r = await call('/v1/contract-spend', { contract: 'linkspin', email: owner && owner.email ? owner.email : undefined, wallet: x.wallet, cents: x.cents, tx: x.tx || undefined, at: x.paidAt }); }
catch (e) { r = { status: 0, body: { error: e.message } }; }
if (r.status === 200) { st.spends.splice(st.spends.indexOf(x), 1); st.stats.spends = (st.stats.spends || 0) + 1; }
else if (r.status === 400 || r.status === 409) { st.spends.splice(st.spends.indexOf(x), 1); st.stats.dropped++; console.log('hubsync spend refused', r.status, r.body.error || '', x.wallet); }
else { x.tries++; if (x.tries >= 20) { st.spends.splice(st.spends.indexOf(x), 1); st.stats.dropped++; } else x.next = now + Math.min(3600000, 30000 * 2 ** Math.min(x.tries, 7)); }
save();
}
}
async function flushBinds() {
const st = load(); st.binds = st.binds || []; const now = Date.now();
for (const b of st.binds.slice()) {
if (b.next > now) continue;
let owner = null; try { owner = await R.accounts.byAddress(b.wallet); } catch (e) {}
let r; try { r = await call('/v1/contract-bind', { contract: 'linkspin', email: owner && owner.email ? owner.email : undefined, wallet: b.wallet, sponsorRef: b.sponsorWallet || '' }); }
catch (e) { r = { status: 0, body: { error: e.message } }; }
if (r.status === 200) { st.binds.splice(st.binds.indexOf(b), 1); st.stats.binds = (st.stats.binds || 0) + 1; }
else if (r.status === 400 || r.status === 409) { st.binds.splice(st.binds.indexOf(b), 1); st.stats.dropped++; console.log('hubsync bind refused', r.status, r.body.error || '', b.wallet); }
else { b.tries++; if (b.tries >= 20) { st.binds.splice(st.binds.indexOf(b), 1); st.stats.dropped++; } else b.next = now + Math.min(3600000, 30000 * 2 ** Math.min(b.tries, 7)); }
save();
}
}
async function flush() {
if (!on() || flushing) return { skipped: true };
flushing = true; let done = 0, failed = 0;
try {
const st = load(); const now = Date.now();
await flushBinds(); await flushSpends();
for (const [e, o] of Object.entries(st.outbox)) {
if (o.next > now) continue;
try { await report(e); delete st.outbox[e]; done++; }
catch (err) { o.tries++; o.next = Date.now() + Math.min(3600000, 30000 * 2 ** Math.min(o.tries, 7)); o.error = String(err.message).slice(0, 120); failed++; st.stats.errors++; }
save();
}
} finally { flushing = false; }
return { done, failed };
}
const tick = () => flush();
// ---- rule 3: the holding tank asks the hub (Marty 2026-11-14) -------------------------------------------------------------
// The tank never offers anyone locked on ANY network contract, or anyone the hub already knows a sponsor for, nor a waiting
// copy made here from a hub event for someone who never signed in here (their own door's tank has them; announcing them in
// the shared topic or adopting them here would not be quiet). tank.js asks through its hooks (networkHeld, networkLocked,
// network); server.js wires them only with HUB_ENABLED, so with the flag off the tank works exactly as before. One
// /v1/locked {emails, detail} call per 2,000 emails, cached per email: fresh for 10 minutes. CONSERVATIVE when the hub cannot
// be reached: the last answer stands for up to 1 hour, after that the person is held ('unknown': not offered, not moved to
// the tank, not auto-assigned) until the hub answers again. After a failed call the hub is left alone for 2 minutes.
const HELD_FRESH_MS = 10 * 60000, HELD_STALE_MS = 60 * 60000, HELD_DOWN_MS = 2 * 60000, HELD_CHUNK = 2000;
const held = new Map(); let heldDownUntil = 0, heldBusy = Promise.resolve();
async function refreshHeld(emails, timeout) {
const run = heldBusy.then(async () => {
const now = Date.now(); const miss = emails.filter(e => { const c = held.get(e); return !c || now - c.at > HELD_FRESH_MS; });
if (!miss.length || now < heldDownUntil) return;
try {
for (let i = 0; i < miss.length; i += HELD_CHUNK) {
const part = miss.slice(i, i + HELD_CHUNK);
const r = await call('/v1/locked', { emails: part, detail: true }, timeout || 5000);
if (r.status !== 200 || !r.body || !r.body.found || typeof r.body.found !== 'object') throw new Error('hub locked ' + r.status);
if (held.size > 60000) held.clear();
const at = Date.now(); for (const e of part) held.set(e, { at, row: r.body.found[e] || null });
}
} catch (e) { heldDownUntil = Date.now() + HELD_DOWN_MS; load().stats.heldErrors = (load().stats.heldErrors || 0) + 1; console.log('hubsync: hub /v1/locked unreachable:', e.message); }
});
heldBusy = run.catch(() => {}); return run;
}
const whyHeld = (c, now) => (!c || now - c.at > HELD_STALE_MS ? 'unknown' : c.row && c.row.locked ? 'locked' : c.row && c.row.sponsored ? 'sponsored' : null);
// accounts -> Map email -> 'locked' | 'sponsored' | 'unknown' | 'hub-shell' for the ones the tank must not offer
async function heldAmong(accts, opts) {
const out = new Map(); if (!R || !on()) return out;
const list = (accts || []).filter(a => a && a.email); const emails = [...new Set(list.map(a => norm(a.email)))]; if (!emails.length) return out;
await refreshHeld(emails, opts && opts.timeout);
const now = Date.now(); const made = load().made;
for (const e of emails) { const w = whyHeld(held.get(e), now); if (w) out.set(e, w); }
for (const a of list) { const e = norm(a.email); if (!out.has(e) && made[e] && !a.lastSeen && !(Number(a.memberId) > 0)) out.set(e, 'hub-shell'); }
return out;
}
// release, rescue and expiry moves: 'locked' (on any network contract) | 'unknown' (hub not answering) | null
async function lockedAnywhere(email) {
if (!R || !on()) return null; const e = norm(email); if (!e) return null;
await refreshHeld([e]); const w = whyHeld(held.get(e), Date.now());
return w === 'locked' || w === 'unknown' ? w : null;
}
// the sponsor the hub knows for a tank member, for tank.alignToNetwork: this contract's lock first, else the network sponsor
// OFF unless HUB_TANK_ALIGN=on: aligning moves sponsors (and on LinkSpin a linked wallet then has its payouts switched on, which
// locks that sponsor on the contract), so the first run over a full tank is Marty's deliberate step, not a side effect of the
// deploy. While it is off the people the hub knows a sponsor for are simply held out of the tank (rule 3).
const alignOn = () => /^(1|true|on|yes)$/i.test(String(process.env.HUB_TANK_ALIGN || '').trim());
async function hubSponsor(email) {
if (!R || !on() || !alignOn()) return null; const e = norm(email); if (!e) return null;
await refreshHeld([e]); const c = held.get(e); if (!c || !c.row || Date.now() - c.at > HELD_STALE_MS) return null;
const l = c.row.locks && Object.prototype.hasOwnProperty.call(c.row.locks, CONTRACT) ? c.row.locks[CONTRACT] : undefined;
const sp = norm(l !== undefined ? l : c.row.sponsorEmail);
return sp && sp !== e ? { sponsorEmail: sp, via: l !== undefined ? 'network hub, LinkSpin contract' : 'network hub' } : null;
}
function adminView() {
const st = load();
return { on: on(), url: URL_(), site: SITE(), lastSeq: st.lastSeq, outbox: Object.keys(st.outbox).length, stats: st.stats, lastError: st.lastError || null,
made: Object.keys(st.made || {}).length, tankCache: held.size, tankHubDownUntil: heldDownUntil || null,
disagree: Object.entries(st.disagree).slice(-50).map(([e, d]) => ({ member: mask(e), hub: mask(d.hub), here: mask(d.here), how: d.how, at: d.at })), disagreeTotal: Object.keys(st.disagree).length };
}
module.exports = { /* member erase (erase.js, 2026-11-15): the live copy */ _state: load, _save: save, _forgetHeld: e => held.delete(norm(e)), init, on, receive, touch, onChain, flush, tick, adminView, isQuiet, heldAmong, lockedAnywhere, hubSponsor, _heldReset: () => { held.clear(); heldDownUntil = 0; }, _heldAge: ms => { for (const c of held.values()) c.at -= ms; } };
+6 -3
View File
@@ -30,6 +30,7 @@
// Until InstantAdPay answers proto 2, the hash of a row carrying the new facts is not recorded (sent again later). // Until InstantAdPay answers proto 2, the hash of a row carrying the new facts is not recorded (sent again later).
'use strict'; 'use strict';
const SF = require('./sponsorfollow'); const SF = require('./sponsorfollow');
const prohibited = require('./prohibited'); // 2026-10-30: a profile that fails the policy never leaves this site
const crypto = require('crypto'); const crypto = require('crypto');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
@@ -52,10 +53,12 @@ function save() { try { fs.writeFileSync(FILE(), JSON.stringify(load())); } catc
function init(deps) { R = deps; load(); } // { dataDir, accounts, registry, host, follow (sponsorfollow store), tank: () => tank } function init(deps) { R = deps; load(); } // { dataDir, accounts, registry, host, follow (sponsorfollow store), tank: () => tank }
const PUBLIC = () => String(process.env.PUBLIC_URL || ('https://' + (R.host || 'linkspin.app'))).replace(/\/+$/, ''); const PUBLIC = () => String(process.env.PUBLIC_URL || ('https://' + (R.host || 'linkspin.app'))).replace(/\/+$/, '');
function profileOf(a) { function profileOf(a) {
let socials = null; try { socials = a.socials ? (typeof a.socials === 'string' ? JSON.parse(a.socials) : a.socials) : null; } catch (e) { socials = null; } if (a.profileQuarantined) return null; // quarantined (link planted on a brand-new free account): stays here, unseen, until Marty decides
const cp = prohibited.cleanProfile({ avatarUrl: a.avatarUrl, bio: a.bio, socials: a.socials }, 'LinkSpin'); // policy applied on the way out too
const socials = cp.socials;
const av = String(a.avatarUrl || '').trim(); const av = String(a.avatarUrl || '').trim();
const avatarUrl = !av ? null : /^https:\/\//i.test(av) ? av : av.startsWith('/') ? PUBLIC() + av : null; const avatarUrl = !av ? null : /^https:\/\//i.test(av) ? av : av.startsWith('/') ? PUBLIC() + av : null;
const bio = String(a.bio || '').trim().slice(0, 600) || null; const bio = cp.bio;
if (!avatarUrl && !bio && !(socials && Object.keys(socials).length)) return null; if (!avatarUrl && !bio && !(socials && Object.keys(socials).length)) return null;
return { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null }; return { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null };
} }
@@ -140,4 +143,4 @@ async function tick(force) {
finally { ticking = false; } finally { ticking = false; }
} }
function adminView() { const st = load(); return { on: on(), url: URL_(), tracked: Object.keys(st.hashes).length, pushed: st.pushed, knownSkipped: st.known, last: st.last, errors: st.errors, lastError: st.lastError || null, pendingTouches: pending.size }; } function adminView() { const st = load(); return { on: on(), url: URL_(), tracked: Object.keys(st.hashes).length, pushed: st.pushed, knownSkipped: st.known, last: st.last, errors: st.errors, lastError: st.lastError || null, pendingTouches: pending.size }; }
module.exports = { init, touch, tick, adminView, on }; module.exports = { init, touch, tick, adminView, on, /* member erase (erase.js, 2026-11-15): the live copy */ _state: load, _save: save, _forget: e => pending.delete(norm(e)) };
+14 -6
View File
@@ -13,6 +13,10 @@ const FAQ = [
questions: ['I am already on InstantAdPay, do I start over?', 'Will my InstantAdPay sponsor be my sponsor here?', 'Can I sign in with my InstantAdPay email?'], questions: ['I am already on InstantAdPay, do I start over?', 'Will my InstantAdPay sponsor be my sponsor here?', 'Can I sign in with my InstantAdPay email?'],
tags: ['instantadpay', 'sponsor', 'carry-over', 'team', 'network'], tags: ['instantadpay', 'sponsor', 'carry-over', 'team', 'network'],
answer: 'Sign in with the email you use on InstantAdPay and your sponsor is placed for you before you buy anything: the same people above you, the same people below you, the same wallet. LinkSpin is a second property to build on, with tools you will use every day.' }, answer: 'Sign in with the email you use on InstantAdPay and your sponsor is placed for you before you buy anything: the same people above you, the same people below you, the same wallet. LinkSpin is a second property to build on, with tools you will use every day.' },
{ id: 'f-conversion-pixel', title: 'How do I count sign-ups and sales from my ads?', source: 'faq',
questions: ['How do I count sign-ups from my ads?', 'How do I see cost per lead?', 'Where do I put the conversion pixel?', 'My autoresponder has its own thank-you page, can I still track?'],
tags: ['conversion pixel', 'goal', 'cost per goal', 'thank-you page', 'aweber', 'getresponse'],
answer: 'Open Conversions in your Control Room (' + SITE_URL + '/conversions) and add a goal, for example subscriber. Paste the landing tag once on your landing page and the goal pixel on your thank-you page, then press Send a test conversion. From then on each click on your ads and spin links that reaches the goal counts once, within 30 days of the click, with its cost per goal by campaign. If Aweber, GetResponse or another provider shows its own thank-you page, set its thank-you redirect to a page on your own site that carries the pixel. InstantAdPay members find the same goals under Campaigns > Conversion tracking.' },
{ id: 'f-new-here', title: 'New here: where to start', source: 'faq', { id: 'f-new-here', title: 'New here: where to start', source: 'faq',
questions: ['I am new, where do I start?', 'What should I do first?', 'How do I get started?'], questions: ['I am new, where do I start?', 'What should I do first?', 'How do I get started?'],
tags: ['getting started', 'new member', 'first steps'], tags: ['getting started', 'new member', 'first steps'],
@@ -21,14 +25,14 @@ const FAQ = [
questions: ['How much POL do I need?', 'How much POL for fees?', 'What does a package cost in POL?'], questions: ['How much POL do I need?', 'How much POL for fees?', 'What does a package cost in POL?'],
tags: ['pol', 'fees', 'gas', 'buy packages'], tags: ['pol', 'fees', 'gas', 'buy packages'],
answer: 'The Credits screen shows the live POL cost of each package. Have that plus 2 or 3 POL for network fees; there is no other cost. Trust Wallet users should keep about double, because Trust blocks a purchase that spends most of the wallet.' }, answer: 'The Credits screen shows the live POL cost of each package. Have that plus 2 or 3 POL for network fees; there is no other cost. Trust Wallet users should keep about double, because Trust blocks a purchase that spends most of the wallet.' },
{ id: 'f-moonpay-declined', title: 'MoonPay declined my card', source: 'faq', { id: 'f-card-declined', title: 'My card was declined buying POL', source: 'faq',
questions: ['Why did MoonPay decline my card?', 'My card was refused buying POL', 'MoonPay will not take my payment'], questions: ['Why was my card declined buying POL?', 'My card was refused buying POL', 'The on-ramp will not take my payment'],
tags: ['moonpay', 'card', 'declined', 'buy pol'], tags: ['card', 'declined', 'buy pol', 'on-ramp'],
answer: 'Some banks block crypto purchases. Try a different card, Apple Pay or Google Pay, or buy POL on an exchange and withdraw it to your own wallet on the Polygon network. MoonPay is an independent provider with its own fees, limits and a first-time ID check (minimum order usually around $30).' }, answer: 'Some banks block crypto purchases. Try a different card, Apple Pay or Google Pay, or another major exchange or on-ramp, then send the POL to your own wallet on the Polygon network. Whichever provider you use has its own ID checks, fees and limits; LinkSpin is never in the middle of that payment.' },
{ id: 'f-same-wallet-positions', title: 'One wallet, one position', source: 'faq', { id: 'f-same-wallet-positions', title: 'One wallet, one position', source: 'faq',
questions: ['Can I use the same wallet for more than one position?', 'How do I add positions for Qualified Start?'], questions: ['Can I use the same wallet for more than one position?', 'How do I add positions for Qualified Start?'],
tags: ['wallet', 'position', 'qualified start', 'metamask'], tags: ['wallet', 'position', 'qualified start', 'metamask'],
answer: 'One address is one position on the contract. For Qualified Start, add extra accounts inside MetaMask, each with its own address, and link them as positions under your main wallet. The Qualified Start videos in Training walk through it.' }, answer: 'One address is one position on the contract. For Qualified Start, add extra accounts inside your wallet app, each with its own address, and link them as positions under your main wallet. The Qualified Start videos in Training walk through it.' },
{ id: 'f-payouts-where', title: 'Where do my payouts go?', source: 'faq', { id: 'f-payouts-where', title: 'Where do my payouts go?', source: 'faq',
questions: ['Where do my payouts go?', 'Which wallet gets paid?', 'Does the site hold my earnings?'], questions: ['Where do my payouts go?', 'Which wallet gets paid?', 'Does the site hold my earnings?'],
tags: ['payout', 'wallet', 'custody'], tags: ['payout', 'wallet', 'custody'],
@@ -52,6 +56,10 @@ const FAQ = [
{ id: 'f-recovery-phrase', title: 'Recovery phrase and scam safety', source: 'faq', { id: 'f-recovery-phrase', title: 'Recovery phrase and scam safety', source: 'faq',
questions: ['Someone asked for my recovery phrase', 'Will support ever ask for my private key?', 'Someone messaged me asking for money'], questions: ['Someone asked for my recovery phrase', 'Will support ever ask for my private key?', 'Someone messaged me asking for money'],
tags: ['recovery phrase', 'private key', 'scam', 'security'], tags: ['recovery phrase', 'private key', 'scam', 'security'],
answer: 'Never share your recovery phrase (the 12 or 24 words) or private key with anyone: whoever has them has your money. Nobody from LinkSpin will ever ask for them, and the site never sees them. If someone does ask, do not reply, and tell support through Help at ' + SITE_URL + '/help.' } answer: 'Never share your recovery phrase (the 12 or 24 words) or private key with anyone: whoever has them has your money. Nobody from LinkSpin will ever ask for them, and the site never sees them. If someone does ask, do not reply, and tell support through Help at ' + SITE_URL + '/help.' },
{ id: 'f-prohibited-content', title: 'What content is not allowed?', source: 'faq',
questions: ['What content is not allowed?', 'Can I put a link in my bio?', 'Why was my bio refused?', 'Can I promote a casino or CBD offer?', 'What is link farming?'],
tags: ['prohibited content', 'rules', 'bio', 'links', 'gambling', 'adult', 'link farm', 'terms'],
answer: 'Not allowed anywhere on LinkSpin, in ads, campaigns, line banners, wall offers, bios and social links: gambling, casinos, betting, lotteries and sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing and counterfeit goods; misleading financial promises. The bio is text only, no links and no domain names; links go in the social fields of your profile. Your bio, avatar and social links show on your public wall once you have bought a package; a free account\'s wall shows the name, the line\'s ads and the join button. Accounts created to place links in profile fields (link farming) are removed without notice, with their profile text. Full list: ' + SITE_URL + '/terms#prohibited' },
]; ];
module.exports = { FAQ }; module.exports = { FAQ };
+52 -11
View File
@@ -9,6 +9,12 @@
// path serves the new text. // path serves the new text.
// source canned | faq | ticket | admin // source canned | faq | ticket | admin
// //
// NETWORK (2026-11-15, netkb.js): the other network sites' entries, read from the hub, sit in the same index. This site's own
// entries are boosted first (HOME_BOOST); a question that names another site boosts that site's entries (NAMED_BOOST) and
// skips this site's instant answers (namesOther, chatbot.js). Other sites' entries never take the fast path; they ride along as
// context labelled with the site and the link to send people to. This site's own entries are published to the hub. The same
// merge code is in InstantAdPay, LinkSpin and the rebuilt sites' kb.js.
//
// Retrieval: BM25 over title, question variants and tags, plus the answer text at a low weight, with // Retrieval: BM25 over title, question variants and tags, plus the answer text at a low weight, with
// word bigrams so phrase overlap counts more than scattered words. No embeddings, no external calls. // word bigrams so phrase overlap counts more than scattered words. No embeddings, no external calls.
// The top hits go into the AI system prompt as "Knowledge base" context (chatbot.js). // The top hits go into the AI system prompt as "Knowledge base" context (chatbot.js).
@@ -22,10 +28,11 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const crypto = require('crypto'); const crypto = require('crypto');
let netkb = null; try { netkb = require('./netkb'); } catch (e) {}
const { SITE_URL } = require('./host'); const { SITE_URL } = require('./host');
let DATA_DIR = null, SEEDS = [], ready = null; let DATA_DIR = null, SEEDS = [], ready = null;
let cache = null, cacheAt = 0, index = null; let cache = null, cacheAt = 0, index = null, netVer = '';
const TTL = 30000; // two app copies share the volume for about 30 s during a deploy: re-read now and then const TTL = 30000; // two app copies share the volume for about 30 s during a deploy: re-read now and then
// ---------------------------------------------------------------- text + scoring (pure, unit-tested) // ---------------------------------------------------------------- text + scoring (pure, unit-tested)
@@ -82,10 +89,38 @@ function buildIndex(entries) {
} }
return { docs, df, avg, n: docs.length }; return { docs, df, avg, n: docs.length };
} }
const HOME_BOOST = 2, NAMED_BOOST = 3;
// which network sites a question names, by the site name or a short alias ("dlb", "vbb", "iap", ...)
const ALIASES = { iap: ['iap', 'instant ad pay'], linkspin: ['link spin'], bannerline: ['dlb', 'downline banner', 'downline banners'], vbb: ['vbb', 'viral banner'],
viraladblitz: ['vab', 'viral ad blitz'], downlinehydra: ['hydra', 'dh'], fivex: ['5x', '5x your team', 'five x', 'the draft'], stackpol: ['stack pol', 'stackpol'] };
const norm = s => ' ' + String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim() + ' ';
function namedSites(query, idx) {
const q = norm(query); const out = new Set();
for (const s of (idx && idx.sites) || []) {
const names = [s.name, s.site].concat(ALIASES[s.site] || []).map(norm);
if (names.some(n => n.trim() && q.includes(n))) out.add(s.site);
}
return out;
}
// does the question name a network site other than this one (hub site id `self`)? Then the home fast path stands aside.
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz',
downlinehydra: 'DownlineHydra', fivex: '5xYourTeam', stackpol: 'Stack POL', earnerscorner: 'Earners Corner' };
function namesOther(query, self) {
const q = norm(query); const out = [];
const ids = new Set(Object.keys(NAMES).concat(((index && index.sites) || []).map(s => s.site)));
for (const id of ids) {
if (id === self) continue;
const s = ((index && index.sites) || []).find(x => x.site === id) || {};
const names = [s.name, NAMES[id], id.length > 3 ? id : ''].concat(ALIASES[id] || []).filter(Boolean).map(norm);
if (names.some(n => n.trim() && q.includes(n))) out.push(id);
}
return out;
}
function rank(idx, query, k) { function rank(idx, query, k) {
if (!idx || !idx.n) return []; if (!idx || !idx.n) return [];
const qt = [...new Set(terms(query))]; const qt = [...new Set(terms(query))];
if (!qt.length) return []; if (!qt.length) return [];
const named = namedSites(query, idx);
const out = []; const out = [];
for (const d of idx.docs) { for (const d of idx.docs) {
let s = 0; let s = 0;
@@ -97,6 +132,8 @@ function rank(idx, query, k) {
s += FIELDS[f] * idf * (tf * (K1 + 1)) / (tf + K1 * (1 - B + B * d.f[f].len / idx.avg[f])); s += FIELDS[f] * idf * (tf * (K1 + 1)) / (tf + K1 * (1 - B + B * d.f[f].len / idx.avg[f]));
} }
} }
if (s > 0 && d.e.site) s *= named.has(d.e.site) ? NAMED_BOOST : 1;
else if (s > 0) s *= named.size ? 1 : HOME_BOOST;
if (s > 0) out.push({ entry: d.e, score: Math.round(s * 100) / 100 }); if (s > 0) out.push({ entry: d.e, score: Math.round(s * 100) / 100 });
} }
out.sort((a, b) => b.score - a.score); out.sort((a, b) => b.score - a.score);
@@ -153,9 +190,10 @@ function init(opts) {
} }
async function load(force) { async function load(force) {
if (ready) await ready; if (ready) await ready;
if (!force && cache && Date.now() - cacheAt < TTL) return cache; if (!force && cache && Date.now() - cacheAt < TTL && (!netkb || netkb.version() === netVer)) return cache; // a new network set rebuilds at once
const all = await store().all(); const all = await store().all();
cache = all.filter(e => !e.deleted); cacheAt = Date.now(); index = buildIndex(cache); rx.clear(); cache = all.filter(e => !e.deleted); cacheAt = Date.now(); rx.clear(); netVer = netkb ? netkb.version() : '';
index = buildIndex(cache.concat(netkb ? netkb.remote() : [])); index.sites = netkb ? netkb.sites() : [];
return cache; return cache;
} }
const rx = new Map(); const rx = new Map();
@@ -173,13 +211,16 @@ async function fastPath(msg) {
} }
async function search(query, k) { await load(); return rank(index, query, k || 5); } async function search(query, k) { await load(); return rank(index, query, k || 5); }
async function context(query, k) { return relevant(await search(query, k || 5)); } async function context(query, k) { return relevant(await search(query, k || 5)); }
// this site's own entries, for netkb.publish
async function own() { await load(); return cache.slice(); }
const label = e => e.site ? ' (about ' + e.siteName + ', another network site; send people to ' + e.go + ')' : '';
const HELP = 'Help (' + SITE_URL + '/help, or ' + SITE_URL + '/support when signed out)'; const HELP = 'Help (' + SITE_URL + '/help, or ' + SITE_URL + '/support when signed out)';
function promptBlock(hits) { function promptBlock(hits) {
const unsure = 'say "I\'m not sure, ask support" and point to ' + HELP + '.'; const unsure = 'say "I\'m not sure, ask support" and point to ' + HELP + '.';
if (!hits.length) return 'KNOWLEDGE BASE: no entry matches this question. If the FACTS above do not answer it either, ' + unsure + ' Do not guess.'; if (!hits.length) return 'KNOWLEDGE BASE: no entry matches this question. If the FACTS above do not answer it either, ' + unsure + ' Do not guess.';
return 'KNOWLEDGE BASE (maintained answers, most relevant first). Answer from these when one fits: keep its facts, numbers and links exactly, in your own short words. ' return 'KNOWLEDGE BASE (maintained answers, most relevant first). Answer from these when one fits: keep its facts, numbers and links exactly, in your own short words. '
+ 'If none of them and none of the FACTS answer the question, ' + unsure + ' Never guess.\n' + 'If none of them and none of the FACTS answer the question, ' + unsure + ' Never guess.\n'
+ hits.map((h, i) => '[' + (i + 1) + '] ' + h.entry.title + '\nAsked as: ' + (h.entry.questions || []).slice(0, 4).join(' | ') + '\nAnswer: ' + h.entry.answer).join('\n\n'); + hits.map((h, i) => '[' + (i + 1) + '] ' + h.entry.title + label(h.entry) + '\nAsked as: ' + (h.entry.questions || []).slice(0, 4).join(' | ') + '\nAnswer: ' + h.entry.answer).join('\n\n');
} }
// ---------------------------------------------------------------- the admin side // ---------------------------------------------------------------- the admin side
@@ -200,7 +241,7 @@ function validate(o, cur) {
async function list(q) { async function list(q) {
const all = (await load(true)).slice(); const all = (await load(true)).slice();
if (!q) return all.sort((a, b) => b.updated - a.updated); if (!q) return all.sort((a, b) => b.updated - a.updated);
const ranked = rank(index, q, 50).map(h => Object.assign({ score: h.score }, h.entry)); const ranked = rank(index, q, 50).filter(h => !h.entry.site).map(h => Object.assign({ score: h.score }, h.entry));
const lc = String(q).toLowerCase(), seen = new Set(ranked.map(e => e.id)); const lc = String(q).toLowerCase(), seen = new Set(ranked.map(e => e.id));
const plain = all.filter(e => !seen.has(e.id) && (e.id.includes(lc) || (e.title + ' ' + e.answer + ' ' + (e.ticketRef || '')).toLowerCase().includes(lc))); const plain = all.filter(e => !seen.has(e.id) && (e.id.includes(lc) || (e.title + ' ' + e.answer + ' ' + (e.ticketRef || '')).toLowerCase().includes(lc)));
return ranked.concat(plain); return ranked.concat(plain);
@@ -211,19 +252,19 @@ async function create(o) {
const now = Date.now(), id = 'kb-' + now.toString(36) + crypto.randomBytes(2).toString('hex'); const now = Date.now(), id = 'kb-' + now.toString(36) + crypto.randomBytes(2).toString('hex');
const src = ['ticket', 'admin'].includes(o.source) ? o.source : 'admin'; const src = ['ticket', 'admin'].includes(o.source) ? o.source : 'admin';
const e = Object.assign(v, { id, source: src, ticketRef: String(o.ticketRef || '').slice(0, 20), seedHash: '', edited: true, deleted: false, created: now, updated: now }); const e = Object.assign(v, { id, source: src, ticketRef: String(o.ticketRef || '').slice(0, 20), seedHash: '', edited: true, deleted: false, created: now, updated: now });
await store().put(e); await load(true); await store().put(e); await load(true); if (netkb) netkb.publishSoon();
return { ok: true, entry: e }; return { ok: true, entry: e };
} }
async function update(id, o) { async function update(id, o) {
const cur = await get(id); if (!cur) return { error: 'Entry not found.' }; const cur = await get(id); if (!cur) return { error: 'Entry not found.' };
const v = validate(o, cur); if (v.error) return v; const v = validate(o, cur); if (v.error) return v;
const e = Object.assign({}, cur, v, { edited: true, updated: Date.now() }); const e = Object.assign({}, cur, v, { edited: true, updated: Date.now() });
await store().put(e); await load(true); await store().put(e); await load(true); if (netkb) netkb.publishSoon();
return { ok: true, entry: e }; return { ok: true, entry: e };
} }
async function remove(id) { async function remove(id) {
const cur = await get(id); if (!cur) return { error: 'Entry not found.' }; const cur = await get(id); if (!cur) return { error: 'Entry not found.' };
await store().put(Object.assign({}, cur, { deleted: true, updated: Date.now() })); await load(true); await store().put(Object.assign({}, cur, { deleted: true, updated: Date.now() })); await load(true); if (netkb) netkb.publishSoon();
return { ok: true }; return { ok: true };
} }
// newest change made by a person (admin pane or a saved ticket reply), as a Central-time day. The chatbot-sync // newest change made by a person (admin pane or a saved ticket reply), as a Central-time day. The chatbot-sync
@@ -238,8 +279,8 @@ async function stamp() {
async function test(question) { async function test(question) {
const fast = await fastPath(String(question || '')); const fast = await fastPath(String(question || ''));
const hits = await search(String(question || ''), 8), used = new Set(relevant(hits).map(h => h.entry.id)); const hits = await search(String(question || ''), 8), used = new Set(relevant(hits).map(h => h.entry.id));
return { fast: fast ? { id: fast.id, title: fast.title } : null, ranked: hits.map(h => ({ id: h.entry.id, title: h.entry.title, score: h.score, used: used.has(h.entry.id) })) }; return { fast: fast ? { id: fast.id, title: fast.title } : null, ranked: hits.map(h => ({ id: h.entry.id, site: h.entry.site || '', title: h.entry.title, score: h.score, used: used.has(h.entry.id) })) };
} }
module.exports = { init, load, fastPath, search, context, promptBlock, list, get, create, update, remove, stamp, test, module.exports = { init, load, own, namesOther, fastPath, search, context, promptBlock, list, get, create, update, remove, stamp, test,
_pure: { words, terms, buildIndex, rank, relevant, validate, seedHash, MIN_SCORE } }; _pure: { words, terms, buildIndex, rank, relevant, validate, seedHash, namedSites, MIN_SCORE, HOME_BOOST, NAMED_BOOST } };
+218
View File
@@ -0,0 +1,218 @@
// The Refuel Kit (Fuel Your Offers stage 3, Marty approved the build 2026-10-24). The SAME file ships in InstantAdPay and
// LinkSpin; each site keeps ITS OWN program's kits (InstantAdPay art promotes InstantAdPay, LinkSpin art promotes
// LinkSpin, never mixed).
//
// A kit is one month's members-only banner set: { month 'YYYY-MM', theme, released, sizes 728x90 300x250 468x60 160x600
// 1200x630 } with one base image per size, stored as data in DATA_DIR/kits/ (kits.json + <month>/<size>.<ext>).
// Admin uploads the base art and previews the personalization; nothing here generates art (real art is Marty's).
//
// Who gets which kit: a counted refuel (the streak in refuel.js, InstantAdPay is the source of truth) unlocks the kit
// of the Central-time month it landed in. The entitlement arrives as { months: { 'YYYY-MM': streakMonthAtUnlock } }
// from opts.entitled(email). Kits stay usable after their month; missing a refuel only stops NEW kits.
// streak month 3+ at unlock an animated GIF version of each banner size
// streak month 6+ at unlock a "custom banners" credit for BannerKitAI: the entitlement and a note only, no integration
//
// Personalized on the server per member: their @username and a QR code to their own link are drawn onto each banner
// with ffmpeg (the badge renderer's approach). Rendered files are cached in DATA_DIR/kits/out/<hash>.<ext> and served
// publicly at /kitimg/<hash>.<ext> (ad networks and IAP banner campaigns load them by URL); the hash is an HMAC of
// member + kit + size + variant + base-art version, so it cannot be guessed and changes when the art changes.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const { spawn } = require('child_process');
const SIZES = { '728x90': [728, 90], '300x250': [300, 250], '468x60': [468, 60], '160x600': [160, 600], '1200x630': [1200, 630] };
const ORDER = ['728x90', '300x250', '468x60', '160x600', '1200x630'];
// where the QR and the name go on each size: q = QR box (x, y, side), t = name (x expr, y expr, font px)
const LAYOUT = {
'728x90': { q: ['W-84', 6, 78], t: ['W-96-tw', 'H-30', 18] },
'468x60': { q: ['W-58', 4, 52], t: ['W-68-tw', 'H-24', 14] },
'300x250': { q: ['W-82', 'H-82', 76], t: ['8', 'H-30', 16] },
'160x600': { q: ['(W-120)/2', 'H-128', 120], t: ['(W-tw)/2', 'H-160', 16] },
'1200x630': { q: ['W-212', 'H-212', 182], t: ['32', 'H-66', 34] },
};
let X = {}, DIR = null, OUT = null, FILE = null, SALT = null;
const MONTH_RE = /^\d{4}-(0[1-9]|1[0-2])$/;
const norm = e => String(e || '').trim().toLowerCase();
function init(opts) {
X = opts || {}; DIR = path.join(X.dataDir, 'kits'); OUT = path.join(DIR, 'out'); FILE = path.join(DIR, 'kits.json');
try { fs.mkdirSync(OUT, { recursive: true }); } catch (e) {}
const sf = path.join(DIR, 'salt'); try { SALT = fs.readFileSync(sf, 'utf8').trim(); } catch (e) {}
if (!SALT) { SALT = crypto.randomBytes(16).toString('hex'); try { fs.writeFileSync(sf, SALT, { flag: 'wx' }); } catch (e) { try { SALT = fs.readFileSync(sf, 'utf8').trim(); } catch (er) {} } }
}
const program = () => X.program === 'linkspin' ? 'linkspin' : 'iap';
const brand = () => program() === 'linkspin' ? 'LinkSpin' : 'InstantAdPay';
function load() { try { const s = JSON.parse(fs.readFileSync(FILE, 'utf8')); s.kits = s.kits || {}; s.credits = s.credits || {}; return s; } catch (e) { return { kits: {}, credits: {} }; } }
function save(s) { const tmp = FILE + '.' + process.pid + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(s, null, 1)); fs.renameSync(tmp, FILE); }
const ctMonth = ts => new Date(ts || Date.now()).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }).slice(0, 7);
const monthLabel = m => new Date(Date.UTC(Number(m.slice(0, 4)), Number(m.slice(5, 7)) - 1, 15)).toLocaleDateString('en-US', { month: 'long', year: 'numeric', timeZone: 'UTC' });
// ---- admin: the kits ---------------------------------------------------------------------------------
function baseFile(month, size) {
const d = path.join(DIR, month);
for (const ext of ['png', 'jpg', 'gif']) { const f = path.join(d, size + '.' + ext); if (fs.existsSync(f)) return f; }
return null;
}
function kitView(k) {
const sizes = ORDER.map(s => { const f = baseFile(k.month, s); return { size: s, ready: !!f, v: f ? Math.round(fs.statSync(f).mtimeMs) : 0 }; });
return { month: k.month, label: monthLabel(k.month), theme: k.theme || '', released: !!k.released, program: program(), sizes, complete: sizes.every(x => x.ready), updated: k.updated || 0 };
}
function listKits() { const s = load(); return Object.values(s.kits).sort((a, b) => b.month.localeCompare(a.month)).map(kitView); }
function saveKit(b) {
const month = String(b.month || ''); if (!MONTH_RE.test(month)) return { error: 'Month as YYYY-MM.' };
const s = load(); const k = s.kits[month] || { month, theme: '', released: false, created: Date.now() };
if (b.theme != null) k.theme = String(b.theme).trim().slice(0, 80);
if (b.released != null) {
if (b.released && !kitView(k).complete) return { error: 'Upload all five sizes before releasing the kit.' };
k.released = !!b.released;
}
if (b.remove) { delete s.kits[month]; save(s); return { ok: true, removed: true }; }
k.updated = Date.now(); s.kits[month] = k; save(s);
return { ok: true, kit: kitView(k) };
}
const MAGIC = { png: b => b[0] === 0x89 && b[1] === 0x50, jpg: b => b[0] === 0xff && b[1] === 0xd8, gif: b => b.slice(0, 3).toString() === 'GIF' };
function uploadBase(month, size, buf, mime) {
if (!MONTH_RE.test(String(month))) return { error: 'Month as YYYY-MM.' };
if (!SIZES[size]) return { error: 'Size must be one of ' + ORDER.join(', ') + '.' };
const ext = { 'image/png': 'png', 'image/jpeg': 'jpg', 'image/gif': 'gif' }[String(mime || '').split(';')[0].trim()];
if (!ext || !buf || buf.length < 32 || !MAGIC[ext](buf)) return { error: 'Use a PNG, JPG or GIF file.' };
const d = path.join(DIR, month); fs.mkdirSync(d, { recursive: true });
for (const e of ['png', 'jpg', 'gif']) { try { fs.unlinkSync(path.join(d, size + '.' + e)); } catch (er) {} }
fs.writeFileSync(path.join(d, size + '.' + ext), buf);
const s = load(); if (!s.kits[month]) s.kits[month] = { month, theme: '', released: false, created: Date.now() }; s.kits[month].updated = Date.now(); save(s);
return { ok: true, kit: kitView(s.kits[month]) };
}
// placeholder art for tests and previews: the program's existing banners from public/banners (no paid image APIs)
function usePlaceholder(month) {
const pre = program() === 'linkspin' ? 'linkspin-' : 'iap-';
const pick = { '728x90': [pre + '728x90.png'], '300x250': [pre + '300x250.png'], '468x60': [pre + '468x60.png'], '160x600': [pre + '160x600.png'],
'1200x630': program() === 'linkspin' ? ['linkspin-og-1200x630.png'] : ['iap-hero-1200x630.png', 'iap-advertise-earn-1200x630.jpg'] };
const done = [];
for (const size of ORDER) {
const f = pick[size].map(n => path.join(X.publicDir, 'banners', n)).find(p => fs.existsSync(p)); if (!f) continue;
const buf = fs.readFileSync(f); const r = uploadBase(month, size, buf, /\.jpg$/.test(f) ? 'image/jpeg' : 'image/png'); if (r.ok) done.push(size);
}
return { ok: true, sizes: done, kit: kitView(load().kits[month] || { month }) };
}
// ---- the renderer ---------------------------------------------------------------------------------------
let FONT;
function font() {
if (FONT !== undefined) return FONT;
FONT = process.env.BADGE_FONT || null; if (FONT) return FONT;
const walk = d => { let ents = []; try { ents = fs.readdirSync(d, { withFileTypes: true }); } catch (e) { return null; } for (const e of ents) { const f = path.join(d, e.name); if (e.isDirectory()) { const r = walk(f); if (r) return r; } else if (/bold\.ttf$/i.test(e.name) || /DejaVuSans-Bold\.ttf$/.test(e.name)) return f; } return null; };
for (const d of ['/usr/share/fonts', '/usr/local/share/fonts']) { const r = walk(d); if (r) { FONT = r; break; } }
if (!FONT && process.platform === 'win32' && fs.existsSync('C:/Windows/Fonts/arialbd.ttf')) FONT = 'C:/Windows/Fonts/arialbd.ttf';
return FONT;
}
const ffText = t => String(t).replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/:/g, '\\:').replace(/%/g, '%%');
function run(args, cwd) {
return new Promise(resolve => {
const p = spawn(X.ffmpeg || 'ffmpeg', args, { stdio: ['ignore', 'pipe', 'pipe'], cwd });
const out = []; let err = '';
p.stdout.on('data', c => out.push(c)); p.stderr.on('data', c => { err += c; });
p.on('error', e => resolve({ code: -1, err: e.message })); p.on('close', code => resolve({ code, out: Buffer.concat(out), err }));
});
}
// one personalized banner: base scaled to the exact size, QR (white quiet zone) and @name on a dark box
async function renderStill(base, size, name, link, stage, outFile) {
const [W, H] = SIZES[size]; const L = LAYOUT[size]; const F = font();
if (!F) return { error: 'No font for the renderer.' };
const qr = X.qrcode || require('qrcode'); // opts.qrcode: a test copy without node_modules
const qrFile = outFile + '.qr.png';
await qr.toFile(qrFile, link, { margin: 1, width: L.q[2], errorCorrectionLevel: 'M', color: { dark: '#000000', light: '#ffffff' } });
const winPath = /:/.test(F); const fontFile = winPath ? path.basename(F) : F;
const ex = v => String(v).replace(/W/g, String(W)).replace(/H/g, String(H));
const tx = String(L.t[0]).replace(/W/g, String(W)).replace(/tw/g, 'text_w'); const ty = ex(L.t[1]);
const showName = stage !== 0, showQr = stage === undefined || stage === 2;
const chain = ['[0:v]scale=' + W + ':' + H + ':flags=lanczos,setsar=1[b]'];
let last = 'b';
if (showQr) { chain.push('[1:v]scale=' + L.q[2] + ':' + L.q[2] + '[q]'); chain.push('[' + last + '][q]overlay=x=' + ex(L.q[0]) + ':y=' + ex(L.q[1]) + '[o]'); last = 'o'; }
if (showName && name) { chain.push('[' + last + ']drawtext=fontfile=' + fontFile + ":text='" + ffText(name) + "':fontcolor=white:fontsize=" + L.t[2] + ':box=1:boxcolor=0x0b1418@0.72:boxborderw=6:x=' + tx + ':y=' + ty + '[n]'); last = 'n'; }
const args = ['-v', 'error', '-y', '-i', path.resolve(base), '-i', path.resolve(qrFile), '-filter_complex', chain.join(';'), '-map', '[' + last + ']', '-frames:v', '1'];
if (/\.jpg$/.test(outFile)) args.push('-q:v', '3');
args.push(path.resolve(outFile));
const r = await run(args, winPath ? path.dirname(F) : undefined);
try { fs.unlinkSync(qrFile); } catch (e) {}
if (r.code !== 0 || !fs.existsSync(outFile)) return { error: 'Render failed: ' + String(r.err || '').slice(0, 200) };
return { ok: true };
}
// the animated version (streak month 3+): the banner, then the name, then the name and the QR, looping
async function renderGif(base, size, name, link, outFile) {
const frames = [0, 1, 2].map(i => outFile + '.f' + i + '.png');
for (let i = 0; i < 3; i++) { const r = await renderStill(base, size, name, link, i, frames[i]); if (r.error) return r; }
const list = outFile + '.txt';
fs.writeFileSync(list, frames.map((f, i) => "file '" + path.resolve(f).replace(/\\/g, '/') + "'\nduration " + (i === 2 ? 3 : 1)).join('\n') + "\nfile '" + path.resolve(frames[2]).replace(/\\/g, '/') + "'\n");
const r = await run(['-v', 'error', '-y', '-f', 'concat', '-safe', '0', '-i', list, '-filter_complex', 'split[a][b];[a]palettegen=max_colors=96[p];[b][p]paletteuse=dither=bayer', '-loop', '0', path.resolve(outFile)]);
for (const f of frames.concat(list)) { try { fs.unlinkSync(f); } catch (e) {} }
if (r.code !== 0 || !fs.existsSync(outFile)) return { error: 'GIF render failed: ' + String(r.err || '').slice(0, 200) };
return { ok: true };
}
const hashOf = (email, month, size, variant, v) => crypto.createHmac('sha256', SALT).update([norm(email), program(), month, size, variant, v].join('|')).digest('hex').slice(0, 28);
function indexFile() { return path.join(OUT, 'index.json'); }
function noteIndex(h, meta) { let ix = {}; try { ix = JSON.parse(fs.readFileSync(indexFile(), 'utf8')); } catch (e) {} ix[h] = meta; const tmp = indexFile() + '.' + process.pid + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(ix)); fs.renameSync(tmp, indexFile()); }
// render (or reuse) one personalized file; returns { url, file, size, variant, w, h, bytes }
async function personal(who, month, size, variant) {
const base = baseFile(month, size); if (!base) return { error: 'That kit has no ' + size + ' art yet.' };
const v = Math.round(fs.statSync(base).mtimeMs);
const ext = variant === 'gif' ? 'gif' : size === '1200x630' ? 'jpg' : 'png';
const h = hashOf(who.email, month, size, variant, v + '|' + who.name + '|' + who.link);
const out = path.join(OUT, h + '.' + ext);
if (!fs.existsSync(out)) {
const tmp = path.join(OUT, h + '.' + process.pid + '.' + Date.now() + '.' + ext);
let r; try { r = variant === 'gif' ? await renderGif(base, size, who.name, who.link, tmp) : await renderStill(base, size, who.name, who.link, undefined, tmp); } catch (e) { r = { error: 'The banner renderer is not available: ' + e.message }; }
if (r.error) return r;
try { fs.renameSync(tmp, out); } catch (e) { try { fs.unlinkSync(tmp); } catch (er) {} }
noteIndex(h, { email: norm(who.email), month, size, variant, ts: Date.now() });
}
const [w, hh] = SIZES[size];
return { ok: true, url: '/kitimg/' + h + '.' + ext, abs: String(X.siteUrl || '').replace(/\/+$/, '') + '/kitimg/' + h + '.' + ext, file: out, size, variant, w, h: hh, bytes: fs.statSync(out).size, ext };
}
// public serving: only files already rendered for an entitled member
function servePath(name) { const m = /^([a-f0-9]{28})\.(png|jpg|gif)$/.exec(String(name || '')); if (!m) return null; const f = path.join(OUT, m[0]); return fs.existsSync(f) ? { file: f, mime: { png: 'image/png', jpg: 'image/jpeg', gif: 'image/gif' }[m[2]] } : null; }
// ---- the member ------------------------------------------------------------------------------------------
async function whoOf(email) {
const w = await X.linkFor(norm(email)); if (!w || !w.link) return null;
return { email: norm(email), name: w.username ? '@' + w.username : '', link: w.link };
}
async function myKits(email) {
const ent = (await X.entitled(norm(email)).catch(() => null)) || null;
if (!ent || !ent.on) return { on: false };
const s = load(); const months = ent.months || {};
const nowMonth = String(ent.today || '').slice(0, 7) || ctMonth(); // a kit released early still waits for its month
const kits = Object.values(s.kits).filter(k => k.released && k.month <= nowMonth).sort((a, b) => b.month.localeCompare(a.month)).slice(0, 12).map(k => {
const streakAt = months[k.month] || 0; const unlocked = streakAt > 0;
return Object.assign(kitView(k), { unlocked, streakAt, gif: unlocked && streakAt >= 3, custom: unlocked && streakAt >= 6 });
});
// the BannerKitAI "custom banners" credit: an entitlement on record, nothing more yet
const customMonths = Object.entries(months).filter(([, k]) => k >= 6).map(([m]) => m);
if (customMonths.length) {
const e = norm(email); const have = s.credits[e] || {}; let changed = false;
for (const m of customMonths) if (!have[m]) { have[m] = { ts: Date.now(), used: false }; changed = true; }
if (changed) { s.credits[e] = have; save(s); }
}
const credits = Object.entries((s.credits[norm(email)] || {})).map(([m, c]) => ({ month: m, used: !!c.used }));
const cur = nowMonth; const who = await whoOf(email).catch(() => null);
return { on: true, program: program(), brand: brand(), link: who ? who.link : null, name: who ? who.name : null, current: cur, currentLabel: monthLabel(cur), unlockedCurrent: !!months[cur],
kits, customCredits: credits, customNote: credits.length ? 'Custom banners made for your own offer with BannerKitAI are coming. Your credit is saved on your account and will be honored when it opens.' : null,
nextRefuel: ent.nextRefuel || null };
}
async function renderFor(email, month, size, variant) {
const mk = await myKits(email); if (!mk.on) return { error: 'The Refuel Kit is not switched on.' };
const k = mk.kits.find(x => x.month === month); if (!k) return { error: 'No such kit.' };
if (!k.unlocked) return { error: 'Your next counted refuel unlocks this kit.' };
if (!SIZES[size]) return { error: 'No such size.' };
if (variant === 'gif' && !k.gif) return { error: 'The animated version comes with a 3-month streak.' };
const who = await whoOf(email); if (!who) return { error: 'Set a username first, so your banners carry your own link.' };
return personal(who, month, size, variant === 'gif' ? 'gif' : 'still');
}
async function preview(month, size, username, variant) {
const link = String(X.siteUrl || '').replace(/\/+$/, '') + '/join/' + (username || 'yourname');
const who = { email: 'preview@' + program(), name: '@' + (username || 'yourname'), link };
return personal(who, month, size, variant === 'gif' ? 'gif' : 'still');
}
module.exports = { init, SIZES, ORDER, LAYOUT, listKits, saveKit, uploadBase, usePlaceholder, myKits, renderFor, preview, servePath, ctMonth, monthLabel, font };
+61
View File
@@ -0,0 +1,61 @@
// "Load into my Banner Spin" for the Refuel Kit (2026-10-24). Each Banner Spin size in an unlocked kit goes into one of the
// member's Banner Spins of that size that has room, or into a new Banner Spin when the member's tier allows one more.
// The banner is the member's own personalized file (copied into uploads like a normal Banner Spin upload, so health checks,
// moderation and Member content treat it the same), labelled "Refuel Kit <month>", the target their own link.
// Loading the same kit twice does not add it twice.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
async function load(d) { // { kit, bannerspin, content, uploadsDir, email, month, variant, sizes }
const { kit, bannerspin, email, month } = d;
const mk = await kit.myKits(email); const k = mk.on && mk.kits.find(x => x.month === month);
if (!k) return { error: 'No such kit.' };
if (!k.unlocked) return { error: 'Your next counted refuel unlocks this kit.' };
const t = await bannerspin.tierFor(email); if (!t.ok) return { error: t.reason, status: 403 };
const want = Array.isArray(d.sizes) && d.sizes.length ? d.sizes.map(String) : k.sizes.filter(x => x.ready).map(x => x.size);
const label = 'Refuel Kit ' + month; const results = [];
for (const size of want.filter(z => bannerspin.SIZES[z] && k.sizes.some(x => x.size === z && x.ready))) {
const mine = await bannerspin.list(email);
const has = mine.find(x => x.size === size && x.banners.some(b => b.label === label));
if (has) { results.push({ size, spinId: has.id, spin: has.name, already: true }); continue; }
const r = await kit.renderFor(email, month, size, d.variant === 'gif' && k.gif ? 'gif' : 'still');
if (r.error) { results.push({ size, error: r.error }); continue; }
if (r.bytes > bannerspin.MAX_BYTES) { results.push({ size, error: 'The ' + size + ' file is over 150 KB, so Banner Spin cannot take it. Use the still version.' }); continue; }
let spin = mine.find(x => x.size === size && x.banners.length < t.banners && !x.adminOff), created = false;
if (!spin) { const c = await bannerspin.create(email, { name: 'Refuel Kit ' + size, size, fallback: mk.link || '' }); if (c.error) { results.push(Object.assign({ size, error: c.error }, mine.length >= t.spins ? { full: true } : {})); continue; } spin = c.spin; created = true; }
const name = crypto.randomBytes(12).toString('hex') + '.' + r.ext;
fs.writeFileSync(path.join(d.uploadsDir, name), fs.readFileSync(r.file));
const mime = { png: 'image/png', jpg: 'image/jpeg', gif: 'image/gif' }[r.ext];
try { if (d.content) d.content.noteUpload(name, email, r.bytes, mime, ''); } catch (e) {}
bannerspin.noteImage(email, name, r.w, r.h, r.bytes, mime);
const add = await bannerspin.addBanner(email, spin.id, { image: '/uploads/' + name, target: mk.link, label });
results.push(add.error ? { size, error: add.error } : { size, spinId: spin.id, spin: spin.name, created });
}
return { ok: true, results, message: summary(results, t) };
}
// one plain sentence set for the member (2026-10-24): what loaded, what did not and why, and what to do about it. A Starter
// tier holds 2 Banner Spins, so a full kit loads two sizes; that is the rule, and the message has to say so up front.
const join = a => a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1];
function summary(results, t) {
const ok = results.filter(x => !x.error), full = results.filter(x => x.error && x.full), bad = results.filter(x => x.error && !x.full);
const out = [];
if (ok.length) out.push('Loaded: ' + join(ok.map(x => x.size + (x.already ? ' (already in "' + x.spin + '")' : x.created ? ' (new Banner Spin "' + x.spin + '")' : ' (added to "' + x.spin + '")'))) + '.');
if (full.length) out.push('Not loaded: ' + join(full.map(x => x.size)) + '. Your ' + t.label + ' tier holds ' + t.spins + ' Banner Spins, one size each, and they are all in use. Nothing is broken: pick the sizes you want most and load those, or delete a Banner Spin under Links to make room.'
+ (t.next ? ' ' + t.next.label + ' (' + t.next.need + ') holds ' + t.next.spins + '.' : ''));
for (const x of bad) out.push(x.size + ': ' + x.error);
if (!results.length) out.push('Pick at least one size to load.');
return out.join(' ');
}
// what the Refuel Kit panel needs to pre-pick sizes: the tier, Banner Spins in use, and the sizes that fit (sizes with a
// Banner Spin that has room first, then new ones in order of use: 728x90, 300x250, 468x60, 160x600)
const PREFER = ['728x90', '300x250', '468x60', '160x600'];
async function room(email, bannerspin) {
const t = await bannerspin.tierFor(email); if (!t.ok) return { ok: false, reason: t.reason };
const mine = await bannerspin.list(email); const sizes = PREFER.filter(z => bannerspin.SIZES[z]);
const fits = sizes.filter(z => mine.some(x => x.size === z && x.banners.length < t.banners && !x.adminOff));
let free = Math.max(0, t.spins - mine.length); const suggested = sizes.filter(z => fits.includes(z) || (free > 0 && free-- > 0));
return { ok: true, tier: t.label, spins: t.spins, used: mine.length, next: t.next, sizes, suggested, all: suggested.length >= sizes.length };
}
module.exports = { load, room, summary };
+264
View File
@@ -0,0 +1,264 @@
// Launch week (Marty approved 2026-11-05, campaign-2026-11/PLAN.md "Launch-week hook", options B and C).
//
// FOUNDER BADGE (cosmetic only: no credits, no POL, no perks)
// Criterion: the account signed in at least once before the launch moment (siteConfig().launchAt, default
// 2026-11-15T06:00:00-06:00, 6 AM Central). "Signed in" = the account's earliest known signed-in visit:
// accounts.firstSeen, or lastSeen when firstSeen is not set yet. Both are written only by accounts.touchSeen(),
// which runs on signed-in requests (/api/me dashboard load, the /api/my/ping heartbeat, sponsor chat). Since
// 2026-11-05 touchSeen keeps firstSeen = the previous lastSeen on the next visit, so a member who signed in before
// launch and again after it still reads as "before". Carried-over shell accounts that never signed in have neither
// field and never qualify. The flag is stored on the account (accounts.founder = the launch moment, ms).
// Grant: automatic from the launch moment (tick every 10 minutes, founderGrant '0' switches it off), idempotent (an
// account already flagged is skipped), one run per 10-minute slot across app copies (marks.claim). Admin preview + run
// at /api/admin/launch-week. No Telegram posts, no email.
//
// LAUNCH WEEK CONTEST (option B)
// Window [launchContestStart, launchContestEnd): default Sun 2026-11-15 06:00 CT to the end of Sat 2026-11-21 CT
// (end stored exclusive as 2026-11-22T00:00:00-06:00). Ranking reuses the weekly leaderboard's count: tier-1 TierPaid
// events (the direct sponsor of each package sold), read from the chain index. Never counted: the sponsor's own
// positions, any purchase made by a linked position (Qualified Start), the admin account and the company ids
// (overrideHouseIds) as contestants or as buyers, and any email or member id in launchContestExcludeEmails /
// launchContestExcludeIds (Marty's other accounts). A member must have launchContestMinSales (default 2) counted
// sales to place. Ties: more sales, then more dollars, then whoever reached their total first.
// Prizes: launchContestPrizesPol (default "10,6,4" = 1st, 2nd, 3rd). Paid ONLY by the admin button after the window
// closes (POST /api/admin/launch-week/pay with the exact list the admin saw), through the same payer wallet and the
// contract's award(memberId) that the Level 4 override uses. The ranking is frozen on the first pay call; each place
// is claimed once (marks.claim) and written to disk as "sending" BEFORE the send, so nothing is ever paid twice.
'use strict';
const fs = require('fs');
const path = require('path');
const TZ = 'America/Chicago';
const DEFAULT_LAUNCH = '2026-11-15T06:00:00-06:00';
const DEFAULT_END = '2026-11-22T00:00:00-06:00'; // exclusive: the window includes all of Saturday Nov 21, Central
const WEI = 10n ** 18n;
const GAS_LIMIT = 150000n; // same as the override's award() call
const toWei = pol => { const [a, b = ''] = String(pol).trim().split('.'); return BigInt(a || '0') * WEI + BigInt((b + '0'.repeat(18)).slice(0, 18) || '0'); };
const polStr = wei => { const w = BigInt(wei); const s = (w * 10000n / WEI).toString().padStart(5, '0'); return (s.slice(0, -4) + '.' + s.slice(-4)).replace(/\.?0+$/, ''); };
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const fmtCT = (ts, withTime) => new Date(ts).toLocaleString('en-US', Object.assign({ timeZone: TZ, weekday: 'long', month: 'short', day: 'numeric' }, withTime ? { hour: 'numeric', minute: '2-digit' } : {}));
function create() {
let R = null; // { accounts, chain, marks, leaderboard, payer: () => signer|null, txLink, siteConfig, dataDir, adminEmail, now }
const lastError = { at: 0, msg: '' };
const now = () => (R && R.now ? R.now() : Date.now());
function init(refs) { R = refs; }
// ---- settings (all date-driven: launch morning needs no deploy) ----
function cfg() {
const s = R.siteConfig() || {};
const t = (v, d) => { const x = Date.parse(String(v || '').trim() || d); return isFinite(x) ? x : Date.parse(d); };
const launchAt = t(s.launchAt, DEFAULT_LAUNCH);
const start = String(s.launchContestStart || '').trim() ? t(s.launchContestStart, DEFAULT_LAUNCH) : launchAt;
const end = t(s.launchContestEnd, DEFAULT_END);
const prizes = String(s.launchContestPrizesPol == null || s.launchContestPrizesPol === '' ? '10,6,4' : s.launchContestPrizesPol).split(',').map(x => x.trim()).filter(x => /^\d+(\.\d{1,6})?$/.test(x) && Number(x) > 0);
const minSales = Math.max(1, Math.floor(Number(s.launchContestMinSales == null || s.launchContestMinSales === '' ? 2 : s.launchContestMinSales) || 2));
const minCents = Math.max(0, Math.floor(Number(s.launchContestMinCents || 0) || 0));
const list = v => String(v || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
const exEmails = new Set(list(s.launchContestExcludeEmails)); if (R.adminEmail) exEmails.add(String(R.adminEmail).toLowerCase());
const exIds = new Set([...list(s.overrideHouseIds || '1'), ...list(s.launchContestExcludeIds)].map(Number).filter(Boolean));
return { launchAt, start, end, prizes, minSales, minCents, exEmails, exIds,
founderGrant: String(s.founderGrant == null ? '1' : s.founderGrant) !== '0',
contestOn: String(s.launchContest == null ? '1' : s.launchContest) !== '0' };
}
// ---- FOUNDER ----
const earliestSignIn = a => Number(a.firstSeen) || Number(a.lastSeen) || 0;
const qualifiesFounder = (a, launchAt) => { const t = earliestSignIn(a); return t > 0 && t < launchAt; };
async function founderPreview() {
const c = cfg(); const all = await R.accounts.listAll(1e6);
const q = all.filter(a => qualifiesFounder(a, c.launchAt));
const granted = all.filter(a => a.founder).length;
return { launchAt: c.launchAt, launchAtCT: fmtCT(c.launchAt, true), launched: now() >= c.launchAt, field: 'firstSeen (earliest signed-in visit), else lastSeen',
accounts: all.length, qualify: q.length, granted, missing: q.filter(a => !a.founder).length, autoGrant: c.founderGrant,
neverSignedIn: all.filter(a => !earliestSignIn(a)).length };
}
// grant the flag to every qualifying account that lacks it. Refuses before the launch moment.
async function grantFounders(opts) {
const o = opts || {}; const c = cfg();
if (now() < c.launchAt) return { error: 'The launch moment (' + fmtCT(c.launchAt, true) + ' Central) has not happened yet. Founder badges are granted from then on.' };
const slot = 'lw:founder:' + c.launchAt + ':' + Math.floor(now() / 600000) + (o.manual ? ':m' : '');
if (!await R.marks.claim(slot)) return { ok: true, skipped: 'another copy of the app is granting in this slot' };
const all = await R.accounts.listAll(1e6); let n = 0;
for (const a of all) {
if (a.founder || !qualifiesFounder(a, c.launchAt)) continue;
try { const r = await R.accounts.setFounder(a.email, c.launchAt); if (r && r.ok && !r.already) n++; } catch (e) { lastError.at = now(); lastError.msg = 'founder ' + a.email + ': ' + e.message; }
}
if (n) {
try { const f = path.join(R.dataDir, 'launchweek', 'founder-grants.json'); fs.mkdirSync(path.dirname(f), { recursive: true }); let log = []; try { log = JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) {} log.push({ at: now(), launchAt: c.launchAt, granted: n, manual: !!o.manual }); fs.writeFileSync(f, JSON.stringify(log.slice(-50))); } catch (e) {}
console.log('founder badge: granted to ' + n + ' accounts');
}
return { ok: true, granted: n };
}
async function tick() {
const c = cfg();
if (c.founderGrant && now() >= c.launchAt) {
const all = await R.accounts.listAll(1e6);
if (all.some(a => !a.founder && qualifiesFounder(a, c.launchAt))) await grantFounders();
}
}
// what the member's own badge strip shows: held, or (before launch) on the way
function founderState(acct) {
const c = cfg(); if (!acct) return { founder: false, pending: false };
if (acct.founder) return { founder: true, pending: false };
// the caller is the member's own signed-in dashboard request (touchSeen runs in it), so before launch they are on the way
return { founder: false, pending: now() < c.launchAt, launchAt: c.launchAt };
}
// ---- CONTEST: standings ----
async function standings(at) {
const c = cfg(); const t = at || now();
const { map, names, founders, positionIds, mainId } = await R.leaderboard.memberMap();
const price = {};
const evs = R.chain.recentEvents(1e9);
for (const e of evs) if (e.type === 'Purchase') price[e.tx + ':' + e.buyerId] = Number(e.priceCents || 0);
const rows = {}; const until = Math.min(c.end, t);
for (const e of evs) {
if (e.type !== 'TierPaid' || e.tier !== 1 || e.ts < c.start || e.ts >= until) continue;
const sponsor = map[e.recipientId], buyer = map[e.buyerId];
if (!sponsor) continue;
if (buyer && buyer === sponsor) continue; // own positions never count
if (positionIds.has(e.buyerId)) continue; // linked positions (Qualified Start) never count
if (c.exEmails.has(sponsor) || c.exIds.has(e.recipientId) || c.exIds.has(mainId[sponsor])) continue; // admin, company, Marty's accounts: not contestants
if ((buyer && c.exEmails.has(buyer)) || c.exIds.has(e.buyerId)) continue; // company placements / Marty's own buys
const cents = price[e.tx + ':' + e.buyerId] || 0;
if (cents < c.minCents) continue;
const r = rows[sponsor] = rows[sponsor] || { email: sponsor, name: names[sponsor] || 'member', founder: founders.has(sponsor), sales: 0, cents: 0, lastTs: 0, ids: {} };
r.sales++; r.cents += cents; r.lastTs = Math.max(r.lastTs, e.ts); r.ids[e.recipientId] = (r.ids[e.recipientId] || 0) + 1;
}
const list = Object.values(rows).sort((a, b) => b.sales - a.sales || b.cents - a.cents || a.lastTs - b.lastTs || (a.email < b.email ? -1 : 1));
list.forEach((r, i) => { r.rank = i + 1; r.usd = r.cents / 100; r.qualifies = r.sales >= c.minSales; r.payId = mainId[r.email] || Number(Object.entries(r.ids).sort((x, y) => y[1] - x[1])[0][0]); });
const winners = []; let place = 0;
for (const r of list) { if (!r.qualifies || place >= c.prizes.length) continue; winners.push({ place: place + 1, email: r.email, name: r.name, memberId: r.payId, sales: r.sales, usd: r.usd, pol: c.prizes[place] }); place++; }
return { start: c.start, end: c.end, open: t < c.end, started: t >= c.start, minSales: c.minSales, prizes: c.prizes, rows: list, winners };
}
// ---- CONTEST: payout store (one small file per place, single writer per claim) ----
const dir = (...p) => path.join(R.dataDir, 'launchweek', 'contest-' + cfg().start, ...p);
const readJ = f => { try { return JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) { return null; } };
const writeJ = (f, o) => { fs.mkdirSync(path.dirname(f), { recursive: true }); const tmp = f + '.' + process.pid + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(o)); fs.renameSync(tmp, f); };
const frozen = () => readJ(dir('frozen.json'));
const getPlace = n => readJ(dir('place-' + n + '.json'));
const putPlace = (n, patch) => { const o = Object.assign(getPlace(n) || { place: n }, patch, { updated: now() }); writeJ(dir('place-' + n + '.json'), o); return o; };
const places = () => { const f = frozen(); return f ? f.winners.map(w => Object.assign({}, w, getPlace(w.place) || { state: 'pending' })) : []; };
function txInfo(tx) { // an AwardPaid this contest made: for the email / feed label
const h = String(tx || '').toLowerCase(); if (!h || !R) return null;
try { for (const p of places()) if (p.txHash && String(p.txHash).toLowerCase() === h) return { place: p.place }; } catch (e) {}
return null;
}
async function freeze() {
const f = frozen(); if (f) return f;
const c = cfg(); if (now() < c.end) return null;
if (!await R.marks.claim('lw:freeze:' + c.start)) { for (let i = 0; i < 20 && !frozen(); i++) await new Promise(r => setTimeout(r, 250)); return frozen(); }
const s = await standings(c.end);
const o = { at: now(), start: c.start, end: c.end, minSales: c.minSales, prizes: c.prizes, winners: s.winners.map(w => Object.assign({}, w, { wei: toWei(w.pol).toString() })), top: s.rows.slice(0, 10).map(r => ({ rank: r.rank, name: r.name, founder: r.founder, sales: r.sales, usd: r.usd, qualifies: r.qualifies })) };
writeJ(dir('frozen.json'), o); return o;
}
// admin preview: live standings (or the frozen result), what would be paid, the payer and every payout record
async function adminView() {
const c = cfg(); const s = await standings();
const f = frozen(); const p = R.payer ? R.payer() : null;
const payer = { keyPresent: !!p };
if (p) { payer.address = p.address; try { payer.balancePol = polStr(await p.balance()); } catch (e) { payer.balanceError = e.message; } }
return { window: { start: c.start, end: c.end, startCT: fmtCT(c.start, true), endCT: fmtCT(c.end - 1, true), open: s.open, started: s.started },
minSales: c.minSales, minCents: c.minCents, prizes: c.prizes, excluded: { emails: [...c.exEmails], ids: [...c.exIds] },
standings: s.rows.slice(0, 25).map(r => ({ rank: r.rank, name: r.name, email: r.email, memberId: r.payId, sales: r.sales, usd: r.usd, qualifies: r.qualifies })),
wouldPay: (f ? f.winners : s.winners).map(w => ({ place: w.place, name: w.name, email: w.email, memberId: w.memberId, sales: w.sales, pol: w.pol })),
frozen: f ? { at: f.at } : null, payouts: places().map(x => ({ place: x.place, name: x.name, memberId: x.memberId, pol: x.pol, state: x.state, txHash: x.txHash || '', tx: x.txHash && R.txLink ? R.txLink(x.txHash) : '', note: x.note || '' })),
payer, canPay: !s.open && !!p, founder: await founderPreview(), lastError: lastError.msg ? lastError : null };
}
// the admin button. `expect` = [{ place, memberId, pol }] exactly as the admin saw it; any difference refuses.
async function pay(expect) {
const c = cfg();
if (now() < c.end) return { error: 'The contest window is still open until ' + fmtCT(c.end - 1, true) + ' Central.' };
const p = R.payer ? R.payer() : null; if (!p) return { error: 'No payer wallet: the Level 4 override payer key (OVERRIDE_PAYER_KEY) is not configured.' };
const f = await freeze(); if (!f) return { error: 'Could not freeze the results; try again.' };
const want = (Array.isArray(expect) ? expect : []).map(x => x.place + ':' + Number(x.memberId) + ':' + String(x.pol)).sort().join('|');
const have = f.winners.map(w => w.place + ':' + w.memberId + ':' + w.pol).sort().join('|');
if (want !== have) return { error: 'The confirmed list does not match the frozen result. Reload and confirm again.', frozen: f.winners };
const todo = f.winners.filter(w => { const s = (getPlace(w.place) || {}).state; return !s || s === 'pending'; });
if (!todo.length) return { ok: true, paidNow: 0, payouts: places() };
let fees, bal;
try { fees = await p.fees(); bal = BigInt(await p.balance()); } catch (e) { return { error: 'Payer read failed: ' + e.message }; }
const total = todo.reduce((n, w) => n + BigInt(w.wei), 0n), gas = BigInt(todo.length) * GAS_LIMIT * BigInt(fees.maxFeePerGas);
if (bal < total + gas) return { error: 'Payer wallet ' + p.address + ' holds ' + polStr(bal) + ' POL; the prizes need ' + polStr(total) + ' POL plus up to ' + polStr(gas) + ' POL gas. Nothing was sent.' };
let paidNow = 0;
for (const w of todo) {
const rec = getPlace(w.place) || {}; const attempt = rec.attempt || 0;
if (!await R.marks.claim('lw:pay:' + c.start + ':' + w.place + ':' + attempt)) continue; // another copy (or an earlier click) owns it
const cur = getPlace(w.place); if (cur && cur.state && cur.state !== 'pending') continue;
putPlace(w.place, Object.assign({}, w, { state: 'checking', attempt }));
try { await p.preflight(w.memberId, w.wei); }
catch (e) { putPlace(w.place, { state: 'blocked', note: 'award() would revert (' + String(e.reason || e.shortMessage || e.message).slice(0, 100) + '); nothing sent' }); continue; }
putPlace(w.place, { state: 'sending', sendingAt: now() }); // on disk BEFORE the send
let tx;
try { tx = await p.send(w.memberId, w.wei, fees); }
catch (e) { putPlace(w.place, { state: 'review', note: 'send error, may or may not have gone out: ' + String(e.shortMessage || e.message).slice(0, 140) }); continue; }
putPlace(w.place, { state: 'sent', txHash: tx.hash });
console.log('launch contest: place ' + w.place + ' #' + w.memberId + ' ' + w.pol + ' POL tx ' + tx.hash);
try { const rc = await tx.wait(); if (rc && Number(rc.status) === 1) { putPlace(w.place, { state: 'paid', paidAt: now() }); paidNow++; } else putPlace(w.place, { state: 'failed', note: 'reverted on chain; needs review' }); }
catch (e) { putPlace(w.place, { state: 'review', note: 'sent, receipt not confirmed: ' + String(e.message).slice(0, 120) }); }
}
return { ok: true, paidNow, payouts: places() };
}
// admin decision on a stuck place: 'paid' with a tx that is an AwardPaid from the payer to that member for that amount,
// or 'retry' after checking the payer wallet on the explorer shows nothing went out (blocked / failed / review only)
async function resolve(place, action, tx) {
const r = getPlace(Number(place)); if (!r) return { error: 'no such place' };
if (action === 'paid') {
const p = R.payer ? R.payer() : null;
const hit = p && R.chain.recentEvents(1e9).find(e => e.type === 'AwardPaid' && String(e.tx).toLowerCase() === String(tx || '').toLowerCase());
if (!hit || hit.toId !== r.memberId || String(hit.amountWei) !== String(r.wei) || String(hit.from).toLowerCase() !== String(p.address).toLowerCase()) return { error: 'that tx is not an AwardPaid from the payer wallet to #' + r.memberId + ' for ' + r.pol + ' POL in the chain index' };
putPlace(r.place, { state: 'paid', txHash: hit.tx, note: 'admin: confirmed tx' }); return { ok: true };
}
if (action === 'retry') {
const staleSend = r.state === 'sending' && now() - (r.sendingAt || 0) > 15 * 60000; // the app stopped mid-send: you checked the explorer
if (!['blocked', 'failed', 'review', 'checking'].includes(r.state) && !staleSend) return { error: 'place is ' + r.state + '; only blocked, failed, review, checking or a send stuck for 15 minutes can be retried' };
putPlace(r.place, { state: 'pending', attempt: (r.attempt || 0) + 1, note: 'admin: nothing went out, released for one more try (was ' + r.state + ')' }); return { ok: true };
}
return { error: 'action must be paid or retry' };
}
// ---- public: the /leaderboard panel (from the launch moment through the payout) ----
async function panelState() {
const c = cfg(); const t = now();
if (!c.contestOn || t < c.start) return null;
const f = frozen(); const ps = places();
const done = f && (f.winners.length === 0 || ps.every(x => x.state === 'paid'));
if (done || t > c.end + 21 * 86400000) return null; // after the payout (or three weeks after the close): gone
const s = f ? null : await standings();
return { c, s, f, ps };
}
async function panelHtml() {
const st = await panelState(); if (!st) return '';
const { c, s, f } = st;
const ord = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th'];
const prizeLine = c.prizes.map((pol, i) => ord[i] + ' place ' + pol + ' POL').join(' · ');
const rows = f ? f.top : s.rows.slice(0, 10).map(r => ({ rank: r.rank, name: r.name, founder: r.founder, sales: r.sales, usd: r.usd, qualifies: r.qualifies }));
const open = !f && s.open;
let h = '<section class="lwc" id="launch-contest"><p class="eyebrow" style="margin:0 0 4px">Launch week contest</p>'
+ '<h2>' + (open ? 'Who is bringing in the most buyers' : 'Final standings') + '</h2>'
+ '<p class="muted small" style="margin:0 0 10px">' + esc(fmtCT(c.start, true)) + ' to ' + esc(fmtCT(c.end - 1, true)) + ', Central time. Ranked by packages bought by the people you sponsor directly. '
+ 'You need at least ' + c.minSales + ' to place. Your own positions, linked positions and the company account do not count.</p>'
+ '<div class="prize"><b>Prizes:</b> ' + esc(prizeLine) + '. Prizes are paid in POL to the wallet on file after the week closes and the results are checked.</div>'
+ '<table class="lb"><tr><th>#</th><th>Member</th><th>Packages</th><th>Sales</th></tr>'
+ (rows.length ? rows.map(r => '<tr><td>' + r.rank + '</td><td><b>' + esc(r.name) + '</b>' + (r.founder ? ' <span class="fdr" title="Founder badge">Founder</span>' : '') + (r.qualifies ? '' : ' <span class="muted small">(needs ' + c.minSales + ' to place)</span>') + '</td><td>' + r.sales + '</td><td>$' + Number(r.usd).toLocaleString() + '</td></tr>').join('')
: '<tr><td colspan="4" class="muted">No packages sold yet in the contest window. The first sales take the top spots.</td></tr>') + '</table>'
+ '<p class="muted small" style="margin:0">' + (open ? 'Standings update live from the chain.' : 'The window is closed. Winners are paid after the results are checked.') + ' No income is guaranteed.</p></section>';
return h;
}
// public JSON for /launch and the dashboard
async function publicView() {
const c = cfg(); const st = await panelState();
return { launchAt: c.launchAt, launched: now() >= c.launchAt, contest: { start: c.start, end: c.end, minSales: c.minSales, live: !!st, places: c.prizes.length, prizes: now() >= c.start ? c.prizes : null } };
}
return { init, cfg, founderPreview, grantFounders, tick, founderState, qualifiesFounder, standings, freeze, adminView, pay, resolve, panelHtml, publicView, txInfo };
}
const main = create();
module.exports = Object.assign(main, { create, DEFAULT_LAUNCH, DEFAULT_END, toWei, polStr });
+21 -15
View File
@@ -4,6 +4,7 @@
// on Central time: week = Monday 00:00 to Sunday 23:59, month = calendar month. Winners are recorded at // on Central time: week = Monday 00:00 to Sunday 23:59, month = calendar month. Winners are recorded at
// rollover (checked hourly), announced to Telegram, and credit prizes are granted automatically. // rollover (checked hourly), announced to Telegram, and credit prizes are granted automatically.
const { SITE_HOST, SITE_URL } = require('./host'); const { SITE_HOST, SITE_URL } = require('./host');
const themehead = require('./themehead'); // light/dark theme head script (2026-11-01)
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
let R = null; // { chain, accounts, ads, dataDir, siteConfig, notify(text), pushFeed(ev) } let R = null; // { chain, accounts, ads, dataDir, siteConfig, notify(text), pushFeed(ev) }
@@ -37,14 +38,15 @@ function periodBounds(period, ts) {
let idMap = { at: 0, map: {}, names: {} }; let idMap = { at: 0, map: {}, names: {} };
async function memberMap() { async function memberMap() {
if (Date.now() - idMap.at < 60000) return idMap; if (Date.now() - idMap.at < 60000) return idMap;
const map = {}, names = {}; const map = {}, names = {}, founders = new Set(), positionIds = new Set(), mainId = {};
const list = await R.accounts.listAll(5000); const list = await R.accounts.listAll(50000);
for (const a of list) { for (const a of list) {
if (a.memberId) { map[a.memberId] = a.email; names[a.email] = a.username ? '@' + a.username : 'member #' + a.memberId; } if (a.memberId) { map[a.memberId] = a.email; mainId[a.email] = a.memberId; names[a.email] = a.username ? '@' + a.username : 'member #' + a.memberId; }
else names[a.email] = a.username ? '@' + a.username : a.email.replace(/@.*/, '') + '@'; else names[a.email] = a.username ? '@' + a.username : a.email.replace(/@.*/, '') + '@';
try { for (const p of await R.accounts.positions(a.email)) if (p.memberId) map[p.memberId] = a.email; } catch (e) {} if (a.founder) founders.add(a.email); // Founder badge (2026-11-05): shown next to the name on the board
try { for (const p of await R.accounts.positions(a.email)) if (p.memberId) { map[p.memberId] = a.email; positionIds.add(p.memberId); } } catch (e) {} // linked positions (Qualified Start)
} }
idMap = { at: Date.now(), map, names }; return idMap; idMap = { at: Date.now(), map, names, founders, positionIds, mainId }; return idMap;
} }
const computeCache = {}; const computeCache = {};
@@ -54,7 +56,7 @@ async function compute(period) {
} }
async function computeRaw(period) { async function computeRaw(period) {
const { start, end, label } = periodBounds(period); const { start, end, label } = periodBounds(period);
const { map, names } = await memberMap(); const { map, names, founders } = await memberMap();
const price = {}; // tx -> cents const price = {}; // tx -> cents
for (const e of R.chain.recentEvents(1e9)) if (e.type === 'Purchase') price[e.tx + ':' + e.buyerId] = Number(e.priceCents || 0); for (const e of R.chain.recentEvents(1e9)) if (e.type === 'Purchase') price[e.tx + ':' + e.buyerId] = Number(e.priceCents || 0);
const rows = {}; const rows = {};
@@ -76,7 +78,7 @@ async function computeRaw(period) {
for (const [em, n] of Object.entries(joins)) { const r = rows[em] = rows[em] || { email: em, name: names[em] || em, sales: 0, cents: 0, pol: 0n, buyers: new Set() }; r.joins = n; } for (const [em, n] of Object.entries(joins)) { const r = rows[em] = rows[em] || { email: em, name: names[em] || em, sales: 0, cents: 0, pol: 0n, buyers: new Set() }; r.joins = n; }
// the admin's own account (company placements, tank arrivals) is not a contestant // the admin's own account (company placements, tank arrivals) is not a contestant
if (R.adminEmail && rows[R.adminEmail]) delete rows[R.adminEmail]; if (R.adminEmail && rows[R.adminEmail]) delete rows[R.adminEmail];
const out = Object.values(rows).map(r => ({ email: r.email, name: r.name, sales: r.sales, usd: r.cents / 100, pol: Number(r.pol / 10n ** 14n) / 10000, buyers: r.buyers.size, joins: r.joins || 0 })) const out = Object.values(rows).map(r => ({ email: r.email, name: r.name, founder: founders.has(r.email), sales: r.sales, usd: r.cents / 100, pol: Number(r.pol / 10n ** 14n) / 10000, buyers: r.buyers.size, joins: r.joins || 0 }))
.sort((a, b) => b.usd - a.usd || b.sales - a.sales || b.joins - a.joins); .sort((a, b) => b.usd - a.usd || b.sales - a.sales || b.joins - a.joins);
out.forEach((r, i) => { r.rank = i + 1; }); out.forEach((r, i) => { r.rank = i + 1; });
return { period, label, start, end, rows: out }; return { period, label, start, end, rows: out };
@@ -90,7 +92,7 @@ async function view(period, meEmail) {
return { period: r.period, label: r.label, start: r.start, end: r.end, prize: prize || '', top: r.rows.slice(0, 10).map(pub), me: me ? pub(me) : null, count: r.rows.length, return { period: r.period, label: r.label, start: r.start, end: r.end, prize: prize || '', top: r.rows.slice(0, 10).map(pub), me: me ? pub(me) : null, count: r.rows.length,
winners: winners().slice(0, 6) }; winners: winners().slice(0, 6) };
} }
const pub = r => ({ rank: r.rank, name: r.name, sales: r.sales, usd: r.usd, buyers: r.buyers, joins: r.joins }); const pub = r => ({ rank: r.rank, name: r.name, founder: !!r.founder, sales: r.sales, usd: r.usd, buyers: r.buyers, joins: r.joins });
// "1000,500,250" -> [1000, 500, 250]: credits for 1st, 2nd, 3rd... (Marty: award the top X positions, 2026-09-14) // "1000,500,250" -> [1000, 500, 250]: credits for 1st, 2nd, 3rd... (Marty: award the top X positions, 2026-09-14)
const ladder = v => String(v || '').split(',').map(x => Math.round(Number(x)) || 0).filter(n => n > 0); const ladder = v => String(v || '').split(',').map(x => Math.round(Number(x)) || 0).filter(n => n > 0);
const ORD = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th']; const ORD = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th'];
@@ -124,24 +126,28 @@ async function rolloverTick() {
} }
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c])); const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
// the Founder badge next to a name (cosmetic, 2026-11-05)
const fdr = r => r && r.founder ? ' <span class="fdr" title="Founder badge: signed in before LinkSpin launched">Founder</span>' : '';
async function renderPage() { async function renderPage() {
const week = await view('week'), month = await view('month'), all = await view('all'); const week = await view('week'), month = await view('month'), all = await view('all');
const sc = R.siteConfig(); const sc = R.siteConfig();
const table = v => '<table class="lb"><tr><th>#</th><th>Member</th><th>Packages</th><th>Sales</th><th>Buyers</th><th>New members</th></tr>' const table = v => '<table class="lb"><tr><th>#</th><th>Member</th><th>Packages</th><th>Sales</th><th>Buyers</th><th>New members</th></tr>'
+ (v.top.length ? v.top.map(r => '<tr><td>' + r.rank + '</td><td><b>' + esc(r.name) + '</b></td><td>' + r.sales + '</td><td>$' + r.usd.toLocaleString() + '</td><td>' + r.buyers + '</td><td>' + r.joins + '</td></tr>').join('') : '<tr><td colspan="6" class="muted">No sales yet in this period.</td></tr>') + '</table>'; + (v.top.length ? v.top.map(r => '<tr><td>' + r.rank + '</td><td><b>' + esc(r.name) + '</b>' + fdr(r) + '</td><td>' + r.sales + '</td><td>$' + r.usd.toLocaleString() + '</td><td>' + r.buyers + '</td><td>' + r.joins + '</td></tr>').join('') : '<tr><td colspan="6" class="muted">No sales yet in this period.</td></tr>') + '</table>';
const fmtD = ts => new Date(ts).toLocaleDateString('en-US', { timeZone: TZ, month: 'short', day: 'numeric' }); const fmtD = ts => new Date(ts).toLocaleDateString('en-US', { timeZone: TZ, month: 'short', day: 'numeric' });
const desc = 'Who is selling the most ad packages on LinkSpin this week and this month. Weekly and monthly referral contest standings, read from the chain.'; const desc = 'Who is selling the most ad packages on LinkSpin this week and this month. Weekly and monthly referral contest standings, read from the chain.';
let h = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Leaderboard | LinkSpin</title><meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + SITE_URL + '/leaderboard"><meta property="og:title" content="LinkSpin leaderboard"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="' + SITE_URL + '/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">' let h = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Leaderboard | LinkSpin</title><meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + SITE_URL + '/leaderboard"><meta property="og:title" content="LinkSpin leaderboard"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="' + SITE_URL + '/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">'
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap"><link rel="stylesheet" href="/assets/site.css?v=20260913a">' + '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=ls20261101t">'
+ '<style>.lbw{max-width:860px}.lb{width:100%;border-collapse:collapse;margin:8px 0 26px;font-variant-numeric:tabular-nums}.lb th{text-align:left;color:var(--muted);font-size:11px;letter-spacing:.08em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line)}.lb td{padding:10px;border-bottom:1px solid var(--line)}.lb tr:first-child + tr td:first-child{color:#ffd15c;font-weight:800}.prize{border-left:4px solid var(--mint);background:rgba(67,232,195,.07);padding:12px 16px;border-radius:0 12px 12px 0;margin:0 0 18px}.win{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin:0 0 10px}</style></head><body><div class="wrap lbw">' + '<style>.lbw{max-width:860px}.lb{width:100%;border-collapse:collapse;margin:8px 0 26px;font-variant-numeric:tabular-nums}.lb th{text-align:left;color:var(--muted);font-size:11px;letter-spacing:.08em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line)}.lb td{padding:10px;border-bottom:1px solid var(--line)}.lb tr:first-child + tr td:first-child{color:#ffd15c;font-weight:800}.prize{border-left:4px solid var(--mint);background:rgba(67,232,195,.07);padding:12px 16px;border-radius:0 12px 12px 0;margin:0 0 18px}.win{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin:0 0 10px}.fdr{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:999px;font-size:11px;font-weight:700;letter-spacing:.04em;color:#7a5600;background:#ffc94d;vertical-align:1px}.lwc{border:1px solid #ffc94d;border-radius:14px;padding:16px 18px;margin:0 0 28px;background:rgba(255,201,77,.07)}.lwc h2{margin:0 0 4px;font-size:24px}.lwc .lb{margin-bottom:8px}</style></head><body><div class="wrap lbw">'
+ '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Referral contest</p><h1>Leaderboard: <em>who is selling</em>.</h1><p class="lead">Ranked by ad packages sold to other people (your own positions never count, and the company account is not a contestant). Read from the chain, updated live. Weeks run Monday to Sunday, Central time.</p></section>'; + '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Referral contest</p><h1>Leaderboard: <em>who is selling</em>.</h1><p class="lead">Ranked by ad packages sold to other people (your own positions never count, and the company account is not a contestant). Read from the chain, updated live. Weeks run Monday to Sunday, Central time.</p></section>';
if (R.launchPanel) { try { h += await R.launchPanel(); } catch (e) { console.error('launch panel', e.message); } } // launch week contest (launchweek.js), date-driven
h += '<h2 style="font-size:24px;margin:0 0 4px">' + week.label + ' <span class="muted small">' + fmtD(week.start) + ' to Sunday</span></h2>' + (week.prize ? '<div class="prize"><b>Weekly prizes:</b> ' + esc(week.prize) + '</div>' : '') + table(week); h += '<h2 style="font-size:24px;margin:0 0 4px">' + week.label + ' <span class="muted small">' + fmtD(week.start) + ' to Sunday</span></h2>' + (week.prize ? '<div class="prize"><b>Weekly prizes:</b> ' + esc(week.prize) + '</div>' : '') + table(week);
h += '<h2 style="font-size:24px;margin:0 0 4px">' + month.label + '</h2>' + (month.prize ? '<div class="prize"><b>Monthly prizes:</b> ' + esc(month.prize) + '</div>' : '') + table(month); h += '<h2 style="font-size:24px;margin:0 0 4px">' + month.label + '</h2>' + (month.prize ? '<div class="prize"><b>Monthly prizes:</b> ' + esc(month.prize) + '</div>' : '') + table(month);
h += '<h2 style="font-size:24px;margin:0 0 4px">All time</h2>' + table(all); h += '<h2 style="font-size:24px;margin:0 0 4px">All time</h2>' + table(all);
const w = winners(); const w = winners();
if (w.length) h += '<h2 style="font-size:24px;margin:0 0 10px">Past winners</h2>' + w.slice(0, 12).map(x => '<div class="win"><b>' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + '</b>: ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '</div>').join(''); if (w.length) h += '<h2 style="font-size:24px;margin:0 0 10px">Past winners</h2>' + w.slice(0, 12).map(x => '<div class="win"><b>' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + '</b>: ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '</div>').join('');
h += '<p class="muted small" style="margin-top:30px">Sales are $ of packages bought by members you directly sponsor. Prizes are advertising credits or packages, never cash. No income is guaranteed.</p>'; h += '<p class="muted small" style="margin-top:30px">Sales are $ of packages bought by members you directly sponsor. Weekly and monthly prizes are advertising credits or packages, never cash. No income is guaranteed.</p>';
h += '</div><script src="/assets/common.js?v=20260914a"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>'; h += '</div><script src="/assets/common.js?v=20261117nw"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
return h; return h;
} }
module.exports = { init, view, compute, renderPage, rolloverTick, winners, periodBounds }; function setLaunchPanel(fn) { if (R) R.launchPanel = fn; }
module.exports = { init, view, compute, renderPage, rolloverTick, winners, periodBounds, memberMap, setLaunchPanel, ctParts };
+76
View File
@@ -0,0 +1,76 @@
// Login-ad clock (Marty 2026-11-15): "I definitely don't want somebody to not look at a login ad for 7 days... if login ads are
// available on those sites, they need to be seen several times a day." The SAME file ships in InstantAdPay and LinkSpin.
//
// A member sees the login ad on their next member-area page load whenever their last finished login-ad view on THIS site is more
// than loginAdEveryHours old (site setting, default 3), whether or not they just signed in. One row per member in MySQL
// (table login_ad_views: k = lowercased email, or 'w:' + wallet for a wallet-only session; seen_at; served_at).
// due(k) true when the member should get the login ad now (no row, or seen_at older than the setting)
// served(k) the login ad was handed to this member (the countdown starts on their screen)
// seen(k, s) the countdown ended: counts only when a serve to this member happened at least s - 2 seconds ago and within the
// last 30 minutes, so reloading during the countdown never skips the ad
// forget(k) member erase
// No database (local QA): the same rules in memory. A failed database read answers "due": when in doubt the ad shows.
'use strict';
let pool = null, tableReady = null, hours = () => 3;
const mem = new Map(); // k -> { seen, served }
const SERVE_WINDOW = 30 * 60 * 1000;
const keyOf = s => {
if (!s) return '';
const e = String(s.email || '').trim().toLowerCase();
if (e) return e.slice(0, 190);
const a = String(s.address || '').trim().toLowerCase();
return /^0x[0-9a-f]{40}$/.test(a) ? 'w:' + a : '';
};
const everyMs = () => { const h = Number(hours()); return (Number.isFinite(h) && h > 0 ? Math.min(h, 24 * 30) : 3) * 3600 * 1000; };
function init(opts) {
const o = opts || {};
if (typeof o.hours === 'function') hours = o.hours;
const url = String(o.url || '').trim();
pool = null; tableReady = null; mem.clear();
if (url) { const mysql = require('mysql2/promise'); pool = mysql.createPool({ uri: url, connectionLimit: 3, charset: 'utf8mb4' }); }
}
async function table() {
if (!tableReady) tableReady = pool.query('CREATE TABLE IF NOT EXISTS login_ad_views (k VARCHAR(200) PRIMARY KEY, seen_at BIGINT NOT NULL DEFAULT 0, served_at BIGINT NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4').catch(e => { tableReady = null; throw e; });
return tableReady;
}
async function row(k) {
if (!pool) return mem.get(k) || null;
await table();
const [r] = await pool.query('SELECT seen_at, served_at FROM login_ad_views WHERE k = ?', [k]);
return r[0] ? { seen: Number(r[0].seen_at) || 0, served: Number(r[0].served_at) || 0 } : null;
}
async function due(k, now) {
if (!k) return false;
const t = now || Date.now();
try { const r = await row(k); return !r || !r.seen || t - r.seen >= everyMs(); } catch (e) { console.error('login-ad clock read', e.message); return true; }
}
async function served(k, now) {
if (!k) return;
const t = now || Date.now();
if (!pool) { const r = mem.get(k) || { seen: 0, served: 0 }; r.served = t; mem.set(k, r); return; }
try { await table(); await pool.query('INSERT INTO login_ad_views (k, served_at) VALUES (?, ?) ON DUPLICATE KEY UPDATE served_at = VALUES(served_at)', [k, t]); }
catch (e) { console.error('login-ad clock serve', e.message); }
}
// -> { ok: true } or { ok: false, reason }
async function seen(k, dwellSec, now) {
if (!k) return { ok: false, reason: 'signed out' };
const t = now || Date.now();
const need = Math.max(0, (Number(dwellSec) || 10) - 2) * 1000;
let r = null; try { r = await row(k); } catch (e) { console.error('login-ad clock read', e.message); return { ok: false, reason: 'store' }; }
if (!r || !r.served || t - r.served > SERVE_WINDOW) return { ok: false, reason: 'not served' };
if (t - r.served < need) return { ok: false, reason: 'too soon' };
if (!pool) { r.seen = t; mem.set(k, r); return { ok: true }; }
try { await pool.query('UPDATE login_ad_views SET seen_at = ? WHERE k = ?', [t, k]); return { ok: true }; }
catch (e) { console.error('login-ad clock seen', e.message); return { ok: false, reason: 'store' }; }
}
async function forget(k) {
if (!k) return;
mem.delete(k);
if (pool) { try { await table(); await pool.query('DELETE FROM login_ad_views WHERE k = ?', [k]); } catch (e) { console.error('login-ad clock forget', e.message); } }
}
module.exports = { init, keyOf, due, served, seen, forget, everyMs };
+1 -1
View File
@@ -77,4 +77,4 @@ function sendCode(to, code) {
+ 'LinkSpin\nAdvertise and earn instantly. Locked in code, not promises.\n' + SITE_URL, { code: true }); + 'LinkSpin\nAdvertise and earn instantly. Locked in code, not promises.\n' + SITE_URL, { code: true });
} }
module.exports = { init, hasKey, send, sendCode }; module.exports = { init, hasKey, send, sendCode, /* member erase (erase.js, 2026-11-15): the live copy */ _intro: { state: () => introLoad(), save: () => { try { fs.writeFileSync(introFile() + '.tmp', JSON.stringify(introLoad())); fs.renameSync(introFile() + '.tmp', introFile()); } catch (e) {} } } };
+62
View File
@@ -0,0 +1,62 @@
// One-time claims shared by every running copy of the app (same idea as InstantAdPay's marks.js, 2026-10-24).
//
// Why: a Coolify deploy starts the new container and only stops the old one once the new one is healthy, so for
// about half a minute two copies of this app run side by side. Anything deduped in process memory or in a JSON
// file that each copy rewrites from its own memory can fire twice (InstantAdPay, 2026-09-25: two emails and a
// doubled Friday bonus). `claim(key)` is true for exactly one caller across all copies, false for everyone else.
//
// With a database: a row in event_marks that only one INSERT can win. Without one (LinkSpin production runs on
// the JSON store): an exclusive file create (open with 'wx') in DATA_DIR/marks/. Both copies mount the same
// volume, and O_EXCL creation is atomic on it, so exactly one copy gets the file. Marks older than 60 days are
// pruned: every event they guard has long since been handled.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
let db = null, DIR = null;
const local = new Set();
function init(deps) {
db = deps && deps.db;
DIR = deps && deps.dataDir ? path.join(deps.dataDir, 'marks') : null;
if (DIR) { try { fs.mkdirSync(DIR, { recursive: true }); } catch (e) {} }
}
const dbOn = () => !!(db && db.enabled && db.enabled());
async function ensureTable() {
if (!dbOn()) return;
await db.q('CREATE TABLE IF NOT EXISTS event_marks (k VARCHAR(160) PRIMARY KEY, ts BIGINT NOT NULL) ENGINE=InnoDB');
}
const fileOf = key => path.join(DIR, crypto.createHash('sha1').update(key).digest('hex') + '.m');
// true = this caller owns the key; false = someone (possibly another copy of the app) already does.
async function claim(key) {
key = String(key).slice(0, 160);
if (dbOn()) {
try {
const r = await db.q('INSERT IGNORE INTO event_marks (k, ts) VALUES (?, ?)', [key, Date.now()]);
return !!(r && r.affectedRows === 1);
} catch (e) { console.error('marks: claim fell back to the file for ' + key + ': ' + e.message); }
}
if (DIR) {
try { const fd = fs.openSync(fileOf(key), 'wx'); try { fs.writeSync(fd, key + '\n' + Date.now()); } finally { fs.closeSync(fd); } return true; }
catch (e) { if (e.code === 'EEXIST') return false; console.error('marks: file claim failed for ' + key + ': ' + e.message); }
}
if (local.has(key)) return false; local.add(key); return true;
}
// whether a key was already claimed (read only, never claims)
async function has(key) {
key = String(key).slice(0, 160);
if (dbOn()) { try { const r = await db.q('SELECT 1 FROM event_marks WHERE k=?', [key]); return r.length > 0; } catch (e) {} }
if (DIR) return fs.existsSync(fileOf(key));
return local.has(key);
}
async function prune() {
const cut = Date.now() - 60 * 86400000;
if (dbOn()) { try { await db.q('DELETE FROM event_marks WHERE ts < ?', [cut]); } catch (e) {} }
if (DIR) { try { for (const f of fs.readdirSync(DIR)) { const p = path.join(DIR, f); try { if (fs.statSync(p).mtimeMs < cut) fs.unlinkSync(p); } catch (e) {} } } catch (e) {} }
}
module.exports = { init, ensureTable, claim, has, prune };
+14 -1
View File
@@ -102,9 +102,22 @@ async function readServed(nasAdId) {
} }
// stop a syndicated ad (budget spent, paused, or expired) — remaining:0 halts serving. // stop a syndicated ad (budget spent, paused, or expired) — remaining:0 halts serving.
// THE TRAP (InstantAdPay, found 2026-09-17, ported here 2026-10-27): NAS has no stop flag, so a stop zeroes `remaining`, and
// served = assigned - remaining then reads the undelivered rest as DELIVERED. The true figure is captured BEFORE the stop
// and returned; callers persist it (ads.stopNas) and never reconcile a stopped ad again.
async function deactivate(nasAdId) { async function deactivate(nasAdId) {
if (!enabled()) return { skipped: 'flag-off' }; if (!enabled()) return { skipped: 'flag-off' };
let served = null;
try { const s = await readServed(nasAdId); if (s) served = s.served; } catch (e) {}
await q('UPDATE sponsorads SET remaining=0, EDate=NOW() WHERE ID=?', [Number(nasAdId)]); await q('UPDATE sponsorads SET remaining=0, EDate=NOW() WHERE ID=?', [Number(nasAdId)]);
return { ok: true, served };
}
// restart a STOPPED ad with `addImpressions` more, re-basing `assigned` on the TRUE served count recorded at the stop
// (a plain topUp would leave the zeroed remainder counted as served)
async function restart(nasAdId, trueServed, addImpressions, days) {
if (!enabled()) return { skipped: 'flag-off' };
const add = Math.max(0, Math.floor(Number(addImpressions) || 0)), base = Math.max(0, Math.floor(Number(trueServed) || 0));
await q('UPDATE sponsorads SET assigned=?, remaining=?, approved=1, EDate=DATE_ADD(NOW(), INTERVAL ? DAY) WHERE ID=?', [base + add, add, Number(days || 30), Number(nasAdId)]);
return { ok: true }; return { ok: true };
} }
@@ -131,4 +144,4 @@ async function topUp(nasAdId, addImpressions, days) {
return { ok: true }; return { ok: true };
} }
module.exports = { setClickUrl, updateCreative, enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind }; module.exports = { setClickUrl, updateCreative, enabled, pushCampaign, readServed, deactivate, restart, topUp, impressionsPerCredit, nasKind };
+136
View File
@@ -0,0 +1,136 @@
// Network conversions (Marty 2026-11-07, "Yes ship these"). REPORTING ONLY: nothing here touches sponsors, payouts, credits or
// the chain. InstantAdPay reports sign-ups, wallet links and package purchases by accounts that arrived on a LinkSpin click
// (op 'events' on /api/partner/conv, signed); LinkSpin counts them for the click's owner.
//
// - The ledger is DATA_DIR/netconv.jsonl: append-only, one write per event, so the two app copies of a deploy can both add
// to it without rewriting each other (unlike the JSON stores that rewrite the whole file). Each copy re-reads it when its
// size changes.
// - Once: marks.claim is true for exactly one copy; a key already in the ledger is a dup, so a repeat after marks are pruned
// is still refused. join and wallet count once per ROOT click (an ad click and the spin click it led to are one click), and
// each purchase counts by its own key (tx + log index). A click belongs to the first account seen on it.
// - Window: convtrack's rule, 30 days from the real click to the EVENT (not to delivery, so a retry queue never loses one).
// - The click owner's own account, and own clicks, are kept as tests: in the ledger with self:1, never counted, no postback.
// - Each row carries what the click was, so a later event still counts after the hit aged out of the rotator.
// - Spin-link events are mirrored into rotator.conv (per-link counts, sources, Reports) and Banner Spin events into its
// own conv; the mirror is replayed from the ledger on a timer, so a copy that lost a write during a deploy heals.
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const EVENTS = ['join', 'wallet', 'purchase'];
const SITE_NAMES = { vai: 'Video App Income' }; // events reported by another network site carry its id; none = InstantAdPay
let FILE = null, C = null, R = null, B = null, P = null, M = null;
let st = { size: -1, rows: [], keys: new Set(), byClick: new Map(), byRoot: new Map() };
const norm = e => String(e || '').trim().toLowerCase();
const DAY = 86400000;
const acctHash = email => crypto.createHash('sha256').update('netconv|' + norm(email)).digest('hex').slice(0, 16); // never the address itself
function init(o) {
FILE = path.join(o.dataDir, 'netconv.jsonl'); C = o.convtrack; R = o.rotator; B = o.bannerspin || null; P = o.postbacks || null; M = o.marks;
st = { size: -1, rows: [], keys: new Set(), byClick: new Map(), byRoot: new Map() }; refresh();
if (!o.noTimers) { setTimeout(() => syncMirror().catch(() => {}), 30000).unref(); setInterval(() => syncMirror().catch(() => {}), 300000).unref(); }
}
function refresh() {
let size = 0; try { size = fs.statSync(FILE).size; } catch (e) {}
if (size === st.size) return st;
const n = { size, rows: [], keys: new Set(), byClick: new Map(), byRoot: new Map() };
let raw = ''; try { raw = fs.readFileSync(FILE, 'utf8'); } catch (e) {}
for (const line of raw.split('\n')) {
if (!line) continue; let r; try { r = JSON.parse(line); } catch (e) { continue; }
n.rows.push(r); n.keys.add(String(r.k).split('|')[0]);
for (const [m, id] of [[n.byClick, r.click], [n.byRoot, r.root]]) { const a = m.get(id); if (a) a.push(r); else m.set(id, [r]); }
}
st = n; return st;
}
// the facts of a click, for one owner, as they stand now
function factsOf(L, o) {
const sp = L.spin, ad = L.ad, bs = L.bspin, mineSpin = !!(sp && sp.owner === o), mineAd = !!(ad && ad.owner === o);
return { kind: mineSpin ? 'spin' : (mineAd ? ad.k : (bs ? 'bspin' : (ad ? ad.k : 'spin'))),
camp: mineAd ? ad.camp : undefined, cname: mineAd ? ad.cname : undefined,
rot: mineSpin ? sp.rotation.id : undefined, rcode: mineSpin ? sp.rotation.code : undefined, rname: mineSpin ? sp.rotation.name : undefined, d: mineSpin ? sp.hit.d : undefined, sr: mineSpin ? (sp.hit.sr || undefined) : undefined,
bcode: bs ? bs.spin.code : undefined, src: (sp ? sp.hit.s : (bs ? (bs.click.h || 'direct') : (ad ? ad.pl : ''))) || '', c: (sp ? sp.hit.c : (bs ? bs.click.c : ad && ad.c)) || '', dv: (sp ? sp.hit.dv : (bs ? bs.click.dv : ad && ad.dv)) || '',
q: (sp ? sp.hit.q : (bs ? bs.click.q : undefined)) || undefined };
}
// e: { k, ev, click, email, value, ts, tx, sk }. Returns { result }: counted | self | dup | other | expired | nomatch | bad.
// Every one of those is final: the sender stops retrying on any answer.
async function record(e) {
const ev = String(e && e.ev || ''), k = String(e && e.k || '').slice(0, 120), click = String(e && e.click || ''); const email = norm(e && e.email);
if (!EVENTS.includes(ev) || !k || !C.isClickId(click) || !email || email.length > 190) return { result: 'bad' };
let S = refresh(); if (S.keys.has(k)) return { result: 'dup' };
const now = Date.now(); const at = Math.min(Number(e.ts) || now, now);
const L = C.lookup(click); const prior = S.byClick.get(click) || null;
if (!L && !prior) return { result: 'nomatch' };
const root = prior ? prior[0].root : L.root; const clickTs = prior ? prior[0].clickTs : L.ts;
if (at - clickTs > C.WINDOW_MS) return { result: 'expired' };
const acct = acctHash(email); const seen = S.byRoot.get(root) || [];
if (seen.length && seen[0].acct !== acct) return { result: 'other' }; // one click, one person: the first account on it
if (ev !== 'purchase' && seen.some(r => r.ev === ev)) return { result: 'dup' };
if (!(await M.claim('net:' + (ev === 'purchase' ? k : root + ':' + ev)))) return { result: 'dup' };
const owners = L ? [...new Set(L.owners)] : [...new Set((prior || []).map(r => r.owner))];
const value = ev === 'purchase' ? C.cleanValue(e.value) : 0;
const sk = /^s:[a-f0-9]{20}$/.test(String(e.sk || '')) ? String(e.sk) : '';
const tx = String(e.tx || '').slice(0, 80) || undefined;
const site = SITE_NAMES[String(e.site || '')] ? String(e.site) : undefined;
const rows = owners.map(o => {
const was = (prior || []).find(r => r.owner === o);
const f = L ? factsOf(L, o) : { kind: was.kind, camp: was.camp, cname: was.cname, rot: was.rot, rcode: was.rcode, rname: was.rname, d: was.d, sr: was.sr, bcode: was.bcode, src: was.src, c: was.c, dv: was.dv, q: was.q };
const self = email === o || !!(was && was.self) || seen.some(r => r.owner === o && r.self) || (L ? C.selfFor(L, o, sk) : false);
const row = Object.assign({ k: owners.length > 1 ? k + '|' + o : k, ev, ts: at, rec: now, value, acct, click, root, clickTs, owner: o, tx, site, self: self ? 1 : undefined }, f);
for (const x of Object.keys(row)) if (row[x] === undefined) delete row[x];
return row;
});
fs.appendFileSync(FILE, rows.map(r => JSON.stringify(r) + '\n').join('')); // one write: the whole event lands or none of it
refresh();
let counted = false;
for (const r of rows) {
if (r.self) continue;
counted = true;
await mirror(r).catch(err => console.error('netconv mirror', err.message));
if (P) P.fire(r.owner, ev, { q: r.q || {}, source: r.src, country: r.c, device: r.dv, lsid: click, code: r.rcode || r.bcode || '', sourceId: r.sr || '', payout: value, currency: 'USD', txid: tx || '', label: ev }).catch(err => console.error('netconv postback', err.message));
}
return { result: counted ? 'counted' : 'self' };
}
// LinkSpin's own sign-ups, wallets and purchases that arrived on an ad click (a / i ids): the rotator cannot see those clicks
async function fromLinkSpin(lsid, ev, facts) {
const f = facts || {}; if (!EVENTS.includes(ev) || f.key || !f.email) return null;
const k = 'ls:' + ev + ':' + (ev === 'purchase' ? (f.txid || crypto.randomBytes(6).toString('hex')) : acctHash(f.email));
await record({ k, ev, click: lsid, email: f.email, value: f.payout, ts: Date.now(), tx: f.txid });
return null;
}
async function mirror(r) {
const key = r.k.split('|')[0];
if (r.rot) return R.convert(r.click, r.ev, { payout: r.value, label: r.ev === 'purchase' ? (SITE_NAMES[r.site] || 'InstantAdPay') : undefined, key, ts: r.ts, bound: { r: r.rot, d: r.d, sr: r.sr } });
if (r.kind === 'bspin' && r.click[0] === 'k') return R.convert(r.click, r.ev, { payout: r.value, key, ts: r.ts });
return null;
}
async function syncMirror() { for (const r of refresh().rows) if (!r.self && r.rot) await mirror(r).catch(() => {}); }
const mineSince = (o, since) => refresh().rows.filter(r => r.owner === o && r.ts >= since);
const ORDER = ['join', 'lead', 'wallet', 'purchase', 'external'];
// Reports > Conversions: everything once. Rows mirrored into the rotator are read from the rotator (which also holds
// LinkSpin's own joins, wallets, purchases, leads and partner postbacks), the ledger adds only what the rotator cannot
// hold (ad clicks, Banner Spin clicks), Banner Spin's own rows add its site events, goals come from the pixel.
function unified(owner, days) {
const o = norm(owner); const since = Date.now() - Math.max(1, Number(days) || 30) * DAY;
const m = {}; const buyers = new Set();
const add = (k, v) => { const x = m[k] = m[k] || { k, n: 0, value: 0 }; x.n++; x.value += Number(v) || 0; };
for (const c of R.convRows(o, since)) { add(c.ev, c.value); if (c.ev === 'purchase') buyers.add(c.lsid); }
if (B && B.convRows) for (const c of B.convRows(o, since)) { if (c.key) continue; add(c.ev, c.value); if (c.ev === 'purchase') buyers.add(c.lsid); }
for (const r of mineSince(o, since)) { if (r.self || r.rot) continue; add(r.ev, r.value); if (r.ev === 'purchase') buyers.add(r.root); }
const goals = {}; for (const c of C.goalRowsOf(o, since)) { const g = goals[c.goal] = goals[c.goal] || { k: 'goal:' + c.goal, n: 0, value: 0 }; g.n++; g.value += c.value || 0; }
const rows = ORDER.filter(k => m[k]).map(k => m[k]).concat(Object.keys(m).filter(k => !ORDER.includes(k)).map(k => m[k]), Object.values(goals).sort((a, b) => b.n - a.n)).map(x => Object.assign(x, { value: Math.round(x.value * 100) / 100 }));
return { rows, joins: (m.join || {}).n || 0, wallets: (m.wallet || {}).n || 0, purchases: (m.purchase || {}).n || 0, buyers: buyers.size, goals: Object.values(goals).reduce((n, g) => n + g.n, 0) };
}
// InstantAdPay's Campaigns card: the same rows, and the events on each of the member's InstantAdPay ad campaigns
function partner(owner, days) {
const o = norm(owner); const d = Math.max(1, Math.min(90, Number(days) || 30)); const since = Date.now() - d * DAY;
const byCampaign = {};
for (const r of mineSince(o, since)) { if (r.self || r.kind !== 'iap' || !r.camp) continue; const b = byCampaign[r.camp] = byCampaign[r.camp] || { join: 0, wallet: 0, purchase: 0, value: 0 }; b[r.ev]++; b.value = Math.round((b.value + (r.value || 0)) * 100) / 100; }
const selfEvents = mineSince(o, since).filter(r => r.self).length;
return { rows: unified(o, d).rows, byCampaign, selfEvents, days: d };
}
function adminCounts() { const a = refresh().rows; return { rows: a.length, counted: a.filter(r => !r.self).length }; }
module.exports = { init, record, fromLinkSpin, unified, partner, syncMirror, adminCounts, EVENTS };
+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: [] } }; } };
+204
View File
@@ -0,0 +1,204 @@
// Shared network knowledge, site side (Marty 2026-11-15: every network site's chatbot answers about the whole network, with its
// own site first). This site publishes its own knowledge-base entries to the network hub and reads the merged set back:
// PUT HUB_URL/v1/kb {name, url, entries} replaces this site's set (the hub skips a set it already holds)
// GET HUB_URL/v1/kb signed over an empty body, If-None-Match: the last version -> 304 when nothing changed
// Signed as HUB_SITE with HUB_SECRET (X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + "\n" + raw body)), like hubreport.js.
// The merged set is kept in memory and in DATA_DIR/netkb-cache.json (a MySQL document through docstore where the site has
// DOCSTORE_URL; written only when the version changes), so a hub outage at boot still answers about the other sites.
// Off when HUB_URL or a 32+ character HUB_SECRET is missing, or NETKB=0: the chatbot then answers about this site only.
//
// SEMANTIC MATCHING (Marty 2026-11-16): the hub matches a question by meaning against the whole network KB with the free core2
// embeddings model (POST HUB_URL/v1/kb/match). match() asks it with a strict timeout (NETKB_MATCH_MS, default 1500) and fails
// soft: an error or a timeout answers null and the next MATCH_PAUSE_MS skip the hub, so the chat never waits on a slow model and
// the site's own BM25 retrieval (kb.js) answers as before. route() turns a match into the chatbot's decision:
// - this site's own entry, raw score >= SEM.answer with a clear lead (or the instant-answer pattern agrees): the answer itself
// - the instant-answer pattern hit kept when the match agrees (its entry within SEM.agree of the top), or when the match has
// no idea (top below SEM.unsure); this site's own entries rank first unless another site is named or clearly closer
// - otherwise no instant answer (the regex is overruled by meaning); the entries >= SEM.context feed the AI prompt
// suggest() gives the support desk's new-ticket form the closest help answers (KB entries only) the same way, BM25 as the fallback.
// Off with NETKB_MATCH=0. Thresholds measured on bge-large-en-v1.5 over the network KB (2026-11-16). Tests: qa/netkb-semantic.test.mjs
// The SAME file ships in every network site (InstantAdPay, LinkSpin, ViralAdBlitz, DownlineHydra, 5xYourTeam, VBB, Downline
// Banners, Stack POL). Keep them identical.
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const REFRESH_MS = 10 * 60 * 1000;
let O = null; // { dataDir, site, name, url, netId, entries: async () => [...], linkFor: (url) => link }
let merged = { version: '', sites: {}, entries: [] }, loadedAt = 0, publishedHash = '', pubTimer = null, timer = null;
const stats = { published: 0, publishErrors: 0, reads: 0, notModified: 0, readErrors: 0, lastError: null, lastPublishAt: 0, lastReadAt: 0 };
const hubUrl = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
const secret = () => String(process.env.HUB_SECRET || '').trim();
const siteName = () => String(process.env.HUB_SITE || (O && O.site) || '').trim();
const enabled = () => process.env.NETKB !== '0' && !!hubUrl() && secret().length >= 32 && !!siteName();
const cacheFile = () => (O && O.dataDir ? path.join(O.dataDir, 'netkb-cache.json') : null);
async function call(method, route, body, headers, timeoutMs) {
const raw = body === undefined ? '' : JSON.stringify(body); const ts = String(Date.now());
const sig = crypto.createHmac('sha256', secret()).update(ts + '\n' + raw).digest('hex');
const r = await fetch(hubUrl() + route, { method, body: method === 'GET' ? undefined : raw, signal: AbortSignal.timeout(timeoutMs || 15000),
headers: Object.assign({ 'Content-Type': 'application/json', 'X-Hub-Site': siteName(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig }, headers || {}) });
let j = null; if (r.status !== 304) { try { j = await r.json(); } catch (e) {} }
return { status: r.status, body: j };
}
// the entries this site shares: what the chatbot's knowledge base holds, minus the instant-answer patterns (those stay home)
const shape = e => ({ id: String(e.id), title: e.title, questions: (e.questions || []).slice(0, 15), answer: e.answer, tags: (e.tags || []).slice(0, 15), link: e.link || (O && O.url) || undefined });
async function publish() {
if (!enabled() || !O || typeof O.entries !== 'function') return { skipped: true };
const entries = (await O.entries()).filter(e => e && e.id && e.answer && !e.deleted).map(shape);
const body = { name: O.name, url: O.url, entries };
const h = crypto.createHash('sha1').update(JSON.stringify(body)).digest('hex');
if (h === publishedHash) return { same: true };
try {
const r = await call('PUT', '/v1/kb', body);
if (r.status !== 200) { stats.publishErrors++; stats.lastError = 'publish ' + r.status + ' ' + ((r.body && r.body.error) || ''); return { error: stats.lastError }; }
publishedHash = h; stats.published++; stats.lastPublishAt = Date.now();
return r.body;
} catch (e) { stats.publishErrors++; stats.lastError = 'publish ' + e.message; return { error: e.message }; }
}
// an admin edit: publish a few seconds later (several quick edits go as one)
function publishSoon() { if (pubTimer) return; pubTimer = setTimeout(() => { pubTimer = null; publish().catch(() => {}); }, 5000); if (pubTimer.unref) pubTimer.unref(); }
function readCache() {
const f = cacheFile(); if (!f) return;
try { const d = JSON.parse(fs.readFileSync(f, 'utf8')); if (d && Array.isArray(d.entries)) { merged = d; loadedAt = 0; } } catch (e) {}
}
function writeCache() {
const f = cacheFile(); if (!f) return;
try { fs.writeFileSync(f + '.tmp', JSON.stringify(merged)); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('netkb cache', e.message); }
}
async function refresh() {
if (!enabled()) return { skipped: true };
try {
const r = await call('GET', '/v1/kb', undefined, merged.version ? { 'If-None-Match': '"' + merged.version + '"' } : {});
stats.lastReadAt = Date.now();
if (r.status === 304) { stats.notModified++; loadedAt = Date.now(); return { same: true }; }
if (r.status !== 200 || !r.body || !Array.isArray(r.body.entries)) { stats.readErrors++; stats.lastError = 'read ' + r.status; return { error: stats.lastError }; }
merged = { version: String(r.body.version || ''), sites: r.body.sites || {}, entries: r.body.entries }; loadedAt = Date.now(); stats.reads++;
writeCache();
return { version: merged.version, count: merged.entries.length };
} catch (e) { stats.readErrors++; stats.lastError = 'read ' + e.message; return { error: e.message }; }
}
// other sites' entries, ready for the chatbot's index: id "<site>:<id>", plus where they come from and the link to send people to
function remote() {
const me = siteName(); const out = [];
for (const e of merged.entries || []) {
if (!e || e.site === me) continue;
const s = (merged.sites || {})[e.site] || {};
const url = s.url || e.link || '';
out.push({ id: e.site + ':' + e.id, title: e.title, questions: e.questions || [], answer: e.answer, tags: e.tags || [],
site: e.site, siteName: s.name || e.site, siteUrl: url, go: (O && typeof O.linkFor === 'function' && url ? O.linkFor(url) : '') || url });
}
return out;
}
// the network's sites as the hub knows them (name, link), this one left out
function sites() {
const me = siteName();
return Object.entries(merged.sites || {}).filter(([k]) => k !== me).map(([k, s]) => ({ site: k, name: s.name || k, url: s.url || '', go: (O && typeof O.linkFor === 'function' && s.url ? O.linkFor(s.url) : '') || s.url || '', count: s.count || 0 }));
}
// ---- semantic matching (2026-11-16)
const SEM = { answer: Number(process.env.NETKB_SEM_ANSWER) || 0.84, margin: 0.02, context: Number(process.env.NETKB_SEM_CONTEXT) || 0.68, unsure: 0.70, band: 0.08, away: 0.06, agree: 0.10, floor: 0.60 };
const MATCH_PAUSE_MS = 30000;
let matchDownUntil = 0;
const mstats = { matches: 0, matchErrors: 0, matchSkipped: 0, matchLastMs: 0, matchLastError: null, semAnswer: 0, semAgree: 0, semRegex: 0, semVeto: 0, semContext: 0 };
const matchOn = () => enabled() && process.env.NETKB_MATCH !== '0';
// -> the hub's answer {confidence, margin, hits: [{site, id, title, answer, score, boosted, home}]} or null (off, down, slow)
async function match(q, o) {
o = o || {};
if (!matchOn()) return null;
if (Date.now() < matchDownUntil) { mstats.matchSkipped++; return null; }
const t0 = Date.now();
try {
const body = { q: String(q || '').slice(0, 600), k: o.k || 6 };
if (o.prefer && o.prefer.length) body.prefer = o.prefer;
if (o.only && o.only.length) body.only = o.only;
const r = await call('POST', '/v1/kb/match', body, undefined, o.timeoutMs || Number(process.env.NETKB_MATCH_MS) || 1500);
mstats.matchLastMs = Date.now() - t0;
if (r.status !== 200 || !r.body || !Array.isArray(r.body.hits)) throw new Error('match ' + r.status + ' ' + ((r.body && r.body.error) || ''));
mstats.matches++;
return r.body;
} catch (e) { mstats.matchErrors++; mstats.matchLastError = e.message; matchDownUntil = Date.now() + MATCH_PAUSE_MS; return null; }
}
// msg + { fast: the instant-answer pattern hit (or null), own: this site's entries, prefer: [site ids the question names] }
// -> null (no match: the caller keeps its old path) or { via, hit: own entry to answer with | null, hits: [{entry, score}] for the prompt }
async function route(msg, o) {
o = o || {};
// a question that names another site but asks about "here" is about this site (e.g. "I am on InstantAdPay, does my team carry over here?")
const prefer = (o.prefer || []).length && !/\b(here|this site|this one)\b/i.test(msg) ? o.prefer : [];
const m = await match(msg, { k: 8, prefer });
if (!m) return null;
const me = siteName();
const own = new Map((o.own || []).map(e => [String(e.id), e]));
const rem = new Map(remote().map(e => [e.id, e]));
const all = m.hits.map(h => ({ entry: h.site === me ? own.get(String(h.id)) : rem.get(h.site + ':' + h.id), score: Number(h.score) || 0, home: h.site === me })).filter(h => h.entry);
let hits = all;
const named = prefer.length > 0, fast = o.fast || null;
if (!named) { // home-site first: this site's own entries lead; another site's ride behind them only when clearly closer (a thing only that site has)
const mine = hits.filter(h => h.home && h.score >= SEM.context);
const homeTop = mine.length ? mine[0].score : 0;
hits = mine.concat(hits.filter(h => !h.home && h.score >= homeTop + SEM.away));
}
const top = hits[0];
const ctx = top ? hits.filter(h => h.score >= SEM.context && (h.score >= top.score - SEM.band || !h.home)).map(h => ({ entry: h.entry, score: Math.round(h.score * 1000) / 1000 })) : [];
const out = (via, hit) => { mstats['sem' + via[0].toUpperCase() + via.slice(1)]++; return { via, hit, hits: ctx, confidence: top ? top.score : 0 }; };
if (top && top.home && !named && top.score >= SEM.answer && (Number(m.margin) >= SEM.margin || (fast && String(fast.id) === String(top.entry.id)))) return out('answer', top.entry);
if (fast) {
const best = all.length ? all[0].score : 0;
if (all.some(h => h.home && String(h.entry.id) === String(fast.id) && h.score >= SEM.floor && h.score >= best - SEM.agree)) return out('agree', fast);
if (!top || top.score < SEM.unsure) return out('regex', fast);
return out('veto', null);
}
return out('context', null);
}
// support desk suggestions (2026-11-16): the help answers closest to what a signed-in member is typing into a new ticket.
// Knowledge-base entries only (published answers, including the ones written from past tickets), never anyone's ticket text.
// text + { own: this site's entries, fallback: async q => [{entry}] (BM25) when the hub is slow or down, max }
const SUGGEST_MIN = Number(process.env.NETKB_SUGGEST_MIN) || 0.70;
const NOT_SUGGESTED = /(^|[-:])support$|^c-refund$/; // the "contact support" entry is no help on the support form itself
function suggestItem(e, home, score) {
return { id: String(e.id), title: e.title, answer: String(e.answer || '').slice(0, 900), site: home ? '' : (e.siteName || e.site || ''),
link: home ? (e.link || '') : (e.go || e.siteUrl || ''), fromTicket: !!(home && e.source === 'ticket'), score: score == null ? null : Math.round(score * 1000) / 1000 };
}
async function suggest(text, o) {
o = o || {};
const q = String(text || '').replace(/\s+/g, ' ').trim().slice(0, 600);
if (q.replace(/[^A-Za-z0-9]/g, '').length < 10) return { items: [], via: 'short' };
const me = siteName(); const own = new Map((o.own || []).map(e => [String(e.id), e]));
const keep = (e, home) => e && !(home && e.handoff) && !NOT_SUGGESTED.test(String(e.id));
let items = [], via = 'none';
const m = await match(q, { k: 8, timeoutMs: o.timeoutMs || 2000 });
if (m) {
via = 'semantic'; const top = m.hits.length ? Number(m.hits[0].score) : 0; const rem = new Map(remote().map(e => [e.id, e]));
for (const h of m.hits) {
if (h.score < SUGGEST_MIN || h.score < top - 0.08) continue;
const home = h.site === me; const e = home ? own.get(String(h.id)) : rem.get(h.site + ':' + h.id);
if (keep(e, home)) items.push(suggestItem(e, home, h.score));
}
} else if (typeof o.fallback === 'function') {
via = 'bm25';
try { for (const x of (await o.fallback(q)) || []) { const e = x && x.entry; const home = !!e && !e.site; if (keep(e, home)) items.push(suggestItem(e, home, null)); } } catch (e) {}
}
return { items: items.slice(0, o.max || 3), via };
}
// opts: { dataDir, site (hub site id), name, url, entries: async () => [...], linkFor: url => tracked link }
function init(opts) {
O = opts || {}; readCache();
if (!enabled()) return;
const first = setTimeout(async () => { await publish().catch(() => {}); await refresh().catch(() => {}); }, Math.max(0, Number(process.env.NETKB_FIRST_MS) || 8000));
if (first.unref) first.unref();
timer = setInterval(async () => { await refresh().catch(() => {}); if (!publishedHash) await publish().catch(() => {}); }, Math.max(1000, Number(process.env.NETKB_REFRESH_MS) || REFRESH_MS));
if (timer.unref) timer.unref();
}
function view() { return Object.assign({ enabled: enabled(), site: siteName(), version: merged.version, sites: Object.keys(merged.sites || {}), entries: (merged.entries || []).length, remote: remote().length, loadedAt, semantic: matchOn(), sem: SEM }, stats, mstats); }
function _set(m) { merged = m; } // tests
const version = () => merged.version || '';
function _matchReset() { matchDownUntil = 0; } // tests
module.exports = { init, publish, publishSoon, refresh, remote, sites, view, enabled, version, match, route, suggest, SEM, _set, _matchReset };
+33
View File
@@ -0,0 +1,33 @@
// Network links (Marty 2026-11-14: "Make sure each of these sites is its own traffic source and link spun so we can track it").
// The admin account (NETWORK_LINKS_OWNER, else ADMIN_EMAIL) owns one spin link per network site, with a fixed short code, and one
// traffic source per network site (catalog templates marked "network"). Every site links to the others through these:
// https://linkspin.app/r/<code>?src=<the site that sent the click>&s1=<member username>&s2=<page>
// src picks the traffic source (rotator.resolve + sources.networkSource), s1 fills ?ref= (the member keeps the sponsor credit),
// s2 is one path segment (how, join, ...; empty = the home page). Clicks show in that account's Reports by link and by source.
// Made once at boot when missing, never changed after: the owner may edit them like any link.
'use strict';
const SITES = [
{ id: 'iap', code: 'nwiap', name: 'InstantAdPay', url: 'https://instantadpay.com/{s2}?ref={s1}' },
{ id: 'linkspin', code: 'nwls', name: 'LinkSpin', url: 'https://linkspin.app/{s2}?ref={s1}' },
{ id: 'dlb', code: 'nwdlb', name: 'Downline Banners', url: 'https://downlinebanners.com/{s2}?ref={s1}' },
{ id: 'vbb', code: 'nwvbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com/{s2}?ref={s1}' },
{ id: 'viraladblitz', code: 'nwvab', name: 'ViralAdBlitz', url: 'https://viraladblitz.com/{s2}?ref={s1}' },
{ id: 'viraladsource', code: 'nwvas', name: 'ViralAdSource', url: 'https://viraladsource.com/{s2}?ref={s1}' },
{ id: 'yourprogrambuilder', code: 'nwypb', name: 'YourProgramBuilder', url: 'https://yourprogrambuilder.com/{s2}?ref={s1}' },
{ id: 'videoappincome', code: 'nwvai', name: 'Video App Income', url: 'https://videoappincome.com/{s2}?ref={s1}' }, // 2026-11-21: s2 = join for the invite page, empty = the sales page
{ id: 'socialtube', code: 'nwst', name: 'Social Tube', url: 'https://socialtube.club/{s2}?ref={s1}' }, // 2026-11-22: the network's video gallery; ?ref= keeps the member's credit on every page there
{ id: 'fivex', code: 'nw5x', name: '5xYourTeam', url: 'https://5xyourteam.com/{s2}?ref={s1}' },
{ id: 'downlinehydra', code: 'nwdh', name: 'DownlineHydra', url: 'https://downlinehydra.com/{s2}?ref={s1}' },
{ id: 'stackpol', code: 'nwsp', name: 'Stack POL', url: 'https://stackpol.com/{s2}?ref={s1}' },
{ id: 'earnerscorner', code: 'nwec', name: 'Earners Corner', url: 'https://earnerscorner.com/{s2}' }
];
function ensure(o) { // { owner, rotator, sources }
const owner = String(o.owner || '').trim().toLowerCase(); if (!owner) return { skipped: 'no owner' };
const out = { owner: owner.replace(/^(.).*(@.*)$/, '$1***$2'), links: [], sources: [] };
for (const s of SITES) {
const src = o.sources.networkSource(owner, s.id); out.sources.push(s.id + ':' + (src ? src.id : 'none'));
const r = o.rotator.ensureFixed(owner, s.code, 'Network: ' + s.name, s.url); out.links.push(s.code + ':' + (r.error || (r.created ? 'made' : 'ok')));
}
return out;
}
module.exports = { SITES, ensure };
+60
View File
@@ -0,0 +1,60 @@
// The network sites list for the footer's "Part of the network" line (Marty 2026-11-14 trust pack).
// One source: the hub's public GET /v1/network-sites (HUB_URL). Cached 10 minutes, refreshed in the background, never waits on a
// slow hub (2.5 s timeout), and falls back to the same built-in list. Never RM Circle, never the games.
// The same file lives in every network site (InstantAdPay, LinkSpin, Downline Banners, VBB, Stack POL).
const FALLBACK = [
{ id: 'iap', name: 'InstantAdPay', url: 'https://instantadpay.com' },
{ id: 'linkspin', name: 'LinkSpin', url: 'https://linkspin.app' },
{ id: 'dlb', name: 'Downline Banners', url: 'https://downlinebanners.com' },
{ id: 'vbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com' },
{ id: 'stackpol', name: 'Stack POL', url: 'https://stackpol.com' },
{ id: 'earnerscorner', name: 'Earners Corner', url: 'https://earnerscorner.com' }
];
const TTL = 10 * 60 * 1000;
let cache = { at: 0, list: FALLBACK, from: 'fallback' };
let inflight = null;
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
function clean(list) {
if (!Array.isArray(list)) return null;
const ok = list.filter(s => s && typeof s.name === 'string' && /^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(s.url || '')))
.slice(0, 30).map(s => ({ id: String(s.id || s.name).toLowerCase().replace(/[^a-z0-9]+/g, '').slice(0, 30), name: String(s.name).slice(0, 60), url: String(s.url).replace(/\/+$/, '') }));
return ok.length ? ok : null;
}
function refresh() {
if (inflight || process.env.NETWORK_SITES_HUB === '0') return inflight;
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
inflight = fetch(hubUrl() + '/v1/network-sites', { signal: ac.signal })
.then(r => (r.ok ? r.json() : null))
.then(j => { const l = clean(j); if (l) cache = { at: Date.now(), list: l, from: 'hub' }; else cache.at = Date.now(); })
.catch(() => { cache.at = Date.now() - TTL + 60 * 1000; }) // hub down: try again in a minute, keep the last good list
.finally(() => { clearTimeout(t); inflight = null; });
return inflight;
}
function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; }
// Tracked links (Marty 2026-11-14: "make sure each of these sites is its own traffic source and link spun so we can track it"): each
// entry also gets go = the LinkSpin network link for that site with ?src=<this site>, so a click shows in LinkSpin Reports under the
// site that sent it (LinkSpin netlinks.js: fixed codes on the admin account). This site = NETWORK_SITE_ID, else the request host.
// No go for this site itself, or when this site cannot be told (a test host): the page then uses the plain url.
const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', viraladblitz: 'nwvab', viraladsource: 'nwvas', yourprogrambuilder: 'nwypb', videoappincome: 'nwvai', fivex: 'nw5x', downlinehydra: 'nwdh', stackpol: 'nwsp', earnerscorner: 'nwec' };
const linksBase = () => String(process.env.NETWORK_LINKS_BASE || 'https://linkspin.app').trim().replace(/\/+$/, '');
const hostOf = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
function selfId(req, l) {
const env = String(process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); if (env) return env;
const h = String((req && req.headers && (req.headers['x-forwarded-host'] || req.headers.host)) || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
const m = h && (l || list()).find(s => hostOf(s.url) === h); return m ? m.id : '';
}
// the LinkSpin-tracked link to site `id` sent from site `from` (from = id: the site's own promo kit); extra = { s1: member username, s2: one path segment }
function tracked(id, from, extra) {
const code = CODES[id]; if (!code || !from) return '';
const q = new URLSearchParams({ src: from }); for (const [k, v] of Object.entries(extra || {})) if (v) q.set(k, String(v));
return linksBase() + '/r/' + code + '?' + q.toString();
}
function withGo(l, me) { return l.map(s => { const go = me && s.id !== me ? tracked(s.id, me) : ''; return go ? Object.assign({}, s, { go }) : s; }); }
// GET /api/network-sites: public, cacheable, the same answer on every page
function handle(req, res) {
const l = list();
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' });
res.end(JSON.stringify(withGo(l, selfId(req, l))));
}
module.exports = { list, handle, refresh, tracked, selfId, withGo, CODES, FALLBACK, _state: () => cache };
+452
View File
@@ -0,0 +1,452 @@
// Network sign-in between InstantAdPay and LinkSpin (Marty approved 2026-11-12). The SAME file ships in both repos; each
// server calls init({ self, peer, peerBase, ... hooks }) and hands every request to handle() before its own routes.
//
// One flow, used two ways. R = the site the member is going TO (receiver), P = the site they are signed in on (provider).
// 1. R GET /sso/start?mode=go|check&to=/path R makes a random state, keeps it in a 5-minute HttpOnly cookie (nsso.st),
// sets the loop guard (nsso.tried, 2 minutes) and sends the browser to P.
// 2. P GET /sso/check?st=<state>&to=/path P looks at its OWN member session (never the admin portal). Signed in:
// P mints a token bound to R, the state and the email, and sends the browser
// to R /sso/in?t=<token>. Not signed in: R /sso/in?none=1&to=/path.
// 3. R GET /sso/in?t=<token> R checks signature, audience, expiry (60 s), the state against its cookie
// (so nobody can push their own token into someone else's browser), and spends
// the nonce (a second use is refused). The email must already be a member
// here; then R makes an ordinary session and redirects to the relative path.
// Outbound links: P GET /go/<peer>?to=/path is the hop a signed-in member's cross-site link points at. Signed out (or the
// secret not set), it is a plain redirect to the other site, so it is always safe to link through.
// Silent check: R's sign-in page calls GET /api/sso/status; { check: true } means "bounce once through P". The guard cookie
// stops a second bounce for 2 minutes (30 until 2026-11-15, when it blocked Marty's silent sign-in on LinkSpin), signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
// bots and non-page fetches never bounce.
// Token: "v1.<base64url JSON>.<base64url HMAC-SHA256(NETWORK_SSO_SECRET, 'nsso.v1.' + JSON part)>", JSON = { iss, aud, email,
// st, to, iat, exp, n[, wallet, name] }. The token grants a plain member session and nothing else: no wallet action, payout or purchase rides on it.
//
// Wallet sites (Downline Banners, 2026-11-13, Marty: "sign in once and be logged into all these sites"). Downline Banners has no email
// accounts; its members are wallets. IAP and LinkSpin list it under `wallets: { bannerline: base }` and vouch one way: /go/bannerline
// and /sso/check?r=bannerline mint a token that also carries the member's wallet (the one they signed in with, else the main wallet
// their account linked by signature) and username. Downline Banners runs this file with `from: { iap, linkspin }`, accepts a token from
// either, and makes a session for that wallet. /sso/start?via=<site> picks which site to ask; old copies ignore the new parameters.
//
// THE HUB AS THE PROVIDER (Marty approved 2026-11-15; off unless HUB_SSO=on, with HUB_URL, HUB_SECRET (32+) and HUB_SITE or C.hubSite).
// The network hub keeps one network sign-in per browser in its own cookie (7 days, renewed on use). With it on:
// /sso/start asks the hub (GET <hub>/sso/check?site=<HUB_SITE>&st&to&m) instead of one other site; the hub answers
// /sso/in?h=<token> ("h1." token, HMAC-SHA256 with this site's HUB_SECRET under 'hubsso.v1.', iss 'hub', aud = this site,
// 60 s, single use, bound to the state cookie) or /sso/in?none=1&hub=1, and then the old pairwise path is tried once as the
// fallback (until every site is switched).
// Push: a signed-in member's page load (a real top-level navigation only) with no matching nsso.hp cookie goes once through
// <hub>/sso/set?site&t=<this site's token for the member> and straight back, so signing in on any site signs in the hub.
// Only when the hub answered /health in the last 2 minutes: a hub that is down never takes a page with it.
// Activity (Marty 2026-11-15, DownlineHydra "Wake it", the CRM score): a signed-in member's page load pings POST <hub>/v1/activity
// {email|wallet, kind 'visit'} at most once per member per day, fire and forget (HUB_URL + HUB_SECRET; HUB_ACTIVITY=0 turns it off).
// signOutEverywhere(session): POST <hub>/v1/sso/signout; the hub ends every hub sign-in of that person and tells hooked sites.
//
// ONE SITES LIST + THE WAY BACK (Marty 2026-11-17: "I logged in to Instant Ad Pay from Viral Ad Source, and it never had a return
// path back"). Before, each provider (IAP, LinkSpin) kept its own hand-written `wallets` list; a site missing from it (5xYourTeam
// 11-15, ViralAdSource 11-17) was refused at /sso/check and the member was dropped on the provider's dashboard with no way back.
// Sites list: a provider also knows every site in the hub's public GET <hub>/v1/sso-sites (HUB_SSO_SITES there; the same list the
// hub signs in for). Read at start, every 5 minutes, and once more (2 s at most) when an unknown site asks. Hand-written entries win.
// Return links: any provider page with ?return=<site>&to=/path (a known site only, never an open redirect) remembers the way back
// in nsso.ret (1 day) and reloads without the two parameters. Signed in already: straight back. After the email-code sign-in (and
// after the username step for a new account) the provider's dashboard goes to /sso/resume, which finishes it: /go/<site>?to=/path.
// No wallet yet (a wallet site needs one): with C.walletPath the member goes to the provider's wallet step first (nsso.wait), and
// afterWallet(req) gives the wallet-link answer its next hop, /sso/resume. The same holds for a deliberate tap (nsso.back).
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const SECRET = () => String(process.env.NETWORK_SSO_SECRET || '').trim();
const enabled = () => SECRET().length >= 32;
const TTL = 60 * 1000; // token life
const SKEW = 30 * 1000; // clock skew allowed between the two servers
const STATE_AGE = 300; // seconds: the state cookie
const GO_STATE_AGE = 3600; // seconds: the state cookie on a deliberate tap (time to sign in, pick a username and link a wallet on the provider first; 20 minutes until 2026-11-17)
const BACK_AGE = 3600; // seconds: the provider remembers an unfinished deliberate check while the member signs in (20 minutes until 2026-11-17)
const RET_AGE = 86400; // seconds: a ?return=<site> link remembers the way back (2026-11-17)
const TRIED_AGE = 120; // seconds: one silent check per browser per 2 minutes (loop guard only; 30 minutes until 2026-11-15)
const OFF_AGE = 12 * 3600; // seconds: no silent check after a sign-out on this site
const HINT_AGE = 300; // seconds: the email prefill when the member is not here yet
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz', downlinehydra: 'DownlineHydra', fivex: '5xYourTeam' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15); downlinehydra = DownlineHydra (2026-11-15); fivex = 5xYourTeam (2026-11-15)
const WALLET_RE = /^0x[0-9a-f]{40}$/;
const PUSH_AGE = 6 * 86400; // seconds: this browser's member is signed in on the hub (the hub's own sign-in lasts 7 days)
const HUB_BASE = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
const HUB_KEY = () => String(process.env.HUB_SECRET || '').trim();
const HUB_NAME = () => String(process.env.HUB_SITE || (C && (C.hubSite || C.self)) || '').trim().toLowerCase();
const hubCreds = () => /^https?:\/\/[a-z0-9.:-]+$/i.test(HUB_BASE()) && HUB_KEY().length >= 32 && /^[a-z0-9_-]{1,64}$/.test(HUB_NAME());
const hubOn = () => String(process.env.HUB_SSO || '').trim().toLowerCase() === 'on' && hubCreds();
let hubSeen = 0, hubChecked = 0, hubAsking = null; // last good /health answer, last time we asked
// true when the hub answered /health in the last 2 minutes. Asked at most once a minute; while the answer is unknown (first use, or
// the last good answer is old) the caller waits for that one question (2 s at most), so a hub that is down costs one page 2 s a minute.
async function hubUp() {
const now = Date.now();
if (now - hubChecked >= 60000 && !hubAsking && typeof fetch === 'function') {
hubChecked = now;
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, 2000);
hubAsking = fetch(HUB_BASE() + '/health', { signal: ac ? ac.signal : undefined }).then(r => { if (r.ok) hubSeen = Date.now(); }).catch(() => {}).finally(() => { clearTimeout(tm); hubAsking = null; });
}
if (hubAsking && Date.now() - hubSeen >= 120000) await hubAsking;
return Date.now() - hubSeen < 120000;
}
// the hub's sign-in sites {site: base} (2026-11-17): providers answer every site the hub knows, not only their hand-written list
let hubSites = {}, hubSitesAt = 0, hubSitesAsking = null;
const SITE_RE = /^[a-z0-9_-]{1,64}$/, BASE_RE = /^https?:\/\/[a-z0-9.:-]+$/i;
function loadHubSites() {
if (hubSitesAsking) return hubSitesAsking;
if (!BASE_RE.test(HUB_BASE()) || typeof fetch !== 'function' || String(process.env.NSSO_HUB_SITES || '') === '0') return Promise.resolve();
hubSitesAt = Date.now();
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, 2000);
hubSitesAsking = fetch(HUB_BASE() + '/v1/sso-sites', { signal: ac ? ac.signal : undefined }).then(r => (r.ok ? r.json() : null)).then(j => {
if (!j || !j.sites || typeof j.sites !== 'object') return;
const out = {}; for (const [k, v] of Object.entries(j.sites)) { const b = String(v || '').replace(/\/+$/, ''); if (SITE_RE.test(k) && BASE_RE.test(b)) out[k] = b; }
hubSites = out;
}).catch(() => {}).finally(() => { clearTimeout(tm); hubSitesAsking = null; });
return hubSitesAsking;
}
const freshSites = () => { if (C && C.wallet && Date.now() - hubSitesAt > 5 * 60 * 1000) loadHubSites(); };
let C = null; // { self, peer, peerBase(), isProd, dataDir, db, member(req), accept(email, req, v), signIn(email, req, v), landing(to), signinPath(to), defaultPath,
// wallets?: { site: base() } + wallet(session) -> { address, name }, from?: { site: base() }, walletPath?: the provider's wallet step }
const b64u = buf => Buffer.from(buf).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
const unb64u = s => Buffer.from(String(s).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
const mac = s => crypto.createHmac('sha256', SECRET()).update('nsso.v1.' + s).digest();
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
const log = (what, email, extra) => console.log('network-sso', what, email ? mask(email) : '-', extra || '');
// a same-site relative path, or the default. No scheme, no host, no protocol-relative //x, no backslashes, no control characters.
function safePath(to, dflt) {
const d = dflt == null ? '/' : dflt;
const s = String(to == null ? '' : to);
if (!s || s.length > 600 || s[0] !== '/' || s[1] === '/' || s[1] === '\\' || /[\\\u0000-\u001f\u007f\s]/.test(s)) return d;
try { const x = new URL(s, 'http://x.invalid'); if (x.host !== 'x.invalid' || x.protocol !== 'http:') return d; return x.pathname + x.search + x.hash; } catch (e) { return d; }
}
function mint(o) {
const now = o.now || Date.now();
const t = { iss: o.iss, aud: o.aud, email: String(o.email || '').trim().toLowerCase(), st: o.st, to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
if (o.name) t.name = String(o.name).slice(0, 40);
const body = b64u(JSON.stringify(t));
return 'v1.' + body + '.' + b64u(mac(body));
}
// -> { ok, email, to, n, exp } or { error: reason }
function verify(tok, o) {
if (!enabled()) return { error: 'off' };
const m = /^v1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
if (!m) return { error: 'malformed' };
const want = mac(m[1]), got = unb64u(m[2]);
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
const now = (o && o.now) || Date.now();
if (!p || p.aud !== o.aud || ![].concat(o.iss).includes(p.iss)) return { error: 'audience' };
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
const st = String((o && o.st) || '');
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
return { ok: true, iss: p.iss, email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
}
// hub tokens ("h1.", the hub's format): mint for the hub (push), verify from the hub (sign-in)
const hmacHub = x => crypto.createHmac('sha256', HUB_KEY()).update('hubsso.v1.' + x).digest();
function mintHub(o) {
const now = o.now || Date.now();
const t = { iss: HUB_NAME(), aud: 'hub', to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
if (o.email) t.email = String(o.email).trim().toLowerCase(); else if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
const body = b64u(JSON.stringify(t));
return 'h1.' + body + '.' + b64u(hmacHub(body));
}
function verifyHub(tok, o) {
if (!hubCreds()) return { error: 'off' };
const m = /^h1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
if (!m) return { error: 'malformed' };
const want = hmacHub(m[1]), got = unb64u(m[2]);
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
const now = (o && o.now) || Date.now();
if (!p || p.iss !== 'hub' || p.aud !== HUB_NAME()) return { error: 'audience' };
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
const st = String((o && o.st) || '');
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
return { ok: true, iss: 'hub', email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
}
// a signed /v1 call to the hub (the scheme every site already uses): hex HMAC-SHA256(HUB_SECRET, ts + newline + body)
async function hubCall(route, body, ms) {
const raw = JSON.stringify(body || {}); const ts = String(Date.now());
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, ms || 5000);
try {
const r = await fetch(HUB_BASE() + route, { method: 'POST', body: raw, signal: ac ? ac.signal : undefined, headers: { 'Content-Type': 'application/json', 'X-Hub-Site': HUB_NAME(), 'X-Hub-Ts': ts, 'X-Hub-Sig': crypto.createHmac('sha256', HUB_KEY()).update(ts + '\n' + raw).digest('hex') } });
let j = null; try { j = await r.json(); } catch (e) {}
return { status: r.status, json: j };
} finally { clearTimeout(tm); }
}
const who = s => (s && s.email ? { email: String(s.email).toLowerCase() } : s && s.address && WALLET_RE.test(String(s.address).toLowerCase()) ? { wallet: String(s.address).toLowerCase() } : null);
const pushTag = w => b64u(crypto.createHmac('sha256', HUB_KEY()).update('push.' + (w.email || w.wallet)).digest()).slice(0, 22);
// once per member per day (memory; a restart may ping once more, the hub counts a visit once per 10 minutes anyway)
const pinged = new Map(); let pingDay = '';
function activity(w) {
if (String(process.env.HUB_ACTIVITY || '') === '0' || !hubCreds() || typeof fetch !== 'function') return;
const day = new Date().toISOString().slice(0, 10); if (day !== pingDay) { pinged.clear(); pingDay = day; }
const k = w.email || w.wallet; if (pinged.has(k)) return; pinged.set(k, 1);
hubCall('/v1/activity', Object.assign({ kind: 'visit' }, w), 5000).then(r => { if (r.status >= 500) pinged.delete(k); }).catch(() => { pinged.delete(k); });
}
// a signed-in request the site already answers (2026-11-16, Marty: "LinkSpin never reports activity"): /api/me, the dashboard
// heartbeat (/api/my/ping) and the admin portal call this, so a Control Room tab kept open for days, a browser that sends no
// Sec-Fetch headers and a wallet-only session still count the day's visit. The page-load ping in page() only sees full navigations.
// s = {email} and/or {address}. Same once-a-day rule as page(). -> true when a ping was due or already sent today.
function seen(s) {
try {
if (!C || !hubCreds()) return false;
const w = who(s && s.email ? s : s && s.address ? { address: s.address } : null); if (!w) return false;
activity(w); return true;
} catch (e) { return false; }
}
// a real top-level page load of a page (never an API call, an asset, a fetch, a bot or one of our own hops)
function pageLoad(req, p) {
if (req.method !== 'GET' || isBot(req)) return false;
if (req.headers['sec-fetch-dest'] !== 'document' || (req.headers['sec-fetch-mode'] && req.headers['sec-fetch-mode'] !== 'navigate')) return false;
if (/^\/(sso|api|go|assets|art|img|fonts|uploads|admin)(\/|$)/.test(p)) return false;
return !/\.[a-z0-9]{1,5}$/i.test(p);
}
async function signOutEverywhere(s) {
const w = who(s); if (!w || !hubCreds()) return { ok: false, reason: !w ? 'signed out' : 'hub off' };
try { const r = await hubCall('/v1/sso/signout', w, 8000); return r.status === 200 ? Object.assign({ ok: true }, r.json || {}) : { ok: false, reason: 'hub ' + r.status }; }
catch (e) { return { ok: false, reason: 'hub unreachable' }; }
}
// single use: true the first time a nonce is spent. MySQL when the site runs on it (two app copies during a deploy share it),
// else memory + a small file in DATA_DIR (survives a restart inside the 60-second window).
const used = new Map(); let fileLoaded = false, tableReady = null;
const FILE = () => C && C.dataDir ? path.join(C.dataDir, 'network-sso-nonces.json') : null;
function prune(now) { for (const [k, exp] of used) if (exp < now) used.delete(k); }
function loadFile() {
if (fileLoaded) return; fileLoaded = true;
try { const o = JSON.parse(fs.readFileSync(FILE(), 'utf8')); for (const k of Object.keys(o)) used.set(k, Number(o[k])); } catch (e) {}
}
function saveFile() { const f = FILE(); if (!f) return; try { fs.writeFileSync(f + '.tmp', JSON.stringify(Object.fromEntries(used))); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('network-sso nonce save', e.message); } }
async function spend(n, exp) {
const now = Date.now(); loadFile(); prune(now);
if (used.has(n)) return false;
used.set(n, Number(exp) + SKEW); saveFile();
const db = C && C.db;
if (db && db.enabled && db.enabled()) {
try {
if (!tableReady) tableReady = db.q('CREATE TABLE IF NOT EXISTS network_sso_nonces (n VARCHAR(40) PRIMARY KEY, exp BIGINT NOT NULL) ENGINE=InnoDB').catch(e => { tableReady = null; throw e; });
await tableReady;
await db.q('INSERT INTO network_sso_nonces (n, exp) VALUES (?, ?)', [n, Number(exp) + SKEW]);
if (Math.random() < 0.05) db.q('DELETE FROM network_sso_nonces WHERE exp < ?', [now]).catch(() => {});
} catch (e) { if (/duplicate/i.test(e.message || '') || e.code === 'ER_DUP_ENTRY') return false; console.error('network-sso nonce db', e.message); return false; } // fail closed
}
return true;
}
// crawlers, link previews and headless browsers never bounce
const BOT_RE = /bot|crawl|spider|slurp|preview|facebookexternalhit|embedly|quora link|whatsapp|telegram|discord|skype|curl|wget|python|httpclient|headless|lighthouse|pingdom|monitor|go-http|java\/|okhttp|axios|node-fetch|undici/i;
const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT_RE.test(ua); };
// only a real top-level page load may start a bounce (sec-fetch-dest is sent by every current browser)
const notPage = req => { const d = req.headers['sec-fetch-dest']; return !!d && d !== 'document'; };
function cookies(req) {
const out = {};
for (const p of String(req.headers.cookie || '').split(';')) { const i = p.indexOf('='); if (i > 0) { try { out[p.slice(0, i).trim()] = decodeURIComponent(p.slice(i + 1).trim()); } catch (e) {} } }
return out;
}
const ck = (k, v, age, httpOnly) => k + '=' + encodeURIComponent(v) + '; Path=/; SameSite=Lax; Max-Age=' + age + (httpOnly ? '; HttpOnly' : '') + (C && C.isProd ? '; Secure' : '');
const go = (res, loc, set) => { const h = { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Robots-Tag': 'noindex' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(302, h); res.end(); return true; };
const sendJson = (res, obj, set) => { const h = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(200, h); res.end(JSON.stringify(obj)); return true; };
function init(opts) { C = Object.assign({ defaultPath: '/' }, opts); fileLoaded = false; used.clear(); if (hubOn()) { hubSeen = 0; hubChecked = 0; hubUp().catch(() => {}); } hubSites = {}; hubSitesAt = 0; if (C.wallet) loadHubSites(); }
// a site this provider answers for: its own list first, then the hub's (never itself, never the peer, which has its own path)
function siteBase(x) {
if (!C || !C.wallet || !SITE_RE.test(String(x || '')) || x === C.self || x === C.peer) return null;
if (C.wallets && Object.prototype.hasOwnProperty.call(C.wallets, x)) return C.wallets[x];
if (Object.prototype.hasOwnProperty.call(hubSites, x)) { const b = hubSites[x]; return () => b; }
return null;
}
// an unknown site asking: ask the hub once more (at most every 30 s, 2 s at most) before refusing
async function siteBaseFresh(x) { let b = siteBase(x); if (!b && C && C.wallet && SITE_RE.test(String(x || '')) && Date.now() - hubSitesAt > 30000) { await loadHubSites(); b = siteBase(x); } return b; }
const siteName = x => NAMES[x] || ({ viraladsource: 'ViralAdSource', webworthit: 'WebWorthIt', stackpol: 'Stack POL' })[x] || x;
const retOf = req => { const m = /^([a-z0-9_-]{1,64})\|(\/.*)$/.exec(cookies(req)['nsso.ret'] || ''); return m ? { site: m[1], to: safePath(m[2], '/') } : null; };
// signed in here, on the way back to a site: its wallet step first when the site needs a wallet this account does not have yet
async function backHop(s, site, to, set) {
let w = null; try { w = await C.wallet(s); } catch (e) {}
if ((!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) && C.walletPath) { set.push(ck('nsso.wait', '1', BACK_AGE, true)); log('back: wallet step first', s.email, 'for ' + siteName(site)); return C.walletPath; }
return '/go/' + site + '?to=' + encodeURIComponent(to);
}
// the cookie a sign-out adds: no silent check on this site for 12 hours (a deliberate cross-site link still signs in)
const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
// -> true when the request was one of ours and has been answered
async function handle(req, res, u) {
if (!C || req.method !== 'GET') return false;
const p = u.pathname;
if (C.wallet && u.searchParams.has('return') && !/^\/(sso|api|go)(\/|$)/.test(p)) { // a site's "sign in / join on <provider>" link: remember the way back (2026-11-17)
const site = String(u.searchParams.get('return') || '').toLowerCase(); const to = safePath(u.searchParams.get('to'), '/');
const clean = new URL(u.pathname + u.search, 'http://x.invalid'); clean.searchParams.delete('return'); clean.searchParams.delete('to');
const here = safePath(clean.pathname + clean.search, '/');
const base = isBot(req) ? null : await siteBaseFresh(site);
if (!base) return go(res, here); // unknown site (or a bot): the page itself, nothing remembered
let s = null; try { s = await C.member(req); } catch (e) {}
if (s && s.email) { // signed in here already: straight back (wallet step first when the site needs one)
const set = []; const hop = await backHop(s, site, to, set);
set.push(hop === C.walletPath ? ck('nsso.ret', site + '|' + to, RET_AGE, true) : ck('nsso.ret', '', 0, true));
return go(res, hop, set);
}
log('return link remembered', null, 'for ' + siteName(site));
return go(res, here, [ck('nsso.ret', site + '|' + to, RET_AGE, true), ck('nsso.wait', '', 0, true)]);
}
const peerName = NAMES[C.peer] || C.peer;
const goTo = p.startsWith('/go/') ? p.slice(4) : '';
const walletBase = siteBase; freshSites(); // the hand-written list, then the hub's sign-in sites (2026-11-17)
if (goTo && (goTo === C.peer || walletBase(goTo))) {
const base = goTo === C.peer ? C.peerBase() : walletBase(goTo)();
const to = safePath(u.searchParams.get('to'), '/');
const plain = base + to;
if (!enabled() || isBot(req)) return go(res, plain);
let s = null; try { s = await C.member(req); } catch (e) {}
if (!s || !s.email) return go(res, plain);
if (goTo !== C.peer) { let w = null; try { w = await C.wallet(s); } catch (e) {} if (!w || !w.address) return go(res, plain); } // no wallet to vouch for: a plain link
return go(res, base + '/sso/start?mode=go' + (goTo === C.peer ? '' : '&via=' + C.self) + '&to=' + encodeURIComponent(to));
}
if (p === '/sso/start') {
const to = safePath(u.searchParams.get('to'), C.defaultPath);
const mode = u.searchParams.get('mode') === 'go' ? 'go' : 'check';
const via = String(u.searchParams.get('via') || '');
const from = C.from && Object.prototype.hasOwnProperty.call(C.from, via) ? C.from[via] : null; // a wallet site may ask either provider
const viaHub = hubOn() && !u.searchParams.get('nohub') && (await hubUp());
if (!(enabled() || viaHub) || isBot(req) || notPage(req)) return go(res, to);
let s = null; try { s = await C.member(req); } catch (e) {}
if (s && (s.email || s.address)) return go(res, to); // already signed in here
const c = cookies(req);
if (mode === 'check' && (c['nsso.tried'] || c['nsso.off']) && !u.searchParams.get('nohub')) return go(res, to);
const st = crypto.randomBytes(16).toString('hex');
if (viaHub) { // the hub answers for the whole network; the pairwise provider is the fallback when it has nobody (nsso.via)
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true), ck('nsso.via', via || '-', STATE_AGE, true)];
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
return go(res, HUB_BASE() + '/sso/check?site=' + encodeURIComponent(HUB_NAME()) + '&st=' + st + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
}
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)];
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
}
if (p === '/sso/resume') { // signed in on the provider after a deliberate tap: finish the check it was asked for (2026-11-14)
const q = new URLSearchParams(cookies(req)['nsso.back'] || '');
const clear = [ck('nsso.back', '', 0, true), ck('nsso.wait', '', 0, true)];
if (!/^[a-f0-9]{32}$/.test(q.get('st') || '')) { // no deliberate tap waiting: a ?return=<site> link may be (2026-11-17)
const ret = retOf(req);
if (!ret || !siteBase(ret.site)) return go(res, C.defaultPath, clear.concat(ck('nsso.ret', '', 0, true)));
let s = null; try { s = await C.member(req); } catch (e) {}
if (!s || !s.email) return go(res, C.signinPath(C.defaultPath)); // not signed in yet: keep it for after the sign-in
const set = clear.slice(); const hop = await backHop(s, ret.site, ret.to, set);
set.push(hop === C.walletPath ? ck('nsso.ret', ret.site + '|' + ret.to, RET_AGE, true) : ck('nsso.ret', '', 0, true));
log('back to ' + siteName(ret.site), s.email); return go(res, hop, set);
}
return go(res, '/sso/check?st=' + q.get('st') + (q.get('r') ? '&r=' + encodeURIComponent(q.get('r')) : '') + '&to=' + encodeURIComponent(safePath(q.get('to'), '/')) + '&m=go', clear); // m=go: still a deliberate tap (the wallet step when one is missing)
}
if (p === '/sso/check') {
const st = String(u.searchParams.get('st') || '');
const to = safePath(u.searchParams.get('to'), '/');
const r = String(u.searchParams.get('r') || '');
const wb = r && r !== C.peer ? await siteBaseFresh(r) : null; // a wallet site asking: the token carries the wallet (the hub's sign-in sites too, 2026-11-17)
if (r && r !== C.peer && !wb) { log('check: unknown site asking, nothing sent', null, r.slice(0, 20)); return go(res, C.defaultPath); } // never answer an unknown site as if the peer asked (2026-11-15: 5xYourTeam was sent to LinkSpin)
const base = wb ? wb() : C.peerBase(), aud = wb ? r : C.peer, forName = siteName(aud);
const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to);
if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none);
let s = null; try { s = await C.member(req); } catch (e) {}
if (!s || !s.email) {
if (u.searchParams.get('m') === 'go' && !isBot(req)) { // a deliberate tap: sign in here first, then /sso/resume finishes the trip
log('check: not signed in here, asking to sign in', null, 'for ' + forName);
const back = new URLSearchParams({ st, to }); if (r) back.set('r', r);
return go(res, C.signinPath(C.defaultPath), [ck('nsso.back', back.toString(), BACK_AGE, true)]);
}
log('check: not signed in here', null, 'for ' + forName); return go(res, none);
}
let w = null;
if (wb) { try { w = await C.wallet(s); } catch (e) {} if (!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) {
if (u.searchParams.get('m') === 'go' && C.walletPath && !isBot(req)) { // a deliberate tap: link a wallet here first, then /sso/resume finishes the trip (2026-11-17)
log('check: no wallet on the account, wallet step first', s.email, 'for ' + forName);
const back = new URLSearchParams({ st, to, m: 'go' }); if (r) back.set('r', r);
return go(res, C.walletPath, [ck('nsso.back', back.toString(), BACK_AGE, true), ck('nsso.wait', '1', BACK_AGE, true)]);
}
log('check: no wallet on the account', s.email, 'for ' + forName); return go(res, none); } }
log('token issued', s.email, 'for ' + forName);
return go(res, base + '/sso/in?t=' + mint({ iss: C.self, aud, email: s.email, wallet: w && w.address, name: w && w.name, st, to }));
}
if (p === '/sso/in') {
const c = cookies(req);
const set = [ck('nsso.st', '', 0, true)];
if (u.searchParams.get('none')) {
const nto = safePath(u.searchParams.get('to'), C.defaultPath);
if (u.searchParams.get('hub') && enabled()) { // nobody on the hub: ask the old pairwise provider once (until every site is switched)
const via = String(c['nsso.via'] || ''); set.push(ck('nsso.via', '', 0, true));
log('none on the hub, trying ' + (NAMES[via] || peerName));
return go(res, '/sso/start?nohub=1&mode=' + (u.searchParams.get('m') === 'go' ? 'go' : 'check') + (via && via !== '-' ? '&via=' + encodeURIComponent(via) : '') + '&to=' + encodeURIComponent(nto), set);
}
log('none: not signed in on ' + (u.searchParams.get('hub') ? 'the hub' : peerName)); return go(res, C.signinPath(nto), set);
}
const fromHub = !!u.searchParams.get('h');
const v = fromHub ? verifyHub(u.searchParams.get('h'), { st: c['nsso.st'] }) : verify(u.searchParams.get('t'), { iss: [C.peer].concat(Object.keys(C.from || {})), aud: C.self, st: c['nsso.st'] });
if (v.error) { log('refused: ' + v.error); return go(res, C.signinPath(C.defaultPath), set); }
if (!(await spend(v.n, v.exp))) { log('refused: token already used', v.email); return go(res, C.signinPath(v.to), set); }
let a = null; try { a = await C.accept(v.email, req, v); } catch (e) { a = { fallback: 'error ' + e.message }; }
if (!a || !a.ok) { // not a member here yet (or not allowed to sign in): the normal email-code sign-in, email filled in
log('fallback to email code: ' + ((a && a.fallback) || 'not accepted'), v.email);
set.push(ck('nsso.hint', v.email, HINT_AGE, true));
return go(res, C.signinPath(v.to), set);
}
let cookie = null; try { cookie = await C.signIn(v.email, req, v); } catch (e) { console.error('network-sso sign-in', e.message); }
if (!cookie) { log('fallback to email code: session not made', v.email); return go(res, C.signinPath(v.to), set); }
set.push(cookie); if (c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
if (fromHub) { const w2 = v.wallet && C.from ? { wallet: v.wallet } : { email: v.email }; set.push(ck('nsso.hp', pushTag(w2), PUSH_AGE, true)); } // the hub already has this sign-in
log('signed in from ' + (fromHub ? 'the network hub' : (NAMES[v.iss] || peerName)), v.email);
return go(res, C.landing(v.to === '/' ? C.defaultPath : v.to), set); // no page named: the dashboard, not the public home page (2026-11-13)
}
if (p === '/api/sso/status') {
const c = cookies(req); const set = [];
let s = null; try { s = await C.member(req); } catch (e) {}
const signedIn = !!(s && (s.email || s.address));
const out = { peer: hubOn() ? 'the network' : peerName, check: (enabled() || (hubOn() && (await hubUp()))) && !signedIn && !isBot(req) && !c['nsso.tried'] && !c['nsso.off'] };
if (c['nsso.hint']) { if (!signedIn) out.hint = c['nsso.hint']; set.push(ck('nsso.hint', '', 0, true)); }
return sendJson(res, out, set);
}
return false;
}
// every GET a site serves passes here first (2026-11-15): a signed-in member's real page load pings the hub's activity once a day and,
// with the hub on, tells the hub about this sign-in once (nsso.hp). -> true when it answered (the redirect through the hub).
async function page(req, res, u) {
if (!C || !hubCreds()) return false;
const p = u.pathname;
if (!pageLoad(req, p)) return false;
let s = null; try { s = await C.member(req); } catch (e) {}
const w = who(s); if (!w) return false;
activity(w);
if (hubOn() && cookies(req)['nsso.hp'] !== pushTag(w) && (await hubUp())) {
log('hub: telling the hub about this sign-in', w.email || null);
return go(res, HUB_BASE() + '/sso/set?site=' + encodeURIComponent(HUB_NAME()) + '&t=' + mintHub(Object.assign({ to: p + u.search }, w)), [ck('nsso.hp', pushTag(w), PUSH_AGE, true)]);
}
return false;
}
// true when this browser came here from a deliberate network tap (nsso.back) or a ?return=<site> link (nsso.ret) and still has to
// finish it after signing in. False while it waits on the wallet step (nsso.wait): the dashboard must not bounce it back and forth.
const pendingBack = req => { const c = cookies(req); return !!(c['nsso.back'] || retOf(req)) && !c['nsso.wait']; };
// the wallet was just linked: the next hop when a way back is waiting (2026-11-17), else null
const afterWallet = req => { const c = cookies(req); return c['nsso.back'] || retOf(req) ? '/sso/resume' : null; };
// the name of the site a member is on the way back to, for a line on the provider's dashboard; null when none
function backName(req) {
const c = cookies(req); const ret = retOf(req);
if (ret) return siteName(ret.site);
if (!c['nsso.back']) return null;
const r = new URLSearchParams(c['nsso.back']).get('r'); return siteName(r || (C && C.peer) || '') || null;
}
module.exports = { init, handle, page, seen, enabled, pendingBack, afterWallet, backName, siteBase, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES, hubOn, hubCreds, signOutEverywhere, mintHub, verifyHub, _hubSeen: t => { hubSeen = t == null ? Date.now() : t; hubChecked = Date.now(); }, _pinged: pinged, _hubSites: o => { if (o) { hubSites = o; hubSitesAt = Date.now(); } return hubSites; } };
+5 -1
View File
@@ -344,7 +344,11 @@ function create() {
+ (top || 'Nobody qualified this week.') + '\nNo money moved' + (c.mode === 'live' ? ' (live switch is on but not paying: ' + live.why.join('; ') + ')' : '') + '. Details: ' + SITE_URL + '/api/admin/override?week=' + r.week, null).catch(() => {}); + (top || 'Nobody qualified this week.') + '\nNo money moved' + (c.mode === 'live' ? ' (live switch is on but not paying: ' + live.why.join('; ') + ')' : '') + '. Details: ' + SITE_URL + '/api/admin/override?week=' + r.week, null).catch(() => {});
} }
return { init, report, week, recipientFor, tick, plan, pay, payDue, resolve, dueWeeks, weekStatus, payerStatus, liveState, overrideTxs, txInfo, claim, cfg }; // the same payer wallet + award(memberId) path for other admin-approved POL awards (launch contest, 2026-11-05):
// null when no key is configured. Independent of overrideMode: the caller is an admin button, not the weekly scheduler.
const payerHandle = () => (payerOverride || keyHex()) ? payer() : null;
const polygonTx = h => txLink(h);
return { init, report, week, recipientFor, tick, plan, pay, payDue, resolve, dueWeeks, weekStatus, payerStatus, liveState, overrideTxs, txInfo, claim, cfg, payerHandle, polygonTx };
} }
const main = create(); const main = create();
+7 -1
View File
@@ -172,6 +172,12 @@ async function write(owner, id, body) {
return { ok: true, page: pub(p), by }; return { ok: true, page: pub(p), by };
} }
function totals() { return { pages: J.db.pages.length, published: J.db.pages.filter(p => p.status === 'published').length, leads: J.db.leads.length }; } function totals() { return { pages: J.db.pages.length, published: J.db.pages.filter(p => p.status === 'published').length, leads: J.db.leads.length }; }
// site-wide figures for the daily snapshot: page views, leads and new pages inside the `since` window
function window24(since) {
const views = J.db.views.filter(v => v.ts >= since && (v.k || 'view') === 'view');
return { pages: J.db.pages.length, published: J.db.pages.filter(p => p.status === 'published').length, created: J.db.pages.filter(p => (p.created || 0) >= since).length,
views: views.length, unique: new Set(views.map(v => v.v)).size, leads: J.db.leads.filter(l => l.ts >= since).length };
}
// -- Reports (2026-10-10): the member's page views, uniques, clicks-through and leads for the last N days, by Central day and by page // -- Reports (2026-10-10): the member's page views, uniques, clicks-through and leads for the last N days, by Central day and by page
const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
async function summary(owner, days) { async function summary(owner, days) {
@@ -263,4 +269,4 @@ function adminAll() {
formProvider: p.type === 'squeeze' && c.formEmbed ? formrestyle.provider(c.formEmbed) : null, views: o.views, uniques: o.u.size, clicks: o.clicks, leads: ld[p.id] || 0 }; }); formProvider: p.type === 'squeeze' && c.formEmbed ? formrestyle.provider(c.formEmbed) : null, views: o.views, uniques: o.u.size, clicks: o.clicks, leads: ld[p.id] || 0 }; });
} }
function adminImages() { return J.db.images.map(i => Object.assign(pubImage(i), { owner: i.owner })); } function adminImages() { return J.db.images.map(i => Object.assign(pubImage(i), { owner: i.owner })); }
module.exports = { init, TYPES, list, get, bySlug, create, update, html, view, lead, leads, csv, scan, write, totals, summary, readUpload, uploadImage, images, removeImage, imageFile, IMG_MAX, IMG_BYTES, providers: () => formrestyle.PROVIDERS, provider: formrestyle.provider, adminAll, adminImages }; module.exports = { init, TYPES, list, get, bySlug, create, update, html, view, lead, leads, csv, scan, write, totals, window24, summary, readUpload, uploadImage, images, removeImage, imageFile, IMG_MAX, IMG_BYTES, providers: () => formrestyle.PROVIDERS, provider: formrestyle.provider, adminAll, adminImages };
+6 -5
View File
@@ -17,7 +17,7 @@ const J = { db: null, FILE: () => path.join(DATA_DIR, 'postbacks.json'),
save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db)); } catch (e) {} } }; save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db)); } catch (e) {} } };
function init(opts) { DATA_DIR = opts.dataDir; ownHosts = opts.ownHosts || (() => []); rotator = opts.rotator; SOURCES = opts.sources || null; J.load(); } function init(opts) { DATA_DIR = opts.dataDir; ownHosts = opts.ownHosts || (() => []); rotator = opts.rotator; SOURCES = opts.sources || null; J.load(); }
const norm = e => String(e || '').trim().toLowerCase(); const norm = e => String(e || '').trim().toLowerCase();
const EVENTS = ['join', 'lead', 'wallet', 'purchase', 'external']; const EVENTS = ['join', 'lead', 'wallet', 'purchase', 'external', 'goal']; // 'goal' = any conversion-pixel goal (2026-10-23); {event} carries the goal's name
const MACRO = /\{([a-z0-9_]{1,24})\}/gi; const MACRO = /\{([a-z0-9_]{1,24})\}/gi;
function isPrivateIp(ip) { function isPrivateIp(ip) {
@@ -102,7 +102,8 @@ async function fire(owner, event, ctx) {
const q = (ctx.q || {}); const q = (ctx.q || {});
const vals = { clickid: q.clickid || q.cid || q.click_id || q.external_id || q.visitor_id || '', subid: q.subid || q.sub_id || q.s1 || '', s1: q.s1 || q.sub1 || '', s2: q.s2 || q.sub2 || '', s3: q.s3 || q.sub3 || '', s4: q.s4 || q.sub4 || '', s5: q.s5 || q.sub5 || '', source: ctx.source || '', event, payout: ctx.payout != null ? ctx.payout : '', currency: ctx.currency || 'USD', txid: ctx.txid || '', lsid: ctx.lsid || '', code: ctx.code || '', country: ctx.country || '', device: ctx.device || '' }; const vals = { clickid: q.clickid || q.cid || q.click_id || q.external_id || q.visitor_id || '', subid: q.subid || q.sub_id || q.s1 || '', s1: q.s1 || q.sub1 || '', s2: q.s2 || q.sub2 || '', s3: q.s3 || q.sub3 || '', s4: q.s4 || q.sub4 || '', s5: q.s5 || q.sub5 || '', source: ctx.source || '', event, payout: ctx.payout != null ? ctx.payout : '', currency: ctx.currency || 'USD', txid: ctx.txid || '', lsid: ctx.lsid || '', code: ctx.code || '', country: ctx.country || '', device: ctx.device || '' };
for (const [k, v] of Object.entries(q)) if (/^(utm_[a-z]+|sub\d|s\d|aff_sub\d?|t\d|cost|zone|placement|site|campaign|creative|banner|keyword|geo|os|browser|carrier|format)$/.test(k) && vals[k] == null) vals[k] = v; for (const [k, v] of Object.entries(q)) if (/^(utm_[a-z]+|sub\d|s\d|aff_sub\d?|t\d|cost|zone|placement|site|campaign|creative|banner|keyword|geo|os|browser|carrier|format)$/.test(k) && vals[k] == null) vals[k] = v;
for (const p of J.db.items.filter(x => x.owner === o && x.enabled && x.events.includes(event))) { const listens = evs => (evs || []).includes(event) || (!!ctx.goal && (evs || []).includes('goal'));
for (const p of J.db.items.filter(x => x.owner === o && x.enabled && listens(x.events))) {
if (!rateOk(o)) break; if (!rateOk(o)) break;
const url = fill(p.url, vals); const url = fill(p.url, vals);
let r = await deliver(p, url, Object.assign({}, ctx, { event })); let r = await deliver(p, url, Object.assign({}, ctx, { event }));
@@ -112,7 +113,7 @@ async function fire(owner, event, ctx) {
// the traffic source that sent this click (and only that one) hears about it through its own postback // the traffic source that sent this click (and only that one) hears about it through its own postback
if (ctx.sourceId && SOURCES) { if (ctx.sourceId && SOURCES) {
const s = SOURCES.forFire(o, ctx.sourceId); const s = SOURCES.forFire(o, ctx.sourceId);
if (s && (s.events || []).includes(event) && rateOk(o)) { if (s && listens(s.events) && rateOk(o)) {
const url = fill(s.postbackUrl, vals); const url = fill(s.postbackUrl, vals);
let r = await deliver(s, url, Object.assign({}, ctx, { event, viaSource: s.id })); let r = await deliver(s, url, Object.assign({}, ctx, { event, viaSource: s.id }));
if (!r.ok && !ctx.test) { await new Promise(res => setTimeout(res, 4000)); r = await deliver(s, url, Object.assign({}, ctx, { event, viaSource: s.id })); } if (!r.ok && !ctx.test) { await new Promise(res => setTimeout(res, 4000)); r = await deliver(s, url, Object.assign({}, ctx, { event, viaSource: s.id })); }
@@ -132,7 +133,7 @@ async function test(owner, id) {
// a conversion happened for an account: find the click that brought them, record it on the rotator, fire the owner's postbacks // a conversion happened for an account: find the click that brought them, record it on the rotator, fire the owner's postbacks
async function convertFor(email, event, facts) { async function convertFor(email, event, facts) {
const c = clickOf(email); if (!c) return null; const c = clickOf(email); if (!c) return null;
const hit = rotator && rotator.convert ? await rotator.convert(c.lsid, event, facts || {}) : null; const hit = rotator && rotator.convert ? await rotator.convert(c.lsid, event, Object.assign({}, facts || {}, { email: norm(email) })) : null;
if (!hit) return null; if (!hit) return null;
const ctx = Object.assign({ q: hit.q || {}, source: hit.s, country: hit.c, device: hit.dv, lsid: c.lsid, code: hit.code, sourceId: hit.sourceId || '' }, facts || {}); const ctx = Object.assign({ q: hit.q || {}, source: hit.s, country: hit.c, device: hit.dv, lsid: c.lsid, code: hit.code, sourceId: hit.sourceId || '' }, facts || {});
try { await fire(hit.owner, event, ctx); } catch (e) {} try { await fire(hit.owner, event, ctx); } catch (e) {}
@@ -152,4 +153,4 @@ async function inbound(key, body) {
} }
// admin Member content (2026-10-18): every postback of every owner // admin Member content (2026-10-18): every postback of every owner
function adminAll() { return J.db.items.map(p => Object.assign(pubItem(p), { owner: p.owner })); } function adminAll() { return J.db.items.map(p => Object.assign(pubItem(p), { owner: p.owner })); }
module.exports = { init, adminAll, EVENTS, validateUrl, fill, deliver, list, create, update, logFor, logForSource, partnerKey, rotateKey, bindClick, clickOf, fire, test, convertFor, inbound }; module.exports = { /* member erase (erase.js, 2026-11-15): the live copy */ _json: { state: () => { if (!J.db) J.load(); return J.db; }, save: () => J.save() }, init, adminAll, EVENTS, validateUrl, fill, deliver, list, create, update, logFor, logForSource, partnerKey, rotateKey, bindClick, clickOf, fire, test, convertFor, inbound };
+108
View File
@@ -0,0 +1,108 @@
// Prohibited-content policy, one module shared by InstantAdPay and LinkSpin (keep the two copies identical).
// 2026-10-30: an SEO backlink farm opened 106 free accounts, each with a casino or local-business bio and a
// website link, and Google indexed that text under our domains through the public walls. Rules (Marty):
// - profile fields are not a free backlink: a bio may not carry a URL or a domain-looking token;
// - gambling, adult, pharma, weapons and link-selling terms are refused in every member-set text field
// (bio, social links, line banner, wall offers, campaign names, headlines, copy and target URLs);
// - case-insensitive and Unicode aware (NFC, lower-cased, letter/number boundaries, so "Essex" never hits "sex").
// Pure functions, no state, no dependencies.
'use strict';
// One entry per term or phrase; spaces match any run of whitespace. Grouped for the Terms page and the admin.
const LIST = {
gambling: ['casino', 'casinos', 'cassino', 'cassinos', 'slots', 'slot gacor', 'betting', 'sportsbook', 'sportsbooks', 'bookmaker', 'bookmakers', 'bookie',
'lottery', 'lotteries', 'lotto', 'poker', 'baccarat', 'roulette', 'blackjack', 'jackpot', 'togel', 'judi', 'judi online', 'apostas', 'apuestas',
'nổ hũ', 'cá cược', 'đổi thưởng', 'xổ số', 'kèo', 'nhà cái', 'soi kèo', 'game bài', 'tài xỉu', 'bắn cá'],
adult: ['porn', 'porno', 'pornography', 'sex', 'sexy', 'escort', 'escorts', 'erotic', 'erotica', 'xxx', 'onlyfans', 'nude', 'nudes', 'hentai', 'cam girl', 'cam girls', 'sex cam', 'hookup', 'hookups'],
pharma: ['viagra', 'cialis', 'levitra', 'pharmacy', 'pharmacies', 'prescription', 'prescriptions', 'steroids', 'anabolic', 'cannabis', 'marijuana', 'weed', 'cbd', 'kratom', 'opioid', 'opioids',
'xanax', 'adderall', 'tramadol', 'oxycodone', 'ketamine', 'cocaine', 'mdma', 'psilocybin', 'vape', 'vaping'],
weapons: ['firearm', 'firearms', 'guns', 'gun shop', 'gun store', 'ammunition', 'ammo', 'rifle', 'rifles', 'pistol', 'pistols', 'handgun', 'handguns', 'silencer', 'suppressor', 'explosives'],
linkfarm: ['backlink', 'backlinks', 'seo service', 'seo services', 'seo agency', 'link building', 'link-building', 'guest post', 'guest posts', 'guest posting', 'pbn', 'buy links', 'sell links', 'dofollow']
};
const ALL = Object.values(LIST).reduce((a, b) => a.concat(b), []);
const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const ZW = /[​-‏⁠]/g; // zero-width joiners hide nothing
const strip = s => String(s == null ? '' : s).normalize('NFC').replace(ZW, '');
const norm = s => strip(s).toLowerCase();
// Boundary = anything that is not a letter or a number (works for every script, unlike \b).
const TERM_RE = new RegExp('(?<![\\p{L}\\p{N}])(?:' + ALL.map(t => esc(norm(t)).replace(/\s+/g, '\\s+')).join('|') + ')(?![\\p{L}\\p{N}])', 'u');
// Common gTLDs plus the ccTLDs link farms actually use. A short two-letter list keeps "Mr.Li" style text out of it.
const TLDS = 'com|net|org|info|biz|io|co|app|xyz|me|tv|us|uk|vn|de|fr|ru|in|id|br|es|it|nl|ca|au|eu|ch|at|be|pt|pl|cz|se|no|fi|dk|ie|nz|za|ng|ke|eg|tr|ua|il|ae|sa|pk|bd|lk|np|kh|la|mm|my|sg|ph|th|jp|kr|cn|tw|hk|mx|ar|cl|pe|to|ly|cc|gg|ai|pw|ws|tk|ml|ga|cf|gq|su|'
+ 'site|online|store|shop|club|top|pro|live|link|page|dev|fun|vip|one|tech|space|website|cloud|digital|agency|company|email|news|blog|life|world|today|zone|guru|ninja|game|games|team|network|money|cash|gold|bid|trade|win|bet|casino|poker|mobi|name|tel|travel|jobs|pics|photo|video|press|media|art|design|studio|capital|finance|exchange|solutions|services|systems|tools|works|center|group|global|international|institute|academy|school|education|university|church|community|social|chat|dating|love|wiki|review|reviews|directory|guide|help|support|rocks|ventures|holdings|partners|limited|ltd|llc|inc|asia|africa|london|nyc|tokyo|berlin|paris|best|buzz|click|host|hosting|lol|monster|wtf|ooo|icu|sbs|cfd|cyou|rest|bar|cam|surf|run|fit|health|care|dog|cat|pet|pets|wine|beer|vodka|bio|eco|green|energy|solar|car|cars|auto|bike|tires|taxi|limo|rent|rentals|house|homes|realty|estate|land|city|town|place|map|earth|fund|loans|credit|insure|legal|law|lawyer|attorney|tax|accountant|consulting|marketing|promo|sale|deals|discount|coupons|gift|gifts|toys|baby|kids|mom|family|wedding|party|events|tickets|show|theater|film|movie|music|band|dance|yoga|golf|football|soccer|hockey|tennis|racing';
// Schemes and www. are matched in any case; a bare domain token (or an email address) only with its TLD in lower case, so a
// missed space after a period ("ads.One day") is not mistaken for a link while real spam domains (typed lower case) are caught.
const SCHEME_RE = /(?:https?:\/\/|ftp:\/\/|(?<![\p{L}\p{N}])www\.)/iu;
const DOMAIN_RE = new RegExp('(?<![\\p{L}\\p{N}])[\\p{L}\\p{N}-]{1,63}(?:\\.[\\p{L}\\p{N}-]{1,63})*\\.(?:' + TLDS + ')(?![\\p{L}\\p{N}])', 'u');
// The matching prohibited term, or null.
function match(text) { const m = TERM_RE.exec(norm(text)); return m ? m[0].replace(/\s+/g, ' ') : null; }
// True when the text carries a URL or a domain-looking token (http(s)://, www., word.tld).
function hasUrl(text) { const t = strip(text); return SCHEME_RE.test(t) || DOMAIN_RE.test(t); }
const BIO_LINK_MSG = 'Links go in the social fields, not the bio.';
const blockedMsg = site => 'That content is not allowed on ' + (site || 'InstantAdPay/LinkSpin') + ' profiles (see Terms).';
const blockedAdMsg = site => 'That content is not allowed on ' + (site || 'InstantAdPay/LinkSpin') + ' (see Terms, Prohibited content).';
// Bio rule: no links, no prohibited terms. Returns { ok: true } or { error, reason }.
function checkBio(bio, site) {
const t = String(bio || '');
if (!t.trim()) return { ok: true };
if (hasUrl(t)) return { error: BIO_LINK_MSG, reason: 'url' };
const term = match(t);
if (term) return { error: blockedMsg(site), reason: 'term:' + term };
return { ok: true };
}
// Any other member-set text (social URL, banner target, campaign name, headline, copy): prohibited terms only.
// Pass profile: true for profile fields (the message names profiles), else the ad message is used.
function checkText(text, site, opts) {
const term = match(text);
if (!term) return { ok: true };
return { error: (opts && opts.profile) ? blockedMsg(site) : blockedAdMsg(site), reason: 'term:' + term };
}
// Several fields at once: { name: value, ... } -> first failure, with the field named in `field`.
function checkFields(fields, site, opts) {
for (const k of Object.keys(fields || {})) {
const v = fields[k]; if (v == null || v === '') continue;
const r = checkText(Array.isArray(v) ? v.join(' ') : String(v), site, opts);
if (r.error) return Object.assign({ field: k }, r);
}
return { ok: true };
}
// Profile ingest (registry sync from the other property, or a saved profile replayed): the parts of a profile that may be
// stored. A bio with a link or a prohibited term is dropped (null); a social URL carrying a prohibited term is dropped.
function cleanProfile(pf, site) {
const out = { avatarUrl: null, bio: null, socials: null, dropped: [] };
if (!pf || typeof pf !== 'object') return out;
const av = String(pf.avatarUrl || '').trim(); if (/^https:\/\/[^\s]+$/i.test(av) && av.length <= 300) out.avatarUrl = av;
const bio = String(pf.bio || '').trim().slice(0, 600);
if (bio) { const r = checkBio(bio, site); if (r.ok) out.bio = bio; else out.dropped.push('bio:' + r.reason); }
const src = pf.socials && typeof pf.socials === 'object' ? pf.socials : (typeof pf.socials === 'string' ? safeJson(pf.socials) : null);
if (src) {
const c = {};
for (const k of Object.keys(src)) {
const v = String(src[k] || '').trim(); if (!v) continue;
const r = checkText(v, site, { profile: true }); if (r.ok) c[k] = v; else out.dropped.push('socials.' + k + ':' + r.reason);
}
if (Object.keys(c).length) out.socials = c;
}
return out;
}
function safeJson(s) { try { const o = JSON.parse(s); return o && typeof o === 'object' ? o : null; } catch (e) { return null; } }
// Terms-page wording, one line per group (kept here so both sites say the same thing).
const POLICY = [
'gambling, casinos, betting, lotteries and sweepstakes',
'adult or sexual content',
'drugs and prescription pharmaceuticals',
'weapons',
'hate or harassment',
'malware, phishing and counterfeit goods',
'misleading financial promises',
'accounts created to place links in profile fields (link farming), which are removed without notice together with their profile text'
];
// One log line per refusal, with the email masked (never the text itself at full length).
function logRefusal(where, email, r) {
try { console.log('prohibited-content refused', where, String(email || '-').replace(/^(.).*(@.*)$/, '$1***$2'), r && r.field ? 'field=' + r.field : '', r && r.reason ? r.reason : ''); } catch (e) {}
}
module.exports = { LIST, ALL, POLICY, match, hasUrl, checkBio, checkText, checkFields, cleanProfile, logRefusal, BIO_LINK_MSG, blockedMsg, blockedAdMsg };
+11 -6
View File
@@ -4,10 +4,14 @@
// the dashboard. One redemption per code per account; every redemption is logged; optional // the dashboard. One redemption per code per account; every redemption is logged; optional
// cap (max uses) and expiry; codes can be switched off. Storage: MySQL promo_codes + // cap (max uses) and expiry; codes can be switched off. Storage: MySQL promo_codes +
// promo_redemptions, or DATA_DIR/promos.json. // promo_redemptions, or DATA_DIR/promos.json.
// starts (2026-11-17, Network Weekend WEEKEND500): a code can be created dormant and open by itself at an exact time (ms; 0 = open
// now). Before it opens it answers 'not open yet'. Test clock: setClock(fn) in tests only.
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const db = require('./db'); const db = require('./db');
let DATA_DIR = null; let DATA_DIR = null;
let clock = () => Date.now();
function setClock(fn) { clock = typeof fn === 'function' ? fn : () => Date.now(); }
const norm = c => String(c || '').trim().toUpperCase().replace(/[^A-Z0-9_-]/g, '').slice(0, 24); const norm = c => String(c || '').trim().toUpperCase().replace(/[^A-Z0-9_-]/g, '').slice(0, 24);
const J = { const J = {
@@ -27,8 +31,8 @@ const D = {
async get(code) { const r = await db.q('SELECT * FROM promo_codes WHERE code=?', [code]); return r[0] ? row(r[0]) : null; }, async get(code) { const r = await db.q('SELECT * FROM promo_codes WHERE code=?', [code]); return r[0] ? row(r[0]) : null; },
async list() { return (await db.q('SELECT * FROM promo_codes ORDER BY created DESC')).map(row); }, async list() { return (await db.q('SELECT * FROM promo_codes ORDER BY created DESC')).map(row); },
async put(c) { async put(c) {
await db.q('INSERT INTO promo_codes (code,credits,partner,note,max_uses,expires,active,created,funder) VALUES (?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE funder=VALUES(funder), credits=VALUES(credits), partner=VALUES(partner), note=VALUES(note), max_uses=VALUES(max_uses), expires=VALUES(expires), active=VALUES(active)', await db.q('INSERT INTO promo_codes (code,credits,partner,note,max_uses,expires,active,created,funder,starts) VALUES (?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE funder=VALUES(funder), credits=VALUES(credits), partner=VALUES(partner), note=VALUES(note), max_uses=VALUES(max_uses), expires=VALUES(expires), active=VALUES(active), starts=VALUES(starts)',
[c.code, c.credits, c.partner || null, c.note || null, c.maxUses || 0, c.expires || 0, c.active ? 1 : 0, c.created || Date.now(), c.funder || null]); [c.code, c.credits, c.partner || null, c.note || null, c.maxUses || 0, c.expires || 0, c.active ? 1 : 0, c.created || Date.now(), c.funder || null, c.starts || 0]);
return this.get(c.code); return this.get(c.code);
}, },
async uses(code) { const r = await db.q('SELECT COUNT(*) n FROM promo_redemptions WHERE code=?', [code]); return Number(r[0].n); }, async uses(code) { const r = await db.q('SELECT COUNT(*) n FROM promo_redemptions WHERE code=?', [code]); return Number(r[0].n); },
@@ -36,7 +40,7 @@ const D = {
async addRedemption(r) { await db.q('INSERT IGNORE INTO promo_redemptions (code,email,credits,via,ts) VALUES (?,?,?,?,?)', [r.code, r.email, r.credits, r.via, r.ts]); }, async addRedemption(r) { await db.q('INSERT IGNORE INTO promo_redemptions (code,email,credits,via,ts) VALUES (?,?,?,?,?)', [r.code, r.email, r.credits, r.via, r.ts]); },
async redemptions(code, n) { const rows = code ? await db.q('SELECT * FROM promo_redemptions WHERE code=? ORDER BY ts DESC LIMIT ?', [code, Number(n) || 200]) : await db.q('SELECT * FROM promo_redemptions ORDER BY ts DESC LIMIT ?', [Number(n) || 200]); return rows.map(r => ({ code: r.code, email: r.email, credits: Number(r.credits), via: r.via, ts: Number(r.ts) })); } async redemptions(code, n) { const rows = code ? await db.q('SELECT * FROM promo_redemptions WHERE code=? ORDER BY ts DESC LIMIT ?', [code, Number(n) || 200]) : await db.q('SELECT * FROM promo_redemptions ORDER BY ts DESC LIMIT ?', [Number(n) || 200]); return rows.map(r => ({ code: r.code, email: r.email, credits: Number(r.credits), via: r.via, ts: Number(r.ts) })); }
}; };
const row = r => ({ code: r.code, funder: r.funder || null, credits: Number(r.credits), partner: r.partner || '', note: r.note || '', maxUses: Number(r.max_uses) || 0, expires: Number(r.expires) || 0, active: !!Number(r.active), created: Number(r.created) }); const row = r => ({ code: r.code, funder: r.funder || null, credits: Number(r.credits), partner: r.partner || '', note: r.note || '', maxUses: Number(r.max_uses) || 0, expires: Number(r.expires) || 0, starts: Number(r.starts) || 0, active: !!Number(r.active), created: Number(r.created) });
const impl = () => db.enabled() ? D : J; const impl = () => db.enabled() ? D : J;
function init(opts) { DATA_DIR = opts.dataDir; if (!db.enabled()) J.load(); } function init(opts) { DATA_DIR = opts.dataDir; if (!db.enabled()) J.load(); }
@@ -44,7 +48,7 @@ async function create(c) {
const code = norm(c.code); if (!code || code.length < 3) return { error: 'Code must be 3 to 24 letters or numbers.' }; const code = norm(c.code); if (!code || code.length < 3) return { error: 'Code must be 3 to 24 letters or numbers.' };
const credits = Math.floor(Number(c.credits)); if (!(credits > 0) || credits > 100000) return { error: 'Credits must be between 1 and 100,000.' }; const credits = Math.floor(Number(c.credits)); if (!(credits > 0) || credits > 100000) return { error: 'Credits must be between 1 and 100,000.' };
const cur = await impl().get(code); const cur = await impl().get(code);
const saved = await impl().put({ code, credits, funder: c.funder ? String(c.funder).toLowerCase() : (cur && cur.funder) || null, partner: String(c.partner || '').slice(0, 80), note: String(c.note || '').slice(0, 200), maxUses: Math.max(0, Math.floor(Number(c.maxUses) || 0)), expires: c.expires ? Number(new Date(c.expires)) || 0 : 0, active: c.active !== false && c.active !== 0 && c.active !== '0', created: cur ? cur.created : Date.now() }); const saved = await impl().put({ code, credits, funder: c.funder ? String(c.funder).toLowerCase() : (cur && cur.funder) || null, partner: String(c.partner || '').slice(0, 80), note: String(c.note || '').slice(0, 200), maxUses: Math.max(0, Math.floor(Number(c.maxUses) || 0)), expires: c.expires ? Number(new Date(c.expires)) || 0 : 0, starts: c.starts !== undefined ? (c.starts ? Number(new Date(c.starts)) || 0 : 0) : (cur && cur.starts) || 0, active: c.active !== false && c.active !== 0 && c.active !== '0', created: cur ? cur.created : Date.now() });
return { ok: true, code: saved }; return { ok: true, code: saved };
} }
async function setActive(code, active) { const c = await impl().get(norm(code)); if (!c) return { error: 'No such code.' }; await impl().put(Object.assign(c, { active: !!active })); return { ok: true }; } async function setActive(code, active) { const c = await impl().get(norm(code)); if (!c) return { error: 'No such code.' }; await impl().put(Object.assign(c, { active: !!active })); return { ok: true }; }
@@ -52,7 +56,8 @@ async function setActive(code, active) { const c = await impl().get(norm(code));
async function check(code, email) { async function check(code, email) {
const k = norm(code); if (!k) return { error: 'Enter a promo code.' }; const k = norm(code); if (!k) return { error: 'Enter a promo code.' };
const c = await impl().get(k); if (!c || !c.active) return { error: 'That promo code is not valid.' }; const c = await impl().get(k); if (!c || !c.active) return { error: 'That promo code is not valid.' };
if (c.expires && Date.now() > c.expires) return { error: 'That promo code has expired.' }; if (c.starts && clock() < c.starts) return { error: 'That promo code is not open yet.' };
if (c.expires && clock() > c.expires) return { error: 'That promo code has expired.' };
if (email && await impl().redeemed(k, email)) return { error: 'You already used that promo code.' }; if (email && await impl().redeemed(k, email)) return { error: 'You already used that promo code.' };
if (c.maxUses && (await impl().uses(k)) >= c.maxUses) return { error: 'That promo code has been fully redeemed.' }; if (c.maxUses && (await impl().uses(k)) >= c.maxUses) return { error: 'That promo code has been fully redeemed.' };
return null; return null;
@@ -71,4 +76,4 @@ async function adminView() {
return { codes, recent: await impl().redemptions(null, 100) }; return { codes, recent: await impl().redemptions(null, 100) };
} }
async function byFunder(email) { return (await impl().list()).filter(c => c.funder === String(email || '').toLowerCase()); } async function byFunder(email) { return (await impl().list()).filter(c => c.funder === String(email || '').toLowerCase()); }
module.exports = { init, create, setActive, check, redeem, adminView, norm, byFunder }; module.exports = { setClock, init, create, setActive, check, redeem, adminView, norm, byFunder };
+38 -7
View File
@@ -1,15 +1,16 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="light">
<head> <head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex,nofollow"> <meta name="robots" content="noindex,nofollow">
<title>Admin | LinkSpin</title> <title>Admin | LinkSpin</title>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png"> <link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/cr.css?v=20261020s"> <link rel="stylesheet" href="/assets/cr.css?v=20261114tu">
<style>@import url("/assets/site.css?v=ls20260916a") layer(legacy);</style> <style>@import url("/assets/site.css?v=ls20261118rd") layer(legacy);</style>
<link rel="stylesheet" href="/assets/tools.css?v=20261018pc2"> <link rel="stylesheet" href="/assets/tools.css?v=20261101t">
<link rel="stylesheet" href="/assets/admin.css?v=20261018a"> <link rel="stylesheet" href="/assets/admin.css?v=20261101t">
</head> </head>
<body> <body>
<div id="page"> <div id="page">
@@ -90,6 +91,11 @@
<div id="ovChain" class="small">…</div> <div id="ovChain" class="small">…</div>
</div> </div>
</div> </div>
<div class="card">
<div class="card-head"><h3>Refill notices</h3><span class="sub" id="rfSub">low, out and idle ads: one message per owner</span></div>
<div id="rfBox" class="small muted">&hellip;</div>
<p style="margin:10px 0 0"><button class="btn small sec" id="rfRun" type="button">Send the next batch now</button></p>
</div>
<div class="card"> <div class="card">
<div class="card-head"><h3>Quick actions</h3></div> <div class="card-head"><h3>Quick actions</h3></div>
<p style="display:flex;gap:10px;flex-wrap:wrap;margin:0"> <p style="display:flex;gap:10px;flex-wrap:wrap;margin:0">
@@ -228,6 +234,12 @@
<p class="small muted">Sponsor = the token the account joined under (username, share code, or member #). Editing it re-points free referrals and future purchases. On-chain sponsorship is permanent once activated.</p> <p class="small muted">Sponsor = the token the account joined under (username, share code, or member #). Editing it re-points free referrals and future purchases. On-chain sponsorship is permanent once activated.</p>
<div class="tablewrap"><table class="adm-table" id="memTable"></table></div> <div class="tablewrap"><table class="adm-table" id="memTable"></table></div>
</div> </div>
<div class="card" id="spamCard">
<div class="card-head"><h3>Link-farm list</h3><span class="sub" id="spamSub">daily scan at 06:30 Central</span></div>
<p class="small muted">Free accounts (no package, no wallet) that carry a link plus a farm signal: a prohibited term in the profile, a sign-in that ended within 15 minutes of the sign-up, or no sponsor. Nothing is deleted on its own. Delete uses the normal member delete (on-chain members are refused) and never touches InstantAdPay; the "also on InstantAdPay" column is there so you can decide. Allow keeps an email off this list for good.</p>
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:0 0 10px"><button class="btn small" id="spamRun" type="button">Scan now</button><button class="btn small sec" id="spamDelete" type="button">Delete selected</button><span class="small muted" id="spamAllow"></span></p>
<div class="tablewrap"><table class="adm-table" id="spamTable"></table></div>
</div>
</div> </div>
<div class="pane" id="pane-content" hidden> <div class="pane" id="pane-content" hidden>
@@ -473,8 +485,27 @@
<p><select id="ovWeek"></select> <button class="btn small sec" type="button" id="ovShow">Show week</button> <button class="btn small" type="button" id="ovPay" hidden>Pay this week now</button></p> <p><select id="ovWeek"></select> <button class="btn small sec" type="button" id="ovShow">Show week</button> <button class="btn small" type="button" id="ovPay" hidden>Pay this week now</button></p>
<div id="ovOut" class="small"></div> <div id="ovOut" class="small"></div>
</div> </div>
<div class="card" id="lwCard">
<div class="card-head"><h3>Launch week</h3><span class="sub">Founder badge (cosmetic) and the launch week contest (POL prizes, paid only from this button)</span></div>
<p class="small" id="lwFounder">…</p>
<p class="small" id="lwWindow"></p>
<div id="lwStand" class="small"></div>
<div id="lwPayouts" class="small"></div>
<p><button class="btn small sec" type="button" id="lwRefresh">Refresh</button> <button class="btn small sec" type="button" id="lwGrant" hidden>Grant Founder badges now</button> <button class="btn small" type="button" id="lwPay" hidden>Pay launch contest</button></p>
</div>
</div> </div>
<div class="pane" id="pane-settings" hidden> <div class="pane" id="pane-settings" hidden>
<div class="card" id="kitCard">
<div class="card-head"><h3>Refuel Kit</h3><span class="sub" id="kitSub">monthly members-only banners: unlocked by a counted refuel (needs refuelStreak on)</span></div>
<p class="small muted">Five base images per month for this site's own program: 728x90, 300x250, 468x60, 160x600, 1200x630. Each member's @name and a QR to their own link are drawn on top: keep the right end clear on 728x90 and 468x60 (QR) with room for the name left of it, the bottom-right corner on 300x250 and 1200x630, and the bottom 170 px on 160x600. No income claims in any banner. Release on the 1st; a member unlocks the month's kit with their next counted refuel.</p>
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center"><input id="kitMonth" placeholder="YYYY-MM" style="max-width:110px"><input id="kitTheme" placeholder="Theme (e.g. Harvest)" style="max-width:240px">
<button class="btn small" id="kitSave" type="button">Save kit</button><button class="btn small sec" id="kitPlaceholder" type="button">Use placeholder art (public/banners)</button></p>
<div id="kitSizes"></div>
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:10px">Preview <select id="kitPrevSize"></select><input id="kitPrevName" placeholder="username" style="max-width:160px"><label class="small"><input type="checkbox" id="kitPrevGif" style="width:auto"> animated</label><button class="btn small sec" id="kitPreview" type="button">Preview</button></p>
<div id="kitPrevBox"></div>
<div id="kitList" class="small"></div>
<div id="kitBox"></div>
</div>
<div class="card"> <div class="card">
<div class="card-head"><h3>Follow-up emails</h3><span class="sub" id="dripSub">sent to every new free member, hours after sign-up</span></div> <div class="card-head"><h3>Follow-up emails</h3><span class="sub" id="dripSub">sent to every new free member, hours after sign-up</span></div>
<p class="small muted">One card per email. Placeholders fill in per reader: click a chip to drop it where your cursor is. <p class="small muted">One card per email. Placeholders fill in per reader: click a chip to drop it where your cursor is.
@@ -517,8 +548,8 @@
</div> </div>
</div> </div>
<script src="/assets/common.js?v=20261023ov"></script> <script src="/assets/common.js?v=20261117nw"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script> <script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261023ov"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script> <script src="/assets/tankready.js?v=20261118rd"></script><script src="/assets/admin.js?v=20261118rd"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script><script src="/assets/admin-launchweek.js?v=20261105lw"></script>
</body> </body>
</html> </html>
+11 -4
View File
@@ -1,12 +1,13 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="light">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
<title>Ads · LinkSpin</title> <title>Ads · LinkSpin</title>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20261020s"> <link rel="stylesheet" href="/assets/cr.css?v=20261114tu">
<style> <style>
/* layout by the space the screen really has (rail expanded or collapsed), not the viewport: the campaign table squeezed /* layout by the space the screen really has (rail expanded or collapsed), not the viewport: the campaign table squeezed
its first column to a word, then a letter, per line once the rail and the side cards took the width (tester, 2026-10-18) */ its first column to a word, then a letter, per line once the rail and the side cards took the width (tester, 2026-10-18) */
@@ -33,6 +34,7 @@
<div id="page"> <div id="page">
<div class="body"> <div class="body">
<div class="tiles" id="tiles"></div> <div class="tiles" id="tiles"></div>
<div class="panel" id="erPanel" hidden style="padding:0;margin-bottom:16px"><div class="ph"><h3>Engine Room</h3><span class="meta">LinkSpin and InstantAdPay at a glance</span></div><div style="padding:12px 16px 14px" id="erRoot" data-host="erPanel" aria-live="polite"></div></div>
<div class="panel" id="composer" hidden> <div class="panel" id="composer" hidden>
<h2 id="cmpTitle">New ad</h2> <h2 id="cmpTitle">New ad</h2>
<div class="seg" id="typeChips"><button class="chip on" type="button" data-t="banner">Banner</button><button class="chip" type="button" data-t="text">Text ad</button><button class="chip" type="button" data-t="login">Login ad</button></div> <div class="seg" id="typeChips"><button class="chip on" type="button" data-t="banner">Banner</button><button class="chip" type="button" data-t="text">Text ad</button><button class="chip" type="button" data-t="login">Login ad</button></div>
@@ -58,12 +60,15 @@
<label class="lbl">Headline (60)<input class="field" id="fTitle" maxlength="60"></label> <label class="lbl">Headline (60)<input class="field" id="fTitle" maxlength="60"></label>
<label class="lbl">One line (140)<input class="field" id="fBody" maxlength="140"></label> <label class="lbl">One line (140)<input class="field" id="fBody" maxlength="140"></label>
</div> </div>
<div id="aiRow" hidden style="margin-top:10px"><button class="btn sm" type="button" id="aiWrite">Write my ad from my link</button> <span class="muted" style="font-size:12px">Put your link in Where the click goes first. We read that page and suggest 3 text ads using only what it says. Nothing launches until you tap Launch.</span><div id="aiList" hidden style="margin-top:8px"></div></div>
<div id="prev" style="margin-top:12px"></div> <div id="prev" style="margin-top:12px"></div>
<div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:14px;align-items:center"><button class="btn pri" type="button" id="fGo">Launch</button><button class="btn ghost" type="button" id="fCancel">Cancel</button><span class="led" id="fCost"></span></div> <div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:14px;align-items:center"><button class="btn pri" type="button" id="fGo">Launch</button><button class="btn ghost" type="button" id="fCancel">Cancel</button><span class="led" id="fCost"></span></div>
</div> </div>
<div class="two"> <div class="two">
<div class="tbl cl"><div class="hd"><span>Campaign</span><span>Creative</span><span>Budget</span><span class="r">Views</span><span class="r">Clicks</span><span>Status</span><span></span></div><div id="rows"></div><div class="ft" id="foot"></div></div> <div class="tbl cl"><div class="hd"><span>Campaign</span><span>Creative</span><span>Budget</span><span class="r">Views</span><span class="r">Clicks</span><span>Status</span><span></span></div><div id="rows"></div><div class="ft" id="foot"></div></div>
<div class="side"> <div class="side">
<div class="panel" id="rfPanel" hidden style="padding:0" aria-live="polite"><div class="ph"><h3>Monthly Refuel</h3><span class="meta" id="rfMeta"></span></div><div style="padding:12px 16px 14px;font-size:13px" class="ink2" id="rfBody"></div></div>
<div class="panel" id="rkPanel" hidden style="padding:0" aria-live="polite"><div class="ph"><h3>Refuel Kit</h3><span class="meta">members-only banners</span></div><div style="padding:12px 16px 14px;font-size:13px" class="ink2" id="rkBody"></div></div>
<div class="panel"><h2>Earn credits</h2><div class="gauge" id="earnGauge"><i></i><i></i><i></i><i></i><i></i></div><div class="muted" id="earnLine" style="margin-top:8px">loading</div><div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:12px"><button class="btn blue" type="button" id="earnNext">View an ad</button><button class="btn" type="button" id="earnClaim" hidden>Claim</button></div><div class="muted" id="earnNote" style="margin-top:8px"></div></div> <div class="panel"><h2>Earn credits</h2><div class="gauge" id="earnGauge"><i></i><i></i><i></i><i></i><i></i></div><div class="muted" id="earnLine" style="margin-top:8px">loading</div><div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:12px"><button class="btn blue" type="button" id="earnNext">View an ad</button><button class="btn" type="button" id="earnClaim" hidden>Claim</button></div><div class="muted" id="earnNote" style="margin-top:8px"></div></div>
<div class="panel"><h2>Where your ads run</h2><div class="where ink2"><div><b>Banner</b><span>the ad viewer here, every member zone on outside sites, and the partner network</span></div><div><b>Text</b><span>the ad viewer and the partner network</span></div><div><b>Login</b><span id="loginWhere">full screen to every member right after they sign in, for a flat 30-day slot of purchased credits</span></div></div><div class="muted" id="rateLine" style="margin-top:10px"></div></div> <div class="panel"><h2>Where your ads run</h2><div class="where ink2"><div><b>Banner</b><span>the ad viewer here, every member zone on outside sites, and the partner network</span></div><div><b>Text</b><span>the ad viewer and the partner network</span></div><div><b>Login</b><span id="loginWhere">full screen to every member right after they sign in, for a flat 30-day slot of purchased credits</span></div></div><div class="muted" id="rateLine" style="margin-top:10px"></div></div>
<div class="panel" hidden><h2>Credit activity</h2><div id="creditLog" class="ink2" style="font-size:13px"></div></div> <div class="panel" hidden><h2>Credit activity</h2><div id="creditLog" class="ink2" style="font-size:13px"></div></div>
@@ -71,7 +76,9 @@
</div> </div>
</div> </div>
</div> </div>
<script src="/assets/cr-shell.js?v=20261023a"></script> <script src="/assets/cr-shell.js?v=20261115hub"></script>
<script src="/assets/ads-screen.js?v=20261023q"></script> <script src="/assets/ads-screen.js?v=20261117aiw"></script>
<script src="/assets/fuel.js?v=20261113sso"></script>
<script src="/assets/engine-room.js?v=20261113sso"></script>
</body> </body>
</html> </html>
+40
View File
@@ -0,0 +1,40 @@
// Admin > Settings > Refuel Kit (2026-10-24). The SAME file ships in InstantAdPay and LinkSpin. Upload one month's base art
// (five sizes, this site's own program), preview the personalization (@name + QR to the member's link), then release it.
// Keep the QR corner and the name strip clear in the art (see the layout note on the card).
(function () {
const $ = id => document.getElementById(id);
if (!$('kitBox')) return;
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const say = m => { $('kitSub').textContent = m; };
const api = async (url, opt) => { const r = await fetch(url, Object.assign({ cache: 'no-store' }, opt || {})); const j = await r.json().catch(() => ({})); if (!r.ok || j.error) throw new Error(j.error || ('HTTP ' + r.status)); return j; };
const post = (url, body) => api(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) });
const nextMonth = () => { const d = new Date(); const ct = new Date(d.toLocaleString('en-US', { timeZone: 'America/Chicago' })); ct.setDate(1); ct.setMonth(ct.getMonth() + 1); return ct.getFullYear() + '-' + String(ct.getMonth() + 1).padStart(2, '0'); };
let sizes = [];
async function load() {
try {
const d = await api('/api/admin/kits'); sizes = d.sizes;
if (!$('kitMonth').value) $('kitMonth').value = nextMonth();
$('kitList').innerHTML = d.kits.length ? d.kits.map(k => '<div style="border:1px solid var(--line,#ccd);border-radius:8px;padding:10px;margin:8px 0">'
+ '<b>' + esc(k.label) + '</b> ' + (k.theme ? '&middot; ' + esc(k.theme) + ' ' : '') + '<span class="small muted">(' + esc(k.month) + ')</span> '
+ (k.released ? '<span class="badge">released</span>' : '<span class="badge amber">draft</span>') + '<div class="small" style="margin:6px 0">'
+ k.sizes.map(s => s.size + ': ' + (s.ready ? 'ready' : '<b>missing</b>')).join(' &middot; ') + '</div>'
+ '<div style="display:flex;gap:6px;flex-wrap:wrap"><button class="btn small sec" type="button" data-kedit="' + esc(k.month) + '" data-theme="' + esc(k.theme) + '">Edit</button>'
+ '<button class="btn small' + (k.released ? ' sec' : '') + '" type="button" data-krel="' + esc(k.month) + '" data-on="' + (k.released ? '0' : '1') + '"' + (!k.complete && !k.released ? ' disabled title="upload all five sizes first"' : '') + '>' + (k.released ? 'Unrelease' : 'Release to members') + '</button></div></div>').join('') : '<p class="small muted">No kits yet.</p>';
$('kitList').querySelectorAll('[data-kedit]').forEach(b => b.addEventListener('click', () => { $('kitMonth').value = b.dataset.kedit; $('kitTheme').value = b.dataset.theme; say('editing ' + b.dataset.kedit); }));
$('kitList').querySelectorAll('[data-krel]').forEach(b => b.addEventListener('click', async () => { try { await post('/api/admin/kits', { month: b.dataset.krel, released: b.dataset.on === '1' }); load(); } catch (e) { say(e.message); } }));
$('kitSizes').innerHTML = sizes.map(s => '<label class="small" style="display:block;margin:4px 0">' + s + ' <input type="file" accept="image/png,image/jpeg,image/gif" data-ksize="' + s + '"></label>').join('');
$('kitSizes').querySelectorAll('[data-ksize]').forEach(inp => inp.addEventListener('change', async () => {
const f = inp.files && inp.files[0]; if (!f) return; const m = $('kitMonth').value.trim();
try { await api('/api/admin/kits/upload?month=' + encodeURIComponent(m) + '&size=' + inp.dataset.ksize, { method: 'POST', headers: { 'Content-Type': f.type }, body: f }); say(inp.dataset.ksize + ' uploaded for ' + m); load(); } catch (e) { say(e.message); }
}));
$('kitPrevSize').innerHTML = sizes.map(s => '<option>' + s + '</option>').join('');
} catch (e) { say('Could not load: ' + e.message); }
}
$('kitSave').addEventListener('click', async () => { try { await post('/api/admin/kits', { month: $('kitMonth').value.trim(), theme: $('kitTheme').value }); say('saved'); load(); } catch (e) { say(e.message); } });
$('kitPlaceholder').addEventListener('click', async () => { try { const r = await post('/api/admin/kits/placeholder', { month: $('kitMonth').value.trim() }); say('placeholder art: ' + r.sizes.join(', ')); load(); } catch (e) { say(e.message); } });
$('kitPreview').addEventListener('click', () => {
const q = 'month=' + encodeURIComponent($('kitMonth').value.trim()) + '&size=' + encodeURIComponent($('kitPrevSize').value) + '&username=' + encodeURIComponent($('kitPrevName').value || 'yourname') + ($('kitPrevGif').checked ? '&variant=gif' : '') + '&t=' + Date.now();
$('kitPrevBox').innerHTML = '<img alt="preview" style="max-width:100%;border:1px solid #ccd" src="/api/admin/kits/preview?' + q + '">';
});
load();
})();
+44
View File
@@ -0,0 +1,44 @@
// Admin > Launch week (2026-11-05): Founder badge preview + grant, launch contest standings and the "Pay launch contest" button.
// The pay button sends real POL from the Level 4 override payer wallet. It shows the frozen ranking and amounts first and
// sends exactly that list; the server refuses if anything changed, and every place is paid at most once.
(function () {
const $ = IAP.$;
if (!$('lwCard')) return;
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
async function api(path, body) {
const r = await (await fetch(path, body === undefined ? { cache: 'no-store' } : { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })).json();
if (r.error) throw new Error(r.error === 'auth' ? 'Session expired. Sign in again.' : r.error);
return r;
}
let last = null;
async function load() {
let r; try { r = await api('/api/admin/launch-week'); } catch (e) { $('lwFounder').textContent = 'Could not read launch week: ' + e.message; return; }
last = r;
const f = r.founder || {};
$('lwFounder').innerHTML = '<b>Founder badge</b> (cosmetic): accounts whose earliest signed-in visit (' + esc(f.field) + ') is before ' + esc(f.launchAtCT) + ' Central. '
+ '<b>' + (f.qualify || 0) + '</b> qualify today of ' + (f.accounts || 0) + ' accounts (' + (f.neverSignedIn || 0) + ' never signed in). Granted: ' + (f.granted || 0) + ', still to grant: ' + (f.missing || 0) + '. '
+ (f.launched ? 'Launch has passed; the automatic grant runs every 10 minutes' : 'The automatic grant starts at the launch moment') + (f.autoGrant ? '.' : ' (switched OFF: founderGrant = 0).');
$('lwGrant').hidden = !f.launched;
const w = r.window || {};
$('lwWindow').innerHTML = '<b>Launch week contest</b>: ' + esc(w.startCT) + ' to ' + esc(w.endCT) + ' Central · ' + (w.open ? (w.started ? 'OPEN' : 'not started') : 'CLOSED')
+ ' · minimum ' + r.minSales + ' sales to place · prizes ' + (r.prizes || []).map((p, i) => (i + 1) + ': ' + p + ' POL').join(', ')
+ ' · excluded: ' + esc((r.excluded.emails || []).join(', ')) + ' and member #' + esc((r.excluded.ids || []).join(', #'))
+ ' · payer ' + (r.payer.keyPresent ? esc(r.payer.address) + ' holds ' + esc(r.payer.balancePol || '?') + ' POL' : 'NOT configured');
$('lwStand').innerHTML = (r.standings || []).length ? '<table><tr><th>#</th><th>Member</th><th>Pays to</th><th>Sales</th><th>$</th><th>Places?</th></tr>' + r.standings.map(x => '<tr><td>' + x.rank + '</td><td>' + esc(x.name) + ' <span class="muted">' + esc(x.email) + '</span></td><td>#' + x.memberId + '</td><td>' + x.sales + '</td><td>$' + x.usd + '</td><td>' + (x.qualifies ? 'yes' : 'no') + '</td></tr>').join('') + '</table>' : '<p class="muted">No counted sales in the window yet.</p>';
$('lwPayouts').innerHTML = (r.payouts || []).length ? '<p><b>Payout records</b> (frozen ' + new Date(r.frozen.at).toLocaleString('en-US', { timeZone: 'America/Chicago' }) + ' CT)</p><table><tr><th>Place</th><th>Member</th><th>POL</th><th>State</th><th>Tx</th></tr>' + r.payouts.map(x => '<tr><td>' + x.place + '</td><td>' + esc(x.name) + ' #' + x.memberId + '</td><td>' + esc(x.pol) + '</td><td>' + esc(x.state) + (x.note ? ' <span class="muted">' + esc(x.note) + '</span>' : '') + '</td><td>' + (x.tx ? '<a href="' + esc(x.tx) + '" target="_blank" rel="noopener">tx</a>' : '') + '</td></tr>').join('') + '</table>' : '';
$('lwPay').hidden = !r.canPay || !(r.wouldPay || []).length || (r.payouts || []).length && r.payouts.every(x => x.state === 'paid');
}
$('lwRefresh').addEventListener('click', load);
$('lwGrant').addEventListener('click', async () => {
try { const r = await api('/api/admin/launch-week/founders', {}); IAP.status('Founder badge: granted to ' + (r.granted || 0) + ' accounts' + (r.skipped ? ' (' + r.skipped + ')' : '') + '.', 'ok'); load(); } catch (e) { IAP.status(e.message, 'bad'); }
});
$('lwPay').addEventListener('click', async () => {
await load(); if (!last) return;
const list = last.wouldPay || []; if (!list.length) { IAP.status('Nobody placed: nothing to pay.', 'bad'); return; }
const total = list.reduce((n, x) => n + Number(x.pol), 0);
const text = list.map(x => 'Place ' + x.place + ': ' + x.name + ' (member #' + x.memberId + ', ' + x.sales + ' sales) gets ' + x.pol + ' POL').join('\n') + '\n\nTotal ' + total + ' POL plus gas, sent from the payer wallet with award(memberId). Each place is paid once.';
if (!await IAP.confirmBox(text, { title: 'Pay the launch week contest?', ok: 'Pay ' + total + ' POL', cancel: 'Cancel' })) return;
try { const r = await api('/api/admin/launch-week/pay', { confirm: true, places: list.map(x => ({ place: x.place, memberId: x.memberId, pol: x.pol })) }); IAP.status('Launch contest: ' + (r.paidNow || 0) + ' paid now.', 'ok'); load(); } catch (e) { IAP.status(e.message, 'bad'); load(); }
});
load();
})();
+29
View File
@@ -0,0 +1,29 @@
// Admin > Overview > Refill notices (2026-10-24): who was told their ads ran low, ran out or sat idle, and what they did next.
(function () {
const $ = id => document.getElementById(id);
if (!$('rfBox')) return;
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const ct = ts => new Date(Number(ts)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT';
const STATE = { low: 'running low', out: 'out of credits', idle: 'idle a week' };
async function load() {
try {
const r = await (await fetch('/api/admin/refill', { cache: 'no-store' })).json();
if (r.error) throw new Error(r.error);
const t = r.totals || {};
$('rfSub').textContent = (r.enabled ? 'on' : 'OFF (site setting refillNotices)') + ', low at ' + r.lowPct + '% delivered';
const st = Object.entries(r.byState || {}).map(([k, v]) => esc(STATE[k] || k) + ': ' + v.sent + ' sent, ' + v.converted + ' acted').join(' &middot; ');
const kinds = Object.entries(r.byKind || {}).map(([k, v]) => esc(k) + ' ' + v).join(', ');
$('rfBox').innerHTML = '<p class="small" style="margin:0 0 8px"><b>' + (t.sent || 0) + '</b> sent (' + (t.emailed || 0) + ' emailed), <b>' + (t.converted || 0) + '</b> acted on it (' + (t.ratePct || 0) + '%)'
+ (t.purchasesUsd ? ', $' + t.purchasesUsd + ' in packages after a notice' : '') + (t.medianHours != null ? ', median ' + t.medianHours + ' h' : '') + '</p>'
+ '<p class="small muted" style="margin:0 0 8px">' + st + (kinds ? '<br>' + kinds : '') + '</p>'
+ ((r.recent || []).length ? '<div class="tbl-wrap"><table class="tbl small"><tr><th>When</th><th>Owner</th><th>State</th><th>Ads</th><th>Credits then</th><th>Next</th></tr>'
+ r.recent.slice(0, 20).map(x => '<tr><td>' + esc(ct(x.at)) + '</td><td>' + esc(x.owner) + '</td><td>' + esc(STATE[x.state] || x.state) + (x.emailed ? '' : ' <span class="muted">(on-site only)</span>') + '</td><td>' + esc((x.names || []).join(', ')) + '</td><td>' + Number(x.credits || 0).toLocaleString() + '</td><td>' + (x.converted ? esc(x.converted.kind) + ' after ' + x.converted.hours + ' h' : '<span class="muted">nothing yet</span>') + '</td></tr>').join('') + '</table></div>' : '<p class="small muted">Nothing sent yet.</p>');
} catch (e) { $('rfBox').textContent = 'Could not load: ' + e.message; }
}
$('rfRun') && $('rfRun').addEventListener('click', async () => {
$('rfRun').disabled = true;
try { const r = await (await fetch('/api/admin/refill/run', { method: 'POST', cache: 'no-store' })).json(); $('rfSub').textContent = 'pass done: ' + (r.sent || 0) + ' sent'; } catch (e) {}
$('rfRun').disabled = false; load();
});
load();
})();
+1 -1
View File
@@ -8,7 +8,7 @@
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c])); const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const day = ts => ts ? new Date(Number(ts)).toLocaleString([], { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : ''; const day = ts => ts ? new Date(Number(ts)).toLocaleString([], { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
const say = (m, k) => { try { IAP.status(m, k); } catch (e) {} }; const say = (m, k) => { try { IAP.status(m, k); } catch (e) {} };
const HOW = { adopt: 'adopted from the tank', rescue: 'rescued to the tank', release: 'released to the tank', expire: 'adoption window ended', admin: 'admin edit' }; const HOW = { adopt: 'adopted from the tank', rescue: 'rescued to the tank', release: 'released to the tank', expire: 'adoption window ended', admin: 'admin edit', invited: 'the member named who invited them' };
const NAME = { instantadpay: 'InstantAdPay', linkspin: 'LinkSpin' }; const NAME = { instantadpay: 'InstantAdPay', linkspin: 'LinkSpin' };
function side(f) { function side(f) {
if (!f) return '<span class="muted">no account</span>'; if (!f) return '<span class="muted">no account</span>';
+15 -15
View File
@@ -25,7 +25,7 @@
.adm .rail .nb.on{background:rgba(31,111,235,.22);color:#fff} .adm .rail .nb.on{background:rgba(31,111,235,.22);color:#fff}
.adm .rail .nb.on::before{content:"";position:absolute;left:-10px;top:10px;bottom:10px;width:3px;border-radius:0 3px 3px 0;background:var(--sig)} .adm .rail .nb.on::before{content:"";position:absolute;left:-10px;top:10px;bottom:10px;width:3px;border-radius:0 3px 3px 0;background:var(--sig)}
.adm .rail .nb .lbl{display:none;white-space:nowrap} .adm .rail .nb .lbl{display:none;white-space:nowrap}
.adm .rail .nb .pill{position:absolute;top:4px;right:4px;margin:0;min-width:16px;height:16px;border-radius:8px;background:var(--sig);color:#fff;font:700 10px/16px var(--mono);padding:0 4px;text-align:center} .adm .rail .nb .pill{position:absolute;top:4px;right:4px;margin:0;min-width:16px;height:16px;border-radius:8px;background:var(--sig);color:var(--sig-ink);font:700 10px/16px var(--mono);padding:0 4px;text-align:center}
.app.wide .rail .nb{width:auto;justify-content:flex-start;gap:12px;padding:0 10px} .app.wide .rail .nb{width:auto;justify-content:flex-start;gap:12px;padding:0 10px}
.app.wide .rail .nb .lbl{display:inline} .app.wide .rail .nb .lbl{display:inline}
.app.wide .rail .nb .pill{position:static;margin-left:auto} .app.wide .rail .nb .pill{position:static;margin-left:auto}
@@ -47,8 +47,8 @@
.adm .pane>.grid:first-child{margin-top:0} .adm .pane>.grid:first-child{margin-top:0}
.adm .card p{margin:0 0 10px} .adm .card p:last-child{margin-bottom:0} .adm .card p{margin:0 0 10px} .adm .card p:last-child{margin-bottom:0}
.adm .card h3+p,.adm .card-head+p{margin-top:6px} .adm .card h3+p,.adm .card-head+p{margin-top:6px}
.adm .bo-content .btn:not(.sec):not(.ghost):not(.pri){background:linear-gradient(180deg,#3A83F0,var(--accent));color:#fff;border-color:var(--accent-hi);box-shadow:0 8px 18px -10px rgba(31,111,235,.9),0 1px 0 rgba(255,255,255,.3) inset} .adm .bo-content .btn:not(.sec):not(.ghost):not(.pri){background:var(--btn-blue);color:var(--accent-ink);border-color:var(--accent-hi);box-shadow:0 8px 18px -10px rgba(31,111,235,.9),0 1px 0 rgba(255,255,255,.3) inset}
.adm .bo-content .btn:not(.sec):not(.ghost):not(.pri):hover{background:linear-gradient(180deg,#4A8FF3,#2A77ED)} .adm .bo-content .btn:not(.sec):not(.ghost):not(.pri):hover{filter:brightness(1.06)}
.adm .btn.small.ghost{background:transparent;box-shadow:none;border-color:transparent;color:var(--accent-hi)} .adm .btn.small.ghost{background:transparent;box-shadow:none;border-color:transparent;color:var(--accent-hi)}
.adm .btn.small.ghost:hover{border-color:var(--line-strong)} .adm .btn.small.ghost:hover{border-color:var(--line-strong)}
.adm .btn.sec:hover{border-color:var(--accent);color:var(--accent-hi)} .adm .btn.sec:hover{border-color:var(--accent);color:var(--accent-hi)}
@@ -58,10 +58,10 @@
.adm .adm-form label.small{display:block;margin-bottom:4px} .adm .adm-form label.small{display:block;margin-bottom:4px}
.adm .small{font-size:12.5px} .adm .small{font-size:12.5px}
.adm .card .sub{color:var(--muted)} .adm .card .sub{color:var(--muted)}
.adm .badge.amber{background:var(--warn-soft);color:var(--warn);border-color:rgba(194,65,12,.35)} .adm .badge.amber{background:var(--warn-soft);color:var(--warn);border-color:var(--warn-line)}
.adm code{font-family:var(--mono);font-size:11.5px;background:var(--panel-2);border:1px solid var(--line);border-radius:4px;padding:1px 5px;color:var(--ink)} .adm code{font-family:var(--mono);font-size:11.5px;background:var(--panel-2);border:1px solid var(--line);border-radius:4px;padding:1px 5px;color:var(--ink)}
.adm pre.small{background:var(--panel-2)!important;color:var(--ink);font-family:var(--mono);font-size:12px} .adm pre.small{background:var(--panel-2)!important;color:var(--ink);font-family:var(--mono);font-size:12px}
.adm #memHits{background:#fff} .adm #memHits{background:var(--panel)}
.adm #memHits button:hover{background:var(--accent-soft)} .adm #memHits button:hover{background:var(--accent-soft)}
.adm .statx .nv{font-size:26px} .adm .statx .nv{font-size:26px}
.adm .chip.flat{margin-top:6px} .adm .chip.flat{margin-top:6px}
@@ -78,29 +78,29 @@
.adm-table td.act,.adm-table th:last-child{width:1%;white-space:nowrap} .adm-table td.act,.adm-table th:last-child{width:1%;white-space:nowrap}
.adm-table td:first-child{overflow-wrap:anywhere} .adm-table td:first-child{overflow-wrap:anywhere}
.adm-table th,.adm-table td{padding:8px 10px;text-align:left;vertical-align:top;border-bottom:1px solid var(--line);font-size:13px;color:var(--ink)} .adm-table th,.adm-table td{padding:8px 10px;text-align:left;vertical-align:top;border-bottom:1px solid var(--line);font-size:13px;color:var(--ink)}
.adm-table tr:hover td{background:rgba(31,111,235,.04)} .adm-table tr:hover td{background:var(--row-hover)}
.adm-table td.when{white-space:nowrap} .adm-table td.when{white-space:nowrap}
.adm-table th{color:var(--muted);font-family:var(--mono);font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;background:var(--panel-2)} .adm-table th{color:var(--muted);font-family:var(--mono);font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;background:var(--panel-2)}
.adm-table .act{white-space:nowrap} .adm-table .act{white-space:nowrap}
.adm-table .act button,.adm-table .act .btn{margin-right:6px} .adm-table .act button,.adm-table .act .btn{margin-right:6px}
.adm-table a{color:var(--accent-hi)} .adm-table a{color:var(--accent-hi)}
.tablewrap{border:1px solid var(--line);border-radius:8px;background:#fff;overflow-x:auto} .tablewrap{border:1px solid var(--line);border-radius:8px;background:var(--panel);overflow-x:auto}
.tablewrap:empty,.tablewrap:has(> table:empty){display:none} .tablewrap:empty,.tablewrap:has(> table:empty){display:none}
/* status pills */ /* status pills */
.st{display:inline-block;border-radius:4px;padding:1px 7px;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;border:1px solid var(--line-strong);color:var(--ink-2);background:var(--panel-2)} .st{display:inline-block;border-radius:4px;padding:1px 7px;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;border:1px solid var(--line-strong);color:var(--ink-2);background:var(--panel-2)}
.st.active,.st.running,.st.released,.st.done{background:var(--ok-soft);color:var(--ok);border-color:rgba(14,138,92,.4)} .st.active,.st.running,.st.released,.st.done{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-line)}
.st.paused,.st.pending,.st.queued,.st.draft{background:var(--warn-soft);color:var(--warn);border-color:rgba(194,65,12,.4)} .st.paused,.st.pending,.st.queued,.st.draft{background:var(--warn-soft);color:var(--warn);border-color:var(--warn-line)}
.st.out,.st.ended,.st.finished{background:var(--panel-2);color:var(--muted);border-color:var(--line-strong)} .st.out,.st.ended,.st.finished{background:var(--panel-2);color:var(--muted);border-color:var(--line-strong)}
.st.rejected,.st.burned,.st.failed{background:var(--bad-soft);color:var(--bad);border-color:rgba(185,28,28,.4)} .st.rejected,.st.burned,.st.failed{background:var(--bad-soft);color:var(--bad);border-color:var(--bad-line)}
.house-tag{display:inline-block;white-space:nowrap;overflow-wrap:normal;word-break:normal;border:1px solid rgba(109,74,255,.45);color:#6D4AFF;background:#EEE9FF;border-radius:4px;padding:0 6px;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;margin-left:6px;vertical-align:middle} .house-tag{display:inline-block;white-space:nowrap;overflow-wrap:normal;word-break:normal;border:1px solid var(--violet-line);color:var(--violet);background:var(--violet-soft);border-radius:4px;padding:0 6px;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;margin-left:6px;vertical-align:middle}
/* forms */ /* forms */
.adm-form p{margin:0 0 10px} .adm-form p{margin:0 0 10px}
.trunc{max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block;vertical-align:bottom} .trunc{max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block;vertical-align:bottom}
textarea.json{font-family:var(--mono);font-size:12px;width:100%;min-height:260px} textarea.json{font-family:var(--mono);font-size:12px;width:100%;min-height:260px}
.ph-chips{display:inline-flex;gap:6px;flex-wrap:wrap;margin-left:6px;vertical-align:middle} .ph-chips{display:inline-flex;gap:6px;flex-wrap:wrap;margin-left:6px;vertical-align:middle}
.ph-chips .chip-t{padding:2px 10px;font-size:11px;font-family:var(--mono);text-transform:none;letter-spacing:0;cursor:pointer;background:#fff} .ph-chips .chip-t{padding:2px 10px;font-size:11px;font-family:var(--mono);text-transform:none;letter-spacing:0;cursor:pointer;background:var(--panel)}
.drip-steps{display:grid;gap:12px} .drip-steps{display:grid;gap:12px}
.drip-step{border:1px solid var(--line);border-radius:8px;padding:14px 16px;background:var(--panel-2)} .drip-step{border:1px solid var(--line);border-radius:8px;padding:14px 16px;background:var(--panel-2)}
.drip-step .ds-head{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:8px} .drip-step .ds-head{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:8px}
@@ -112,7 +112,7 @@ textarea.json{font-family:var(--mono);font-size:12px;width:100%;min-height:260px
.drip-step .ds-tools .btn{padding:4px 10px;font-size:11px} .drip-step .ds-tools .btn{padding:4px 10px;font-size:11px}
.drip-step input.ds-subject{width:100%;margin-bottom:8px;font-weight:700} .drip-step input.ds-subject{width:100%;margin-bottom:8px;font-weight:700}
.drip-step textarea.ds-body{width:100%;min-height:200px;font-size:13px;line-height:1.5} .drip-step textarea.ds-body{width:100%;min-height:200px;font-size:13px;line-height:1.5}
.drip-step input,.drip-step textarea{background:#fff} .drip-step input,.drip-step textarea{background:var(--field-bg)}
.rates-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px 22px} .rates-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px 22px}
.rates-form .rf{display:flex;flex-direction:column;gap:4px} .rates-form .rf{display:flex;flex-direction:column;gap:4px}
.rates-form .rf label{font-size:12.5px;font-weight:700;color:var(--ink)} .rates-form .rf label{font-size:12.5px;font-weight:700;color:var(--ink)}
@@ -145,14 +145,14 @@ textarea.json{font-family:var(--mono);font-size:12px;width:100%;min-height:260px
.ct-filters .ct-chk input{width:auto;margin:0} .ct-filters .ct-chk input{width:auto;margin:0}
.ct-hosts{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin:0 0 10px} .ct-hosts{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin:0 0 10px}
.ct-hosts .chip-t{font-family:var(--mono);text-transform:none;letter-spacing:0;font-size:11px} .ct-hosts .chip-t{font-family:var(--mono);text-transform:none;letter-spacing:0;font-size:11px}
.ct-hosts .chip-t.bad{border-color:rgba(185,28,28,.5);color:var(--bad);background:var(--bad-soft)} .ct-hosts .chip-t.bad{border-color:var(--bad-line);color:var(--bad);background:var(--bad-soft)}
.ct-table .ct-type{font:700 10.5px var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--accent-hi);white-space:nowrap} .ct-table .ct-type{font:700 10.5px var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--accent-hi);white-space:nowrap}
.ct-table .ct-title{font-weight:700;margin:0 0 3px;overflow-wrap:anywhere} .ct-table .ct-title{font-weight:700;margin:0 0 3px;overflow-wrap:anywhere}
.ct-table td{overflow-wrap:anywhere} .ct-table td{overflow-wrap:anywhere}
.ct-table .ct-l{font-size:12.5px;color:var(--ink-2);margin:2px 0;line-height:1.45} .ct-table .ct-l{font-size:12.5px;color:var(--ink-2);margin:2px 0;line-height:1.45}
.ct-table .ct-flags{margin:2px 0 4px;display:flex;gap:4px;flex-wrap:wrap} .ct-table .ct-flags{margin:2px 0 4px;display:flex;gap:4px;flex-wrap:wrap}
.ct-table .ct-flags .st{text-transform:none;letter-spacing:0;font-family:var(--body);font-size:11px} .ct-table .ct-flags .st{text-transform:none;letter-spacing:0;font-family:var(--body);font-size:11px}
.ct-table tr.ct-flagged td{background:rgba(185,28,28,.035)} .ct-table tr.ct-flagged td{background:color-mix(in srgb,var(--bad) 5%,transparent)}
.ct-table .ct-nums div{white-space:nowrap} .ct-table .ct-nums div{white-space:nowrap}
.ct-table td[data-l="Status"] .st{white-space:nowrap} .ct-table td[data-l="Status"] .st{white-space:nowrap}
.ct-table .ct-mem{font-weight:700} .ct-table .ct-mem{font-weight:700}
+46 -7
View File
@@ -296,12 +296,24 @@
async function loadTank() { async function loadTank() {
try { try {
const r = await (await fetch('/api/admin/tank')).json(); if (r.error) return; const r = await (await fetch('/api/admin/tank')).json(); if (r.error) return;
$('tankAdmSub').textContent = r.waiting.length + ' waiting · cap ' + r.cap + ' open per adopter · ' + r.ttlDays + '-day window'; const nReady = r.waiting.filter(w => w.ready).length;
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th></tr>' + (r.waiting.length ? r.waiting.map(w => '<tr><td>' + esc(w.name) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">empty</td></tr>'); $('tankAdmSub').textContent = r.waiting.length + ' waiting' + (nReady ? ' (' + nReady + ' ready to activate)' : '') + ' · cap ' + r.cap + ' open per adopter · ' + r.ttlDays + '-day window · ready members: the free activation is held ' + (r.holdHours || 24) + ' h (a purchase never is), then auto-assigned in rotation';
$('tankAdopt').innerHTML = '<tr><th>Member</th><th>Adopted by</th><th>When</th><th>Window ends</th><th>Status</th></tr>' + (r.adoptions.length ? r.adoptions.map(a => '<tr><td>' + esc(a.adopteeName) + '</td><td>' + esc(a.adopterName) + '</td><td class="when">' + when(a.ts) + '</td><td class="when">' + (a.status === 'released' ? '' : when(a.expires)) + '</td><td>' + esc(a.status) + '</td></tr>').join('') : '<tr><td colspan="5" class="muted">none yet</td></tr>'); // ready = wallet linked: the plain activation is held (never the company) until someone adopts them or the 24-hour safety net assigns them (2026-10-27)
const left = w => { const ms = (w.holdUntil || 0) - Date.now(); if (ms <= 0) return 'assigning now'; const m = Math.round(ms / 60000); return (m >= 60 ? Math.floor(m / 60) + ' h ' + (m % 60) + ' min' : m + ' min') + ' left'; };
const rb = w => (w.opensAt > Date.now() ? ' <span class="badge amber" title="New sign-up: hand adoption opens 24 hours after they joined">Opens ' + when(w.opensAt) + '</span>' : '') + (w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)">Ready to activate · ' + left(w) + '</span>' : '');
// readiness (2026-11-18, network hub): hottest first, stage + heat + last action + how they got here; the hub down = the old table
const RD = window.TankReady; const rdOn = RD && r.waiting.some(w => w.rd);
const wl = rdOn ? r.waiting.slice().sort((a, b) => RD.score(b) - RD.score(a)) : r.waiting;
const rs = r.readiness || {}; const rc = rs.counts || {}; const cnt = o => Object.entries(o || {}).sort((a, b) => b[1] - a[1]).map(([k, v]) => k + ' ' + v).join(', ');
$('tankAdmSub').textContent += rs.on ? (rs.ok === false ? ' · readiness: hub not answering (' + (rs.error || '') + ')' : rc.n ? ' · readiness: how they got here ' + cnt(rc.reasons) + ' · stages ' + cnt(rc.stages) + ' · heat ' + cnt(rc.bands) : ' · readiness: loading') : ' · readiness off';
const cols = rdOn ? 5 : 4;
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th>' + (rdOn ? '<th>Readiness (hottest first)</th>' : '') + '</tr>' + (wl.length ? wl.map(w => '<tr><td>' + esc(w.name) + rb(w) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td>' + (rdOn ? '<td>' + (w.rd ? RD.html(w.rd) : '<span class="muted small">no answer</span>') + '</td>' : '') + '</tr>').join('') : '<tr><td colspan="' + cols + '" class="muted">empty</td></tr>')
+ ((r.aligned || []).length ? '<tr><th colspan="4">Aligned to their network sponsor (InstantAdPay) instead of the tank</th></tr>' + r.aligned.slice(0, 15).map(x => '<tr><td>' + esc(x.email) + '</td><td>' + esc(x.toName || x.to) + '</td><td class="when">' + when(x.at) + '</td><td class="muted">' + esc(x.via || '') + '</td></tr>').join('') : '');
$('tankAdopt').innerHTML = '<tr><th>Member</th><th>Adopted by</th><th>When</th><th>Window ends</th><th>Status</th></tr>' + (r.adoptions.length ? r.adoptions.map(a => '<tr><td>' + esc(a.adopteeName) + '</td><td>' + esc(a.adopterName) + '</td><td class="when">' + when(a.ts) + '</td><td class="when">' + (a.status === 'released' || a.status === 'invited' ? '' : when(a.expires)) + '</td><td>' + esc(a.status) + '</td></tr>').join('') : '<tr><td colspan="5" class="muted">none yet</td></tr>');
} catch (e) {} } catch (e) {}
} }
async function loadMembers() { async function loadMembers() {
loadSpamScan().catch(() => {});
loadTank(); loadTank();
const r = await api('/api/admin/members'); const r = await api('/api/admin/members');
allMembers = r.members || []; allMembers = r.members || [];
@@ -320,6 +332,31 @@
+ '<td class="act"><button class="btn small sec" data-mcopen="' + esc(a.email) + '">Open</button> <button class="btn small sec" data-spon="' + esc(a.email) + '" data-cur="' + esc(a.sponsorRef || '') + '">Sponsor</button></td></tr>').join(''); + '<td class="act"><button class="btn small sec" data-mcopen="' + esc(a.email) + '">Open</button> <button class="btn small sec" data-spon="' + esc(a.email) + '" data-cur="' + esc(a.sponsorRef || '') + '">Sponsor</button></td></tr>').join('');
} }
$('memFilter').addEventListener('input', drawMembers); $('memFilter').addEventListener('input', drawMembers);
// Link-farm list (2026-10-30): the daily scan's candidates; Delete selected = one DELETE /api/admin/member per email (on-chain refused); Allow = spamScanAllow
async function loadSpamScan() {
let v; try { v = await api('/api/admin/spamscan'); } catch (e) { return; }
const last = v.last || {}; const rows = last.candidates || [];
$('spamSub').textContent = last.at ? (rows.length + ' candidate' + (rows.length === 1 ? '' : 's') + ' \u00B7 scanned ' + when(last.at) + (last.manual ? ' (manual)' : '') + ' \u00B7 ' + (last.scanned || 0) + ' accounts, ' + (last.skipped || 0) + ' allowlisted') : 'no scan yet (daily at 06:30 Central)';
$('spamAllow').textContent = 'Allowlist: ' + ((v.allow || []).join(', ') || 'empty');
$('spamTable').innerHTML = '<tr><th></th><th>Account</th><th>Joined</th><th>Sponsor</th><th>First link</th><th>Why</th><th>Also on ' + esc(v.otherSite || 'the other site') + '</th><th></th></tr>'
+ (rows.length ? rows.map(c => '<tr><td><input type="checkbox" data-spamsel="' + esc(c.email) + '"></td><td>' + (c.username ? '<b>@' + esc(c.username) + '</b><br>' : '') + '<span class="small">' + esc(c.email) + '</span>' + (c.quarantined ? ' <span class="badge amber">quarantined</span>' : '') + '</td>'
+ '<td class="small muted when">' + when(c.created) + '</td><td class="small">' + esc(c.sponsorName || 'none') + '</td><td class="small mono" style="max-width:260px;overflow:hidden;text-overflow:ellipsis" title="' + esc((c.links || []).join(' ')) + '">' + esc(c.firstLink || '') + '</td>'
+ '<td class="small">' + esc((c.reasons || []).join(', ')) + '</td><td class="small">' + (c.alsoOn === true ? 'yes' : c.alsoOn === false ? 'no' : 'unknown') + '</td>'
+ '<td class="act"><button class="btn small sec" data-mcopen="' + esc(c.email) + '">Open</button> <button class="btn small sec" data-spamallow="' + esc(c.email) + '">Allow</button></td></tr>').join('') : '<tr><td colspan="8" class="muted small">Nothing to review.</td></tr>');
}
$('spamRun').addEventListener('click', busy($('spamRun'), async () => { await api('/api/admin/spamscan/run', {}); await loadSpamScan(); IAP.status('Scan done.', 'ok'); }));
$('spamDelete').addEventListener('click', busy($('spamDelete'), async () => {
const sel = [...document.querySelectorAll('[data-spamsel]:checked')].map(x => x.dataset.spamsel);
if (!sel.length) { IAP.status('Tick the accounts to delete first.', 'bad'); return; }
if (!await IAP.confirmBox('Delete ' + sel.length + ' account' + (sel.length === 1 ? '' : 's') + ' with their profile text? On-chain members are refused. InstantAdPay is not touched.', { title: 'Delete selected', ok: 'Delete', cancel: 'Cancel' })) return;
let ok = 0, bad = 0; for (const e of sel) { try { await api('/api/admin/member?email=' + encodeURIComponent(e), undefined, 'DELETE'); ok++; } catch (err) { bad++; } }
IAP.status(ok + ' deleted' + (bad ? ', ' + bad + ' refused' : '') + '.', bad ? 'bad' : 'ok');
await api('/api/admin/spamscan/run', {}).catch(() => {}); await loadSpamScan(); loadMembers().catch(() => {});
}));
document.addEventListener('click', async e => {
const b = e.target.closest('[data-spamallow]'); if (!b) return;
try { await api('/api/admin/spamscan/allow', { email: b.dataset.spamallow }); IAP.status('Allowed ' + b.dataset.spamallow + '.', 'ok'); await api('/api/admin/spamscan/run', {}).catch(() => {}); loadSpamScan(); } catch (err) { IAP.status(err.message, 'bad'); }
});
document.addEventListener('click', async e => { document.addEventListener('click', async e => {
const b = e.target.closest('[data-spon]'); if (!b) return; const b = e.target.closest('[data-spon]'); if (!b) return;
const v = await IAP.ask({ title: 'Sponsor for ' + b.dataset.spon, text: 'Username, share code, or member #. Leave blank to clear.', value: b.dataset.cur, ok: 'Save' }); const v = await IAP.ask({ title: 'Sponsor for ' + b.dataset.spon, text: 'Username, share code, or member #. Leave blank to clear.', value: b.dataset.cur, ok: 'Save' });
@@ -347,7 +384,7 @@
mcCur = d; const a = d.account; $('memHits').hidden = true; mcCur = d; const a = d.account; $('memHits').hidden = true;
$('memCard').hidden = false; document.querySelectorAll('#pane-members > .card').forEach(c => { if (c.id !== 'memCard' && c.id !== 'memSearchCard') c.hidden = true; }); $('memCard').hidden = false; document.querySelectorAll('#pane-members > .card').forEach(c => { if (c.id !== 'memCard' && c.id !== 'memSearchCard') c.hidden = true; });
$('mcName').textContent = (a.username ? '@' + a.username : a.email) + (a.memberId ? ' · member #' + a.memberId : ' · free member'); $('mcName').textContent = (a.username ? '@' + a.username : a.email) + (a.memberId ? ' · member #' + a.memberId : ' · free member');
$('mcSub').textContent = 'joined ' + when(a.created) + ' · last seen ' + ago(a.lastSeen); $('mcSub').textContent = 'joined ' + when(a.created) + ' · last seen ' + ago(a.lastSeen) + (a.profileQuarantined ? ' · PROFILE QUARANTINED (link planted on a brand-new free account; not shown publicly)' : '');
$('mcWall').hidden = !a.username; if (a.username) $('mcWall').href = '/wall/' + a.username; $('mcWall').hidden = !a.username; if (a.username) $('mcWall').href = '/wall/' + a.username;
const ch = d.chain, cr = d.credits, t = d.totals; const ch = d.chain, cr = d.credits, t = d.totals;
const level = ch && !ch.readError ? (ch.buyerCount >= 5 ? 'level 3 (5+ buyers)' : ch.buyerCount >= 2 ? 'level 2 (2 buyers)' : 'level 1') : ''; const level = ch && !ch.readError ? (ch.buyerCount >= 5 ? 'level 3 (5+ buyers)' : ch.buyerCount >= 2 ? 'level 2 (2 buyers)' : 'level 1') : '';
@@ -483,7 +520,7 @@
$('updPreview').addEventListener('click', busy($('updPreview'), async () => { const r = await api('/api/admin/updates/preview', updInput()); $('updPre').hidden = false; $('updPre').textContent = 'Subject: ' + r.subject + '\n\n' + r.text; })); $('updPreview').addEventListener('click', busy($('updPreview'), async () => { const r = await api('/api/admin/updates/preview', updInput()); $('updPre').hidden = false; $('updPre').textContent = 'Subject: ' + r.subject + '\n\n' + r.text; }));
$('updTest').addEventListener('click', busy($('updTest'), async () => { const r = await api('/api/admin/updates/send', Object.assign(updInput(), { test: true })); IAP.status('Test sent to ' + r.to + '.', 'ok'); })); $('updTest').addEventListener('click', busy($('updTest'), async () => { const r = await api('/api/admin/updates/send', Object.assign(updInput(), { test: true })); IAP.status('Test sent to ' + r.to + '.', 'ok'); }));
$('updSend').addEventListener('click', busy($('updSend'), async () => { $('updSend').addEventListener('click', busy($('updSend'), async () => {
const inp = updInput(); if (!inp.noteIds.length) { IAP.status('Pick at least one note.', 'bad'); return; } const inp = updInput(); if (!inp.noteIds.length && !String(inp.intro || '').trim()) { IAP.status('Write an intro or pick at least one note.', 'bad'); return; }
const opt = $('updAudience').selectedOptions[0].textContent; const opt = $('updAudience').selectedOptions[0].textContent;
if (!(await IAP.confirmBox('Send this update to ' + opt + '? One email per member, opt-outs skipped.', { title: 'Send member update', ok: 'Send now', cancel: 'Not yet' }))) return; if (!(await IAP.confirmBox('Send this update to ' + opt + '? One email per member, opt-outs skipped.', { title: 'Send member update', ok: 'Send now', cancel: 'Not yet' }))) return;
const r = await api('/api/admin/updates/send', inp); IAP.status('Sending to ' + r.total + ' members in the background.', 'ok'); loadUpdates(); const r = await api('/api/admin/updates/send', inp); IAP.status('Sending to ' + r.total + ' members in the background.', 'ok'); loadUpdates();
@@ -697,7 +734,7 @@
const ago = t => t ? new Date(t).toLocaleString() : 'never'; const ago = t => t ? new Date(t).toLocaleString() : 'never';
const mark = v => v === 'clean' ? '<span style="color:var(--ok,#2e9b5a)">clean</span>' : v === 'flagged' || v === 'listed' ? '<b style="color:var(--bad)">' + v + '</b>' : /^ok:/.test(v || '') ? '<span style="color:var(--ok,#2e9b5a)">answered ' + esc(v.slice(3)) + '</span>' : '<span class="muted">unknown</span>'; const mark = v => v === 'clean' ? '<span style="color:var(--ok,#2e9b5a)">clean</span>' : v === 'flagged' || v === 'listed' ? '<b style="color:var(--bad)">' + v + '</b>' : /^ok:/.test(v || '') ? '<span style="color:var(--ok,#2e9b5a)">answered ' + esc(v.slice(3)) + '</span>' : '<span class="muted">unknown</span>';
$('dmTable').innerHTML = '<tr><th>Domain</th><th>Channel</th><th>Safe Browsing</th><th>URIBL</th><th>SURBL</th><th>Reach</th><th>Status</th><th>Last check</th><th></th></tr>' $('dmTable').innerHTML = '<tr><th>Domain</th><th>Channel</th><th>Safe Browsing</th><th>URIBL</th><th>SURBL</th><th>Reach</th><th>Status</th><th>Last check</th><th></th></tr>'
+ (list.length ? list.map(x => '<tr' + (x.burned ? ' style="background:rgba(192,57,43,.08)"' : '') + '><td><b>' + esc(x.host) + '</b></td>' + (list.length ? list.map(x => '<tr' + (x.burned ? ' style="background:var(--bad-soft)"' : '') + '><td><b>' + esc(x.host) + '</b></td>'
+ '<td><select data-dmch="' + esc(x.host) + '">' + (d.channels || []).map(c => '<option value="' + c + '"' + (c === x.channel ? ' selected' : '') + '>' + esc(d.labels[c] || c) + '</option>').join('') + '</select><br><span class="muted small">' + esc(d.notes[x.channel] || '') + '</span></td>' + '<td><select data-dmch="' + esc(x.host) + '">' + (d.channels || []).map(c => '<option value="' + c + '"' + (c === x.channel ? ' selected' : '') + '>' + esc(d.labels[c] || c) + '</option>').join('') + '</select><br><span class="muted small">' + esc(d.notes[x.channel] || '') + '</span></td>'
+ '<td>' + mark(x.gsb) + '</td><td>' + mark(x.uribl) + '</td><td>' + mark(x.surbl) + '</td><td>' + mark(x.reach) + '</td>' + '<td>' + mark(x.gsb) + '</td><td>' + mark(x.uribl) + '</td><td>' + mark(x.surbl) + '</td><td>' + mark(x.reach) + '</td>'
+ '<td>' + (x.burned ? '<b style="color:var(--bad)">BURNED</b><br><span class="muted small">' + esc(x.reason || '') + (x.burnedAt ? ' · ' + ago(x.burnedAt) : '') + '</span>' : x.channel === 'reserve' ? '<span class="muted">held in reserve</span>' : '<span style="color:var(--ok,#2e9b5a)">live</span>') + '</td>' + '<td>' + (x.burned ? '<b style="color:var(--bad)">BURNED</b><br><span class="muted small">' + esc(x.reason || '') + (x.burnedAt ? ' · ' + ago(x.burnedAt) : '') + '</span>' : x.channel === 'reserve' ? '<span class="muted">held in reserve</span>' : '<span style="color:var(--ok,#2e9b5a)">live</span>') + '</td>'
@@ -1007,6 +1044,8 @@
loginCreditsPerDay: ['Login ad: legacy credits per day', 'only for old login ads with no end date (none since slots)'], loginCreditsPerDay: ['Login ad: legacy credits per day', 'only for old login ads with no end date (none since slots)'],
loginDwellSeconds: ['Login ad: seconds shown', 'full-screen interstitial after sign-in'], loginDwellSeconds: ['Login ad: seconds shown', 'full-screen interstitial after sign-in'],
burnBatchMin: ['On-chain burn batch (credits)', 'accrued spend is burned once it reaches this'], burnBatchMin: ['On-chain burn batch (credits)', 'accrued spend is burned once it reaches this'],
synRateDivisor: ['Network rate divisor (N)', 'partner-network (NAS) banner views and member banners in other members zones cost 1/N of the on-site rate; 1 = same rate; whole numbers'],
synRateDivisorText: ['Network rate divisor for TEXT ads (N)', 'off-site text-ad views cost 1/N of the on-site text rate (10 = 1 credit per 100 network views); whole numbers'],
welcomeCredits: ['Welcome credits', 'granted after the welcome tour'], welcomeCredits: ['Welcome credits', 'granted after the welcome tour'],
dailyViewTarget: ['Daily view set (ads)', 'ads a member views for the daily claim'], dailyViewTarget: ['Daily view set (ads)', 'ads a member views for the daily claim'],
dailyClaimCredits: ['Daily claim (credits)', 'paid when the set is complete'], dailyClaimCredits: ['Daily claim (credits)', 'paid when the set is complete'],
@@ -1060,7 +1099,7 @@
})); }));
// site settings: key / value rows; booleans as checkboxes, numbers stay numbers // site settings: key / value rows; booleans as checkboxes, numbers stay numbers
const SITE_META = { noPayoutIds: 'No-payout positions (member #s, comma): linkage only, no buys from them, no joins routed under them', siteName: 'Site name', tagline: 'Tagline', rehearsal: 'Testnet rehearsal banner', defaultSponsorId: 'Fallback sponsor (member #)', walletConnectProjectId: 'WalletConnect project id', moonpayPublicKey: 'MoonPay public key', telegramBotToken: 'Telegram proof feed: bot token', telegramChatId: 'Telegram proof feed: chat id', telegramTopicId: 'Telegram proof feed: topic id (optional)', telegramEvents: 'Telegram proof feed: events (payouts | payouts+purchases | all)', telegramCtaUrl: 'Telegram proof feed: join link under each post', aiCreditsPerGen: 'AI Copy Engine: credits per generation after the free allowance', aiFreeSurge: 'AI Copy Engine: free generations a month at Surge', aiFreeCircuit: 'AI Copy Engine: free generations a month at Circuit', aiFreeNexus: 'AI Copy Engine: free generations a month at Nexus', snapshotEnabled: 'Daily growth snapshot to Telegram (1/0)', snapshotHourUtc: 'Daily growth snapshot: hour (UTC; 14 = 9 AM Central)', snapshotTargets: 'Daily growth snapshot: targets (feed = proof channel, echo = shared payments topic; comma list)', pipelineMode: 'Pipeline board: off (coming soon card) | preview (admin account only) | on (everyone)', pipelineEta: 'Pipeline: opening date shown on the coming-soon card (e.g. Sep 28)', memberWeeklyEmail: 'Weekly member email to everyone active (1) or only sponsors with a line (0)', leaderboardWeeklyPrize: 'Leaderboard: weekly prize text (optional; blank shows the credit ladder)', leaderboardMonthlyPrize: 'Leaderboard: monthly prize text (optional)', leaderboardWeeklyCredits: 'Leaderboard: weekly credits for 1st,2nd,3rd… (e.g. 1000,500,250; blank = none)', leaderboardMonthlyCredits: 'Leaderboard: monthly credits for 1st,2nd,3rd… (e.g. 5000,2500,1000)', leaderboardAnnounceGeneral: 'Leaderboard: announce winners in the main group too (1/0)', telegramEchoChatId: 'Telegram echo (shared payments topic): chat id', telegramEchoTopicId: 'Telegram echo: topic id', telegramEchoEvents: 'Telegram echo: events (payouts | payouts+purchases | all)', legacyCreditsAdvertiser: 'Legacy welcome credits: former advertisers', legacyCreditsEarner: 'Legacy welcome credits: former earners', pnlFixedMonthlyUsd: 'P&L: fixed monthly cost (USD)', campaignEditFee: 'Ad edits: credits per edit after the first, free one on each ad (0 = always free)' }; const SITE_META = { loginAdEveryHours: 'Login ad: show again on the next member page once the last finished view is this many hours old (default 3)', noPayoutIds: 'No-payout positions (member #s, comma): linkage only, no buys from them, no joins routed under them', siteName: 'Site name', tagline: 'Tagline', rehearsal: 'Testnet rehearsal banner', defaultSponsorId: 'Fallback sponsor (member #)', walletConnectProjectId: 'WalletConnect project id', telegramBotToken: 'Telegram proof feed: bot token', telegramChatId: 'Telegram proof feed: chat id', telegramTopicId: 'Telegram proof feed: topic id (optional)', telegramEvents: 'Telegram proof feed: events (payouts | payouts+purchases | all)', telegramCtaUrl: 'Telegram proof feed: join link under each post', aiCreditsPerGen: 'AI Copy Engine: credits per generation after the free allowance', aiFreeSurge: 'AI Copy Engine: free generations a month at Surge', aiFreeCircuit: 'AI Copy Engine: free generations a month at Circuit', aiFreeNexus: 'AI Copy Engine: free generations a month at Nexus', snapshotEnabled: 'Daily growth snapshot to Telegram (1/0)', snapshotHourUtc: 'Daily growth snapshot: hour (UTC; 14 = 9 AM Central)', snapshotTargets: 'Daily growth snapshot: targets (feed = proof channel, support = LinkSpin Support topic, echo = shared payments topic; comma list)', telegramSupportChatId: 'Telegram LinkSpin Support topic: chat id', telegramSupportTopicId: 'Telegram LinkSpin Support topic: topic id', pipelineMode: 'Pipeline board: off (coming soon card) | preview (admin account only) | on (everyone)', pipelineEta: 'Pipeline: opening date shown on the coming-soon card (e.g. Sep 28)', memberWeeklyEmail: 'Weekly member email to everyone active (1) or only sponsors with a line (0)', leaderboardWeeklyPrize: 'Leaderboard: weekly prize text (optional; blank shows the credit ladder)', leaderboardMonthlyPrize: 'Leaderboard: monthly prize text (optional)', leaderboardWeeklyCredits: 'Leaderboard: weekly credits for 1st,2nd,3rd… (e.g. 1000,500,250; blank = none)', leaderboardMonthlyCredits: 'Leaderboard: monthly credits for 1st,2nd,3rd… (e.g. 5000,2500,1000)', leaderboardAnnounceGeneral: 'Leaderboard: announce winners in the main group too (1/0)', telegramEchoChatId: 'Telegram echo (shared payments topic): chat id', telegramEchoTopicId: 'Telegram echo: topic id', telegramEchoEvents: 'Telegram echo: events (payouts | payouts+purchases | all)', legacyCreditsAdvertiser: 'Legacy welcome credits: former advertisers', legacyCreditsEarner: 'Legacy welcome credits: former earners', pnlFixedMonthlyUsd: 'P&L: fixed monthly cost (USD)', campaignEditFee: 'Ad edits: credits per edit after the first, free one on each ad (0 = always free)' };
function drawSite() { function drawSite() {
const wrap = $('siteForm'); const wrap = $('siteForm');
wrap.innerHTML = Object.entries(siteObj).map(([k, v]) => '<div class="kv-row"><span class="k" title="' + esc(k) + '">' + esc(SITE_META[k] || humanize(k)) + '</span>' wrap.innerHTML = Object.entries(siteObj).map(([k, v]) => '<div class="kv-row"><span class="k" title="' + esc(k) + '">' + esc(SITE_META[k] || humanize(k)) + '</span>'
+61 -10
View File
@@ -2,7 +2,7 @@
// viewer, member zones and the partner network, and earn credits by viewing. Types are limited to the three Marty chose. // viewer, member zones and the partner network, and earn credits by viewing. Types are limited to the three Marty chose.
(function () { (function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog; const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
let D = null, EARN = null, TYPE = 'banner', SPINS = [], HOSTS = [], IMG = ''; let D = null, EARN = null, TYPE = 'banner', SPINS = [], HOSTS = [], IMG = '', AIW = false;
CR.mount({ active: 'ads', title: 'Ads', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ New ad</button>' }); CR.mount({ active: 'ads', title: 'Ads', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ New ad</button>' });
const NOTE = { const NOTE = {
banner: 'Runs in the ad viewer, in every member zone on outside sites, and on the partner network. Views are timed on the server. Spends purchased or earned credits.', banner: 'Runs in the ad viewer, in every member zone on outside sites, and on the partner network. Views are timed on the server. Spends purchased or earned credits.',
@@ -22,7 +22,11 @@
try { [D, EARN] = await Promise.all([CR.get('/api/my/campaigns'), CR.get('/api/my/earn')]); } catch (e) { CR.sub('could not load'); return; } try { [D, EARN] = await Promise.all([CR.get('/api/my/campaigns'), CR.get('/api/my/earn')]); } catch (e) { CR.sub('could not load'); return; }
const cs = D.campaigns || []; const live = cs.filter(c => c.status === 'active'); const cs = D.campaigns || []; const live = cs.filter(c => c.status === 'active');
{ const sel = $('fAud'); if (sel) { const keep = sel.value; sel.innerHTML = '<option value="">Everyone</option>' + (D.audiences || []).map(a => '<option value="' + a.id + '">' + esc(a.name) + ' (' + fmt(a.size30) + ')</option>').join(''); sel.value = keep; sel.onchange = () => { $('fAudModeRow').hidden = !sel.value; }; } } { const sel = $('fAud'); if (sel) { const keep = sel.value; sel.innerHTML = '<option value="">Everyone</option>' + (D.audiences || []).map(a => '<option value="' + a.id + '">' + esc(a.name) + ' (' + fmt(a.size30) + ')</option>').join(''); sel.value = keep; sel.onchange = () => { $('fAudModeRow').hidden = !sel.value; }; } }
const views = cs.reduce((n, c) => n + (c.imps || 0) + (c.impsNas || 0), 0); const views = cs.reduce((n, c) => n + (c.imps || 0) + (c.impsNas || 0) + (c.impsSyn || 0), 0);
const synN0 = Math.max(1, Math.floor(Number(D.rates && D.rates.synRateDivisor) || 1)); // network rate (Marty, 2026-10-27, 4:1)
const synT = Math.max(1, Math.floor(Number(D.rates && D.rates.synRateDivisorText != null ? D.rates.synRateDivisorText : synN0) || 1)); // text ads (Marty, 2026-11-12, 1/10)
const offTxt = c => { const synN = c.type === 'text' ? synT : synN0; return (c.impsNas ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsNas) + ' network' + (synN > 1 ? ' at 1/' + synN : '') + '</span>' : '')
+ (c.impsSyn ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsSyn) + ' partner zones' + (synN > 1 ? ' at 1/' + synN : '') + '</span>' : ''); };
CR.sub(live.length + ' live · ' + fmt(D.availableCredits) + ' credits available'); CR.sub(live.length + ' live · ' + fmt(D.availableCredits) + ' credits available');
const hours = new Array(24).fill(0); Object.values(D.hours || {}).forEach(a => (a || []).forEach((n, i) => { hours[i] += Number(n) || 0; })); // last 7 days by UTC hour, all campaigns const hours = new Array(24).fill(0); Object.values(D.hours || {}).forEach(a => (a || []).forEach((n, i) => { hours[i] += Number(n) || 0; })); // last 7 days by UTC hour, all campaigns
const week = hours.reduce((a, b) => a + b, 0); const week = hours.reduce((a, b) => a + b, 0);
@@ -32,7 +36,7 @@
CR.tile({ k: 'Views delivered', v: fmt(views), series: week ? hours : null, note: week ? fmt(week) + ' in 7 days, by hour' : '' }), CR.tile({ k: 'Views delivered', v: fmt(views), series: week ? hours : null, note: week ? fmt(week) + ' in 7 days, by hour' : '' }),
CR.tile({ k: 'Today\'s viewing', v: EARN.views + ' / ' + EARN.target, note: EARN.streakDay > 1 ? 'streak day ' + EARN.streakDay : '' })].join(''); CR.tile({ k: 'Today\'s viewing', v: EARN.views + ' / ' + EARN.target, note: EARN.streakDay > 1 ? 'streak day ' + EARN.streakDay : '' })].join('');
const r = D.rates || {}; const r = D.rates || {};
$('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views, ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day login slot (' + (slotInfo().free ? slotInfo().free + ' of ' + slotInfo().max + ' open' : 'all ' + slotInfo().max + ' taken' + (slotInfo().queued ? ', ' + slotInfo().queued + ' in line' : '') + ', reserve the next one') + '). Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.'; $('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views' + (synN0 > 1 ? ' here (views on the partner network and in other members\u2019 zones cost 1/' + synN0 + ' of that for banners' + (synT !== synN0 ? ', 1/' + synT + ' for text ads' : '') + ')' : '') + ', ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day login slot (' + (slotInfo().free ? slotInfo().free + ' of ' + slotInfo().max + ' open' : 'all ' + slotInfo().max + ' taken' + (slotInfo().queued ? ', ' + slotInfo().queued + ' in line' : '') + ', reserve the next one') + '). Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.';
// traffic-light status (2026-10-20): live green, running low amber (80%+ of the budget spent), out red, paused grey // traffic-light status (2026-10-20): live green, running low amber (80%+ of the budget spent), out red, paused grey
const stKey = c => c.status === 'queued' ? 'queued' : c.status === 'cancelled' ? 'cancelled' : c.scheduled ? 'sched' : c.status === 'active' ? (c.type !== 'login' && c.budget > 0 && c.spent / c.budget >= 0.8 ? 'low' : 'live') : c.status === 'paused' ? 'paused' : c.status === 'out' ? 'out' : c.status === 'done' ? 'ended' : ''; const stKey = c => c.status === 'queued' ? 'queued' : c.status === 'cancelled' ? 'cancelled' : c.scheduled ? 'sched' : c.status === 'active' ? (c.type !== 'login' && c.budget > 0 && c.spent / c.budget >= 0.8 ? 'low' : 'live') : c.status === 'paused' ? 'paused' : c.status === 'out' ? 'out' : c.status === 'done' ? 'ended' : '';
const ST_LABEL = { queued: 'In line', cancelled: 'Cancelled, refunded', sched: 'Scheduled', live: 'Live', low: 'Running low', paused: 'Paused', out: 'Out of credits', ended: 'Ended' }; const ST_LABEL = { queued: 'In line', cancelled: 'Cancelled, refunded', sched: 'Scheduled', live: 'Live', low: 'Running low', paused: 'Paused', out: 'Out of credits', ended: 'Ended' };
@@ -40,17 +44,36 @@
const QM = {}; (D.loginQueue || []).forEach(q => { QM[q.id] = q; }); const QM = {}; (D.loginQueue || []).forEach(q => { QM[q.id] = q; });
const qCell = c => { const q = QM[c.id]; return '<span class="muted">full page<br><span style="font-size:12px"><b>#' + (q ? q.place : '?') + ' in line</b>, paid' + (q && q.estStartCt ? '<br>' + (q.estStartCt === 'any minute now' ? 'starts any minute now' : 'est. start ' + esc(q.estStartCt) + ' CT (an estimate)') : '') + '</span></span>'; }; const qCell = c => { const q = QM[c.id]; return '<span class="muted">full page<br><span style="font-size:12px"><b>#' + (q ? q.place : '?') + ' in line</b>, paid' + (q && q.estStartCt ? '<br>' + (q.estStartCt === 'any minute now' ? 'starts any minute now' : 'est. start ' + esc(q.estStartCt) + ' CT (an estimate)') : '') + '</span></span>'; };
const cr = c => c.status === 'queued' ? qCell(c) : c.status === 'cancelled' ? '<span class="muted">full page<br><span style="font-size:12px">' + fmt(c.refunded || 0) + ' credits refunded</span></span>' : c.type === 'banner' ? (c.imageUrl ? '<img class="thumb" src="' + esc(c.imageUrl) + '" alt="">' : '') + '<span class="mono muted" style="font-size:11px">' + c.width + 'x' + c.height + '</span>' : c.type === 'text' ? '<b>' + esc(c.title) + '</b><br><span class="muted" style="font-size:12px">' + esc(c.body || '') + '</span>' : '<span class="muted">full page' + (c.type === 'login' && c.expires ? '<br><span style="font-size:12px">' + (c.expires > Date.now() ? 'slot ends ' : 'ended ') + new Date(c.expires).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) + '</span>' : '') + '</span>'; const cr = c => c.status === 'queued' ? qCell(c) : c.status === 'cancelled' ? '<span class="muted">full page<br><span style="font-size:12px">' + fmt(c.refunded || 0) + ' credits refunded</span></span>' : c.type === 'banner' ? (c.imageUrl ? '<img class="thumb" src="' + esc(c.imageUrl) + '" alt="">' : '') + '<span class="mono muted" style="font-size:11px">' + c.width + 'x' + c.height + '</span>' : c.type === 'text' ? '<b>' + esc(c.title) + '</b><br><span class="muted" style="font-size:12px">' + esc(c.body || '') + '</span>' : '<span class="muted">full page' + (c.type === 'login' && c.expires ? '<br><span style="font-size:12px">' + (c.expires > Date.now() ? 'slot ends ' : 'ended ') + new Date(c.expires).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) + '</span>' : '') + '</span>';
$('rows').innerHTML = cs.length ? cs.map(c => '<div class="rw st-row" data-st="' + stKey(c) + '"><div><b>' + esc(c.name) + '</b> <span class="tag t">' + esc(c.type) + '</span>' + (c.audience ? ' <span class="tag plain" title="audience">' + esc((((D && D.audiences) || []).find(a => a.id === c.audience) || {}).name || 'audience') + (c.audienceMode === 'exclude' ? ' · excluded' : '') + '</span>' : '') + '<br><span class="mono muted" style="font-size:11px">#' + c.id + ' · ' + esc(host(c.targetUrl)) + (c.geo ? ' · tiers ' + esc(c.geo) : '') + (c.dailyCap ? ' · cap ' + c.dailyCap + '/day' : '') + '</span></div><div>' + cr(c) + '</div><div><span class="num">' + fmt(c.status === 'cancelled' ? 0 : c.spent) + '</span><span class="muted"> / ' + fmt(c.budget) + (c.status === 'queued' ? ' paid' : '') + '</span><div class="bar st"><i style="width:' + (c.status === 'cancelled' ? 0 : Math.min(100, Math.round(100 * c.spent / Math.max(1, c.budget)))) + '%"></i></div></div><span class="r num">' + fmt(c.imps) + (c.impsNas ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsNas) + ' network</span>' : '') + '</span><span class="r num">' + fmt(c.clicks) + '</span><span>' + st(c) + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap">' $('rows').innerHTML = cs.length ? cs.map(c => '<div class="rw st-row" data-st="' + stKey(c) + '"><div><b>' + esc(c.name) + '</b> <span class="tag t">' + esc(c.type) + '</span>' + (c.audience ? ' <span class="tag plain" title="audience">' + esc((((D && D.audiences) || []).find(a => a.id === c.audience) || {}).name || 'audience') + (c.audienceMode === 'exclude' ? ' · excluded' : '') + '</span>' : '') + '<br><span class="mono muted" style="font-size:11px">#' + c.id + ' · ' + esc(host(c.targetUrl)) + (c.geo ? ' · tiers ' + esc(c.geo) : '') + (c.dailyCap ? ' · cap ' + c.dailyCap + '/day' : '') + '</span></div><div>' + cr(c) + '</div><div><span class="num">' + fmt(c.status === 'cancelled' ? 0 : c.spent) + '</span><span class="muted"> / ' + fmt(c.budget) + (c.status === 'queued' ? ' paid' : '') + '</span><div class="bar st"><i style="width:' + (c.status === 'cancelled' ? 0 : Math.min(100, Math.round(100 * c.spent / Math.max(1, c.budget)))) + '%"></i></div></div><span class="r num">' + fmt(c.imps) + offTxt(c) + '</span><span class="r num">' + fmt(c.clicks) + '</span><span>' + st(c) + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap">'
+ (c.status === 'active' ? '<button class="btn sm" type="button" data-pause="' + c.id + '">Pause</button>' : c.status === 'paused' ? '<button class="btn sm" type="button" data-resume="' + c.id + '">Resume</button>' : '') + (c.status === 'active' ? '<button class="btn sm" type="button" data-pause="' + c.id + '">Pause</button>' : c.status === 'paused' ? '<button class="btn sm" type="button" data-resume="' + c.id + '">Resume</button>' : '')
+ (['active', 'paused', 'out'].includes(c.status) && c.type !== 'login' ? '<button class="btn sm" type="button" data-top="' + c.id + '">Top up</button>' : '') + (['active', 'paused', 'out'].includes(c.status) && c.type !== 'login' ? '<button class="btn sm" type="button" data-top="' + c.id + '">Top up</button>' : '')
+ (c.status === 'queued' ? '<button class="btn sm" type="button" data-qcancel="' + c.id + '" title="Leave the line: the ' + fmt(c.budget) + ' credits you paid come back in full">Cancel and refund</button>' : '') + (c.status === 'queued' ? '<button class="btn sm" type="button" data-qcancel="' + c.id + '" title="Leave the line: the ' + fmt(c.budget) + ' credits you paid come back in full">Cancel and refund</button>' : '')
+ (!['done', 'cancelled'].includes(c.status) ? '<button class="btn sm" type="button" data-edit="' + c.id + '" title="' + (c.edits ? 'Edit the link, ' + (c.type === 'banner' ? 'image' : c.type === 'text' ? 'text' : 'name') + ' (' + fmt(D.editFee) + ' credits)' : 'Fix the link, ' + (c.type === 'banner' ? 'image' : c.type === 'text' ? 'text' : 'name') + ' (first edit free)') + '">Edit</button>' : '') + '</span></div>').join('') + (!['done', 'cancelled'].includes(c.status) ? '<button class="btn sm" type="button" data-edit="' + c.id + '" title="' + (c.edits ? 'Edit the link, ' + (c.type === 'banner' ? 'image' : c.type === 'text' ? 'text' : 'name') + ' (' + fmt(D.editFee) + ' credits)' : 'Fix the link, ' + (c.type === 'banner' ? 'image' : c.type === 'text' ? 'text' : 'name') + ' (first edit free)') + '">Edit</button>' : '') + '</span></div>').join('')
: '<div class="rw"><span class="muted">No ads yet. Launch one: a banner, a text ad or a login-ad slot.</span></div>'; : '<div class="rw"><span class="muted">No ads yet. Launch one: a banner, a text ad or a login-ad slot.</span></div>';
if (D.gauntletPending) $('earnNote').insertAdjacentHTML('afterend', '<div class="muted" style="margin-top:8px">Your welcome credits unlock after the short welcome tour on <a href="/tools">the classic dashboard</a>.</div>'); if (D.gauntletPending) $('earnNote').insertAdjacentHTML('afterend', '<div class="muted" style="margin-top:8px">Your welcome credits unlock after the short welcome tour on <a href="/tools">the classic dashboard</a>.</div>');
$('foot').textContent = 'views = timed views in the ad viewer plus member zones; network = the partner ad network · a paused ad keeps its credits · unspent credits return when an ad ends'; $('foot').textContent = 'views = views here on LinkSpin; network = the partner ad network; partner zones = other members\u2019 zones on their own sites' + (synN0 > 1 ? ' (network and partner-zone views cost 1/' + synN0 + ' of the rate here, so ' + synN0 + ' of them cost what 1 view here does' + (synT !== synN0 ? '; text ads 1/' + synT : '') + ')' : '') + ' · a paused ad keeps its credits · unspent credits return when an ad ends';
$('rows').querySelectorAll('[data-pause]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.pause + '/pause'))); $('rows').querySelectorAll('[data-pause]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.pause + '/pause')));
$('rows').querySelectorAll('[data-resume]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.resume + '/resume'))); $('rows').querySelectorAll('[data-resume]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.resume + '/resume')));
$('rows').querySelectorAll('[data-top]').forEach(b => b.addEventListener('click', async () => { const v = await dialog({ title: 'Top up #' + b.dataset.top, text: 'Add credits to this ad. You have ' + fmt(D.availableCredits) + ' available.', fields: [{ k: 'credits', label: 'Credits to add', value: '25', mono: true }], ok: 'Add' }); if (!v) return; try { await api('/api/my/campaigns/' + b.dataset.top + '/topup', { credits: Number(v.credits) }); toast('Topped up.'); load(); } catch (e) { toast(e.message, true); } })); // An ad pays from ONE position (the contract burns from that member id). When the ad's own position cannot
// cover a top-up but another of the member's positions can, the server says so (switchOptions) and the member
// can move the ad to that position and pay from there (Michael Camire 2026-11-14, ported from InstantAdPay).
const topUpReq = async (id, credits, switchTo) => (await fetch('/api/my/campaigns/' + id + '/topup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(switchTo ? { credits, switchTo } : { credits }) })).json();
$('rows').querySelectorAll('[data-top]').forEach(b => b.addEventListener('click', async () => {
const multi = (D.positionCount || 0) > 1;
const v = await dialog({ title: 'Top up #' + b.dataset.top, text: 'Add credits to this ad. You have ' + fmt(D.availableCredits) + ' available' + (multi ? ' across your positions; an ad pays from one position' : '') + '.', fields: [{ k: 'credits', label: 'Credits to add', value: '25', mono: true }], ok: 'Add' }); if (!v) return;
const credits = Number(v.credits);
try {
let r = await topUpReq(b.dataset.top, credits);
if (r.error && r.switchOptions && r.switchOptions.length) {
const o = r.switchOptions[0];
const ok = await dialog({ title: 'Pay from position #' + o.memberId + '?', text: r.error + ' Move this ad to position #' + o.memberId + ' (' + fmt(o.free) + ' free) and add the ' + fmt(credits) + ' credits from there? Views from now on are paid from #' + o.memberId + '; what the ad already ran up stays on its old position.', ok: 'Pay from #' + o.memberId });
if (!ok) return;
r = await topUpReq(b.dataset.top, credits, o.memberId);
}
if (r.error) throw new Error(r.error);
toast('Topped up: ' + fmt(r.added) + ' credits added' + (r.paidFrom ? ', paid from position #' + r.paidFrom : '') + (r.reactivated ? '. The ad is live again.' : '.')); load();
} catch (e) { toast(e.message, true); }
}));
$('rows').querySelectorAll('[data-qcancel]').forEach(b => b.addEventListener('click', () => cancelReservation(Number(b.dataset.qcancel)))); $('rows').querySelectorAll('[data-qcancel]').forEach(b => b.addEventListener('click', () => cancelReservation(Number(b.dataset.qcancel))));
$('rows').querySelectorAll('[data-edit]').forEach(b => b.addEventListener('click', () => openEdit(Number(b.dataset.edit)))); $('rows').querySelectorAll('[data-edit]').forEach(b => b.addEventListener('click', () => openEdit(Number(b.dataset.edit))));
{ const w = $('loginWhere'); if (w) w.textContent = 'full screen to every member right after they sign in: ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day slot, ' + slotInfo().max + ' slots at a time. When all are taken, reserve the next one: pay now, it starts when a slot frees, and a cancel before then refunds in full'; } { const w = $('loginWhere'); if (w) w.textContent = 'full screen to every member right after they sign in: ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day slot, ' + slotInfo().max + ' slots at a time. When all are taken, reserve the next one: pay now, it starts when a slot frees, and a cancel before then refunds in full'; }
@@ -125,18 +148,26 @@
window.addEventListener('storage', e => { if (e.key === 'iap-view-done') earnRefresh(); }); window.addEventListener('storage', e => { if (e.key === 'iap-view-done') earnRefresh(); });
$('earnClaim').addEventListener('click', async () => { try { const r = await api('/api/my/claim', {}); toast('+' + r.credited + ' credits' + (r.streakDay > 1 ? ', streak day ' + r.streakDay : '') + '. Spend them on an ad.'); load(); } catch (e) { toast(e.message, true); } }); $('earnClaim').addEventListener('click', async () => { try { const r = await api('/api/my/claim', {}); toast('+' + r.credited + ' credits' + (r.streakDay > 1 ? ', streak day ' + r.streakDay : '') + '. Spend them on an ad.'); load(); } catch (e) { toast(e.message, true); } });
// -- composer // -- composer
function setType(t) { TYPE = t; document.querySelectorAll('#typeChips .chip').forEach(c => c.classList.toggle('on', c.dataset.t === t)); $('typeNote').textContent = t === 'login' ? loginNote() : NOTE[t]; $('bannerFields').hidden = t !== 'banner'; $('textFields').hidden = t !== 'text'; $('fCap').parentElement.hidden = t === 'login'; function setType(t) { TYPE = t; document.querySelectorAll('#typeChips .chip').forEach(c => c.classList.toggle('on', c.dataset.t === t)); $('typeNote').textContent = t === 'login' ? loginNote() : NOTE[t]; $('bannerFields').hidden = t !== 'banner'; $('textFields').hidden = t !== 'text'; $('aiRow').hidden = t !== 'text' || !AIW; $('fCap').parentElement.hidden = t === 'login';
const L = slotInfo(), full = t === 'login' && !L.free; const fb = $('fBudget'); const L = slotInfo(), full = t === 'login' && !L.free; const fb = $('fBudget');
if (t === 'login') { fb.dataset.keep = fb.dataset.keep || fb.value; fb.value = L.credits; fb.readOnly = true; } else { if (fb.readOnly && fb.dataset.keep) fb.value = fb.dataset.keep; delete fb.dataset.keep; fb.readOnly = false; } if (t === 'login') { fb.dataset.keep = fb.dataset.keep || fb.value; fb.value = L.credits; fb.readOnly = true; } else { if (fb.readOnly && fb.dataset.keep) fb.value = fb.dataset.keep; delete fb.dataset.keep; fb.readOnly = false; }
$('fGo').disabled = false; $('fGo').textContent = full ? 'Reserve the next slot' : 'Launch'; $('fGo').title = full ? 'All login-ad slots are taken: pay now for a place in line' : ''; $('fGo').disabled = false; $('fGo').textContent = full ? 'Reserve the next slot' : 'Launch'; $('fGo').title = full ? 'All login-ad slots are taken: pay now for a place in line' : '';
cost(); preview(); } cost(); preview(); }
// a login slot is paid from ONE position (2026-11-04): say what each position has free and stop the buy up front when none covers it
const loginShort = () => { const F = D && D.loginFunds; return !!(F && F.best < slotInfo().credits); };
function fundsLine() { const F = D && D.loginFunds; if (!F) return ''; const L = slotInfo();
const per = (F.per || []).length > 1 ? ' (' + F.per.map(x => '#' + x.memberId + ': ' + fmt(x.avail)).join(', ') + ')' : '';
return '<span style="display:block;line-height:1.7;margin-top:4px' + (loginShort() ? ';color:var(--bad,#c0392b)' : '') + '">Paid from one position. '
+ (loginShort() ? 'None of yours has <b>' + fmt(L.credits) + '</b> purchased credits free on its own' + per + '. Buy a package on one position to bring it to ' + fmt(L.credits) + ', then come back.'
: 'Your best-funded position has <b>' + fmt(F.best) + '</b> purchased credits free' + per + '.') + '</span>'; }
function fundsGate() { if (TYPE !== 'login') return; const b = $('fGo'); b.disabled = loginShort(); if (loginShort()) b.title = 'No single position has ' + fmt(slotInfo().credits) + ' purchased credits free'; }
function slotChip() { const ch = document.querySelector('#typeChips .chip[data-t="login"]'); if (!ch || !D) return; const L = slotInfo(); ch.textContent = 'Login ad' + (L.free ? ' (' + L.free + ' of ' + L.max + ' open)' : ' (full, reserve the next)'); } function slotChip() { const ch = document.querySelector('#typeChips .chip[data-t="login"]'); if (!ch || !D) return; const L = slotInfo(); ch.textContent = 'Login ad' + (L.free ? ' (' + L.free + ' of ' + L.max + ' open)' : ' (full, reserve the next)'); }
function cost() { const b = Math.floor(Number($('fBudget').value) || 0); const r = D ? D.rates : {}; let s = ''; function cost() { const b = Math.floor(Number($('fBudget').value) || 0); const r = D ? D.rates : {}; let s = '';
if (TYPE === 'banner') s = 'about ' + fmt(Math.floor(b / (r.bannerCreditsPerBatch || 2) * (r.bannerBatch || 10))) + ' timed views'; if (TYPE === 'banner') s = 'about ' + fmt(Math.floor(b / (r.bannerCreditsPerBatch || 2) * (r.bannerBatch || 10))) + ' timed views';
else if (TYPE === 'text') s = 'about ' + fmt(Math.floor(b / (r.textCreditsPerBatch || 1) * (r.textBatch || 10))) + ' timed views'; else if (TYPE === 'text') s = 'about ' + fmt(Math.floor(b / (r.textCreditsPerBatch || 1) * (r.textBatch || 10))) + ' timed views';
else { const L = slotInfo(); $('fCost').innerHTML = L.free else { const L = slotInfo(); $('fCost').innerHTML = (L.free
? '<b>' + fmt(L.credits) + '</b> purchased credits for <b>' + L.days + '</b> days of unlimited sign-in impressions · <b>' + L.free + '</b> of ' + L.max + ' slots open' ? '<b>' + fmt(L.credits) + '</b> purchased credits for <b>' + L.days + '</b> days of unlimited sign-in impressions · <b>' + L.free + '</b> of ' + L.max + ' slots open'
: '<span style="display:block;line-height:1.7">All <b>' + L.max + '</b> login-ad slots are taken' + (L.queued ? ', <b>' + L.queued + '</b> paid reservation' + (L.queued === 1 ? '' : 's') + ' in line' : '') + '. Reserve the next one: <b>' + fmt(L.credits) + '</b> purchased credits now and you would be <b>#' + nextPlace().place + '</b> in line. ' + esc(estText(nextPlace().estStartCt)) + ' Cancel before it starts for a full refund.</span>'; return; } : '<span style="display:block;line-height:1.7">All <b>' + L.max + '</b> login-ad slots are taken' + (L.queued ? ', <b>' + L.queued + '</b> paid reservation' + (L.queued === 1 ? '' : 's') + ' in line' : '') + '. Reserve the next one: <b>' + fmt(L.credits) + '</b> purchased credits now and you would be <b>#' + nextPlace().place + '</b> in line. ' + esc(estText(nextPlace().estStartCt)) + ' Cancel before it starts for a full refund.</span>') + fundsLine(); fundsGate(); return; }
$('fCost').innerHTML = b >= 10 ? s.replace(/(about )([\d,]+)/, '$1<b>$2</b>') : 'minimum <b>10</b> credits'; } $('fCost').innerHTML = b >= 10 ? s.replace(/(about )([\d,]+)/, '$1<b>$2</b>') : 'minimum <b>10</b> credits'; }
function preview() { const p = $('prev'); if (TYPE === 'banner' && IMG) { const sz = ($('fSize').value || '728x90').split('x'); p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><img src="' + esc(IMG) + '" alt="" style="max-width:100%;width:' + sz[0] + 'px;height:auto;border:1px solid var(--chrome-line);background:var(--inset)">'; } function preview() { const p = $('prev'); if (TYPE === 'banner' && IMG) { const sz = ($('fSize').value || '728x90').split('x'); p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><img src="' + esc(IMG) + '" alt="" style="max-width:100%;width:' + sz[0] + 'px;height:auto;border:1px solid var(--chrome-line);background:var(--inset)">'; }
else if (TYPE === 'text') p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><div class="panel" style="max-width:420px"><b>' + esc($('fTitle').value || 'Your headline') + '</b><br><span class="ink2">' + esc($('fBody').value || 'One line under it.') + '</span><br><span class="mono muted" style="font-size:11px">' + esc(host($('fTarget').value || 'yoursite.com')) + '</span></div>'; else if (TYPE === 'text') p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><div class="panel" style="max-width:420px"><b>' + esc($('fTitle').value || 'Your headline') + '</b><br><span class="ink2">' + esc($('fBody').value || 'One line under it.') + '</span><br><span class="mono muted" style="font-size:11px">' + esc(host($('fTarget').value || 'yoursite.com')) + '</span></div>';
@@ -154,6 +185,23 @@
setType(TYPE); setType(TYPE);
}); });
$('fCancel').addEventListener('click', () => { $('composer').hidden = true; }); $('fCancel').addEventListener('click', () => { $('composer').hidden = true; });
// the AI ad writer (Marty 2026-11-17): 3 text ads the network hub writes only from the member's own page; picking one fills the
// headline and line to edit. Shown only when the hub answers it is on.
CR.get('/api/my/adwriter').then(w => { AIW = !!(w && w.on); if (!$('composer').hidden) setType(TYPE); }).catch(() => { AIW = false; });
{ let opts = [];
$('aiWrite').addEventListener('click', async () => {
const box = $('aiList'), url = $('fTarget').value.trim(); box.hidden = false;
if (!/^https?:\/\/\S+\.\S+/i.test(url)) { box.innerHTML = '<span class="muted">Put your link in Where the click goes first (starting with https://), or pick a spin link, then tap the button again.</span>'; $('fTarget').focus(); return; }
$('aiWrite').disabled = true; box.innerHTML = '<span class="muted">Reading your page and writing 3 ads. This takes a few seconds...</span>';
let r; try { r = await api('/api/my/adwriter', { url, kind: 'text' }); } catch (e) { r = { error: e.message || 'The ad writer did not answer. Try again in a minute.' }; }
$('aiWrite').disabled = false;
if (r.error) { box.innerHTML = '<span class="bad">' + esc(r.error) + '</span>'; return; }
opts = r.options || [];
box.innerHTML = '<div class="muted" style="font-size:12px;margin-bottom:6px">Tap one to use it. Check every word is true for your offer before you launch.' + (typeof r.left === 'number' ? ' Ad writes left today: ' + r.left + '.' : '') + '</div>'
+ opts.map((o, i) => '<button type="button" class="btn ghost" data-ai="' + i + '" style="display:block;width:100%;text-align:left;margin:0 0 6px;white-space:normal;height:auto"><b>' + esc(o.headline) + '</b><br><span class="ink2">' + esc(o.line || '') + '</span></button>').join('');
box.querySelectorAll('button[data-ai]').forEach(b => b.addEventListener('click', () => { const o = opts[Number(b.dataset.ai)]; $('fTitle').value = o.headline; $('fBody').value = o.line || ''; box.hidden = true; preview(); toast('Filled in. Edit it as you like, then tap Launch.'); }));
});
}
$('fGo').addEventListener('click', async () => { $('fGo').addEventListener('click', async () => {
const body = { type: TYPE, name: $('fName').value, targetUrl: $('fTarget').value.trim(), budget: Number($('fBudget').value), geo: $('fGeo').value }; const body = { type: TYPE, name: $('fName').value, targetUrl: $('fTarget').value.trim(), budget: Number($('fBudget').value), geo: $('fGeo').value };
if (TYPE !== 'login' && $('fCap').value) body.dailyCap = Number($('fCap').value); if (TYPE !== 'login' && $('fCap').value) body.dailyCap = Number($('fCap').value);
@@ -169,7 +217,10 @@
$('fGo').disabled = true; $('fGo').disabled = true;
try { const r = await api('/api/my/campaigns', body); const c = r.campaign || {}; try { const r = await api('/api/my/campaigns', body); const c = r.campaign || {};
toast(c.status === 'queued' ? 'Reserved and paid. You are #' + (c.place || '?') + ' in line. We let you know when it starts.' : TYPE === 'login' ? 'Launched. Your login-ad slot runs for ' + slotInfo().days + ' days.' : 'Launched. It is live in rotation now.'); toast(c.status === 'queued' ? 'Reserved and paid. You are #' + (c.place || '?') + ' in line. We let you know when it starts.' : TYPE === 'login' ? 'Launched. Your login-ad slot runs for ' + slotInfo().days + ' days.' : 'Launched. It is live in rotation now.');
$('composer').hidden = true; $('fName').value = ''; load(); } catch (e) { toast(e.message, true); } finally { $('fGo').disabled = false; } $('composer').hidden = true; $('fName').value = ''; load(); } catch (e) {
// a login-ad failure stays on screen until read (the 2-second toast was missed, 2026-11-03)
if (TYPE === 'login') await dialog({ title: body.reserve ? 'Your reservation did not go through' : 'Your login ad did not launch', text: e.message, ok: 'OK', no: 'Close' }); else toast(e.message, true);
} finally { $('fGo').disabled = false; fundsGate(); }
}); });
CR.requireSession(load); CR.requireSession(load);
})(); })();
+10 -5
View File
@@ -65,6 +65,10 @@
$('bsHoursChip').textContent = LSHours.chip(s.hours, s.tz); $('bsHoursChip').classList.toggle('set', !!s.hours); $('bsHoursChip').textContent = LSHours.chip(s.hours, s.tz); $('bsHoursChip').classList.toggle('set', !!s.hours);
$('bsOffNote').hidden = !s.adminOff; if (s.adminOff) $('bsOffNote').textContent = 'LinkSpin took this Banner Spin offline' + (s.adminNote ? ' (' + s.adminNote + ')' : '') + '. Placements show a blank image and clicks go to the fallback. Ask on Help if you think this is a mistake.'; $('bsOffNote').hidden = !s.adminOff; if (s.adminOff) $('bsOffNote').textContent = 'LinkSpin took this Banner Spin offline' + (s.adminNote ? ' (' + s.adminNote + ')' : '') + '. Placements show a blank image and clicks go to the fallback. Ask on Help if you think this is a mistake.';
renderTiles(s, STATS[id]); renderBanners(s); renderSettings(s); renderCodes(s); renderAddLimit(s); renderTiles(s, STATS[id]); renderBanners(s); renderSettings(s); renderCodes(s); renderAddLimit(s);
// the Add a banner frame follows the selected spin's size (Marty 11-05: it kept the first spin's 728x90); a pick made
// for another spin is dropped so it is never checked or uploaded against the wrong size
if (PEND && PEND.spin !== id) { PEND = null; $('bsFile').value = ''; $('bsImgUrl').value = ''; }
if (!PEND) preview($('bsPrev'), s, null);
if (!quiet) window.scrollTo({ top: 0 }); if (!quiet) window.scrollTo({ top: 0 });
loadStats(id); loadStats(id);
} }
@@ -151,8 +155,8 @@
if (r.error) throw new Error(r.error); return r; if (r.error) throw new Error(r.error); return r;
} }
// add a banner: upload first when a file is chosen, then save // add a banner: upload first when a file is chosen, then save
$('bsFile').addEventListener('change', () => { const s = cur(); if (!s) return; $('bsImgUrl').value = ''; PEND = PEND || {}; pickFile($('bsFile'), $('bsPrev'), s, PEND); }); $('bsFile').addEventListener('change', () => { const s = cur(); if (!s) return; $('bsImgUrl').value = ''; PEND = PEND || {}; PEND.spin = s.id; pickFile($('bsFile'), $('bsPrev'), s, PEND); });
$('bsImgUrl').addEventListener('change', async () => { const s = cur(); if (!s) return; $('bsFile').value = ''; PEND = { url: $('bsImgUrl').value.trim() }; PEND.d = await preview($('bsPrev'), s, PEND.url || null); PEND.ok = !!PEND.d; }); $('bsImgUrl').addEventListener('change', async () => { const s = cur(); if (!s) return; $('bsFile').value = ''; PEND = { url: $('bsImgUrl').value.trim(), spin: s.id }; PEND.d = await preview($('bsPrev'), s, PEND.url || null); PEND.ok = !!PEND.d; });
$('bsTgtKind').addEventListener('change', () => { $('bsTgtUrlWrap').hidden = $('bsTgtKind').value !== 'url'; }); $('bsTgtKind').addEventListener('change', () => { $('bsTgtUrlWrap').hidden = $('bsTgtKind').value !== 'url'; });
$('bsAddBtn').addEventListener('click', async () => { $('bsAddBtn').addEventListener('click', async () => {
const s = cur(); if (!s) return; const P = PEND || {}; const s = cur(); if (!s) return; const P = PEND || {};
@@ -222,10 +226,11 @@
if (SEL !== id) return; const s = cur(); if (s) renderTiles(s, st); if (SEL !== id) return; const s = cur(); if (s) renderTiles(s, st);
// seven columns: name, views, second number (uniques for a banner, every image load for a placement), clicks, CTR, matched, last // seven columns: name, views, second number (uniques for a banner, every image load for a placement), clicks, CTR, matched, last
const cell = (label, v) => '<span class="r num"><span class="ml">' + label + ' </span>' + v + '</span>'; const cell = (label, v) => '<span class="r num"><span class="ml">' + label + ' </span>' + v + '</span>';
const row = (name, o, second, secondLabel, last, lastLabel) => '<div class="rw"><span style="overflow-wrap:anywhere">' + name + '</span>' + cell('Views', fmt(o.imps)) + cell(secondLabel, second == null ? '-' : fmt(second)) + cell('Clicks', fmt(o.clicks)) const row = (name, o, second, secondLabel, last, lastLabel) => '<div class="rw"><span style="overflow-wrap:anywhere">' + name + '</span>' + cell('Views', o.imps == null ? '-' : fmt(o.imps)) + cell(secondLabel, second == null ? '-' : fmt(second)) + cell('Clicks', fmt(o.clicks))
+ cell('CTR', o.ctr == null ? '-' : o.ctr + '%') + cell('Matched', o.matchRate == null ? '-' : o.matchRate + '%') + '<span class="r num">' + (last == null ? '' : (lastLabel ? '<span class="ml">' + lastLabel + ' </span>' : '') + last) + '</span></div>'; + cell('CTR', o.ctr == null ? '-' : o.ctr + '%') + cell('Matched', o.matchRate == null ? '-' : o.matchRate + '%') + '<span class="r num">' + (last == null ? '' : (lastLabel ? '<span class="ml">' + lastLabel + ' </span>' : '') + last) + '</span></div>';
$('bsStB').innerHTML = st.banners.length ? st.banners.map(b => row('<img src="' + esc(b.image) + '" alt="" style="max-height:28px;max-width:120px;vertical-align:middle;margin-right:6px" referrerpolicy="no-referrer">' + esc(b.label || 'Banner ' + b.id) + (b.winner ? '<span class="bswin" data-winner="' + b.id + '">WINNER</span>' : ''), b, b.uniques, 'Unique', fmt(b.conversions), 'Conv')).join('') $('bsStB').innerHTML = st.banners.length ? st.banners.map(b => row('<img src="' + esc(b.image) + '" alt="" style="max-height:28px;max-width:120px;vertical-align:middle;margin-right:6px" referrerpolicy="no-referrer">' + esc(b.label || 'Banner ' + b.id) + (b.winner ? '<span class="bswin" data-winner="' + b.id + '">WINNER</span>' : ''), b, b.uniques, 'Unique', fmt(b.conversions), 'Conv')).join('')
+ (st.fallback.imps || st.fallback.clicks ? row('<span class="muted">Fallback</span>', Object.assign({ matchRate: null }, st.fallback), null, 'Unique', null) : '') : '<div class="rw"><span class="muted">No banners yet.</span></div>'; + (st.fallback.imps || st.fallback.clicks ? row('<span class="muted">Fallback shown</span>', Object.assign({ matchRate: null }, st.fallback), null, 'Unique', null) : '')
+ (st.unmatched && st.unmatched.clicks ? row('<span class="muted" title="The click came in, but no view of this Banner Spin from that visitor was on record, so we cannot say which banner they saw. These clicks went to your fallback link.">Clicks not tied to a banner</span>', { imps: null, clicks: st.unmatched.clicks, ctr: null, matchRate: null }, null, 'Unique', null) : '') : '<div class="rw"><span class="muted">No banners yet.</span></div>';
const wm = st.winMin || 1000; const wm = st.winMin || 1000;
$('bsWinNote').textContent = st.winner ? 'WINNER = the best click rate among banners with at least ' + fmt(wm) + ' views each. LinkSpin never changes the weights for you: raise the winner or pause the rest when you are ready.' : 'A WINNER badge appears once two or more live banners have ' + fmt(wm) + ' views each and one leads on click rate. Unique viewers are counted per day from a sample.'; $('bsWinNote').textContent = st.winner ? 'WINNER = the best click rate among banners with at least ' + fmt(wm) + ' views each. LinkSpin never changes the weights for you: raise the winner or pause the rest when you are ready.' : 'A WINNER badge appears once two or more live banners have ' + fmt(wm) + ' views each and one leads on click rate. Unique viewers are counted per day from a sample.';
$('bsStP').innerHTML = st.placements.length ? st.placements.map(p => row(esc(p.host === '(none)' ? 'No referrer (email, apps, privacy settings)' : p.host) + (p.caches ? '<span class="bscache" data-caches="' + esc(p.host) + '"><b>Caches banners:</b> ' + esc(p.caches) + '</span>' : ''), p, p.loads, 'Loads', p.caches ? '<span class="tag warn" title="' + esc(p.caches) + '">CACHED</span>' : '', '')).join('') : '<div class="rw"><span class="muted">No views yet. Put the code on a page and load it.</span></div>'; $('bsStP').innerHTML = st.placements.length ? st.placements.map(p => row(esc(p.host === '(none)' ? 'No referrer (email, apps, privacy settings)' : p.host) + (p.caches ? '<span class="bscache" data-caches="' + esc(p.host) + '"><b>Caches banners:</b> ' + esc(p.caches) + '</span>' : ''), p, p.loads, 'Loads', p.caches ? '<span class="tag warn" title="' + esc(p.caches) + '">CACHED</span>' : '', '')).join('') : '<div class="rw"><span class="muted">No views yet. Put the code on a page and load it.</span></div>';
@@ -236,7 +241,7 @@
$('bsDayBars').style.gridTemplateColumns = 'repeat(' + Math.max(1, days.length) + ',minmax(0,1fr))'; $('bsDayBars').style.gridTemplateColumns = 'repeat(' + Math.max(1, days.length) + ',minmax(0,1fr))';
$('bsDayBars').innerHTML = days.map(d => '<i style="height:' + Math.round(d.imps / dmax * 100) + '%" title="' + d.day + ' · ' + d.imps + ' views, ' + d.clicks + ' clicks, ' + ((d.bots || 0) + (d.servers || 0)) + ' bot or server loads"></i>').join(''); $('bsDayBars').innerHTML = days.map(d => '<i style="height:' + Math.round(d.imps / dmax * 100) + '%" title="' + d.day + ' · ' + d.imps + ' views, ' + d.clicks + ' clicks, ' + ((d.bots || 0) + (d.servers || 0)) + ' bot or server loads"></i>').join('');
$('bsDayAxis').innerHTML = days.length ? '<span>' + days[0].day + '</span><span>' + days[days.length - 1].day + '</span>' : '<span class="muted">no views recorded yet</span>'; $('bsDayAxis').innerHTML = days.length ? '<span>' + days[0].day + '</span><span>' + days[days.length - 1].day + '</span>' : '<span class="muted">no views recorded yet</span>';
const t = st.totals; $('bsStNote').textContent = 'Views are counted on the server: bots and link previews are left out and one visitor reloading counts once a minute per banner. Matched = clicks we could tie to the banner that visitor saw (' + fmt(t.matched) + ' matched, ' + fmt(t.unmatched) + ' went to the fallback). About ' + fmt(t.uniquesSampled) + ' unique visitors (sampled).'; const t = st.totals; $('bsStNote').textContent = 'Views are counted on the server: bots and link previews are left out and one visitor reloading counts once a minute per banner. Matched = clicks we could tie to the banner that visitor saw (' + fmt(t.matched) + ' matched, ' + fmt(t.unmatched) + ' could not be tied to a banner and went to the fallback; they are the "Clicks not tied to a banner" row). A click is tied to a banner when a view of it by that visitor is on record from the last hour, from the same browser or the same internet connection; the script embed always ties it. About ' + fmt(t.uniquesSampled) + ' unique visitors (sampled).';
} }
// ── header actions ── // ── header actions ──
+69 -4
View File
@@ -27,7 +27,7 @@ window.IAP = (function () {
const c = await getConfig(); const c = await getConfig();
const nav = document.createElement('nav'); const nav = document.createElement('nav');
nav.innerHTML = '<div class="wrap">' nav.innerHTML = '<div class="wrap">'
+ '<span class="logo-wrap"><a class="logo" href="/"><span class="wordmark"><svg viewBox="0 0 24 24" fill="none" stroke="#8cc8ff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12a8 8 0 0 1 14-5.3"/><path d="M18 3v4h-4"/><path d="M20 12a8 8 0 0 1-14 5.3"/><path d="M6 21v-4h4"/></svg>Link<b>Spin</b></span></a><span class="byline">Brought to you by the <b>Crypto Team Build Network</b></span></span>' + '<span class="logo-wrap"><a class="logo" href="/"><span class="wordmark"><svg viewBox="0 0 24 24" fill="none" style="stroke:var(--mint-hi)" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12a8 8 0 0 1 14-5.3"/><path d="M18 3v4h-4"/><path d="M20 12a8 8 0 0 1-14 5.3"/><path d="M6 21v-4h4"/></svg>Link<b>Spin</b></span></a><span class="byline">Brought to you by the <b>Crypto Team Build Network</b></span></span>'
+ '<span class="links">' + '<span class="links">'
+ '<a href="/#how" data-p="home">How it works</a>' + '<a href="/#how" data-p="home">How it works</a>'
+ '<a href="/#packages" data-p="pricing">Ad packages</a>' + '<a href="/#packages" data-p="pricing">Ad packages</a>'
@@ -57,9 +57,56 @@ window.IAP = (function () {
f.innerHTML = '<div>© ' + new Date().getFullYear() + ' LinkSpin</div>' f.innerHTML = '<div>© ' + new Date().getFullYear() + ' LinkSpin</div>'
+ '<div style="margin-top:8px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">' + '<div style="margin-top:8px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">'
+ '<a href="/">How it works</a><a href="/ledger">Live ledger</a><a href="/contract">The contract</a><a href="/blog">Blog</a><a href="/leaderboard">Leaderboard</a><a href="/whats-new">What\'s new</a><a href="/support">Support</a>' + '<a href="/">How it works</a><a href="/ledger">Live ledger</a><a href="/contract">The contract</a><a href="/blog">Blog</a><a href="/leaderboard">Leaderboard</a><a href="/whats-new">What\'s new</a><a href="/support">Support</a>'
+ '<a href="/terms">Terms</a><a href="/privacy">Privacy</a><a href="/disclaimer">Disclaimer</a></div>'; + '<a href="/terms">Terms</a><a href="/disclaimer">Earnings Disclaimer</a><a href="/privacy">Privacy</a></div>'
+ '<div style="margin-top:10px">© 2026 TrustClickz</div>';
document.body.appendChild(f); document.body.appendChild(f);
renderNetworkLine(f);
} }
// "Part of the network" (Marty 2026-11-14 trust pack): the list comes from the hub through /api/network-sites, built-in copy if not
const NET_FALLBACK = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] }));
let netList = null;
function networkSites() {
if (!netList) netList = fetch('/api/network-sites').then(r => r.json()).then(l => (Array.isArray(l) && l.length ? l : NET_FALLBACK)).catch(() => NET_FALLBACK);
return netList;
}
// the footer links carry a referral username (Marty 2026-11-15): the signed-in member's own, else the referral this visitor came in on
// (?ref= on this page, remembered for the visit, then the iap.sponsor join cookie; usernames only, never a member number or wallet).
// Tracked links get it as s1 (LinkSpin sends it on as ?ref=), plain links as ?ref=. Earners Corner takes none.
const okRef = v => /^[A-Za-z0-9_.-]{1,40}$/.test(v) && !/^\d+$/.test(v) && !/^0x[0-9a-f]{40}$/i.test(v) && v !== 'company' && v !== 'top';
const arrivedRef = () => {
try { const q = String(new URLSearchParams(location.search).get('ref') || '').trim().toLowerCase(); if (okRef(q)) { try { sessionStorage.setItem('ls.netref', q); } catch (e) {} return q; } } catch (e) {}
try { const v = sessionStorage.getItem('ls.netref') || ''; if (okRef(v)) return v; } catch (e) {}
const m = document.cookie.match(/(?:^|;\s*)iap\.sponsor=([^;]*)/); try { const v = m ? decodeURIComponent(m[1]) : ''; return okRef(v) ? v : ''; } catch (e) { return ''; }
};
let netRef = null;
function networkRef() {
if (!netRef) netRef = fetch('/api/me', { credentials: 'same-origin' }).then(r => r.json()).then(m => (m && m.signedIn && m.username && okRef(m.username) ? m.username : arrivedRef())).catch(() => arrivedRef());
return netRef;
}
function withRef(s, ref) {
const href = s.go || s.url; if (!ref || s.id === 'earnerscorner') return href;
try { const u = new URL(href); u.searchParams.set(s.go ? 's1' : 'ref', ref); return u.toString(); } catch (e) { return href; }
}
function renderNetworkLine(host) {
if (!host || host.querySelector('.netline')) return;
const d = document.createElement('div'); d.className = 'netline';
d.style.cssText = 'margin-top:10px;display:flex;gap:6px 14px;justify-content:center;flex-wrap:wrap;align-items:baseline;font-size:12.5px';
host.appendChild(d);
const esc = s => String(s).replace(/[&<>"]/g, ch => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[ch]);
let list = NET_FALLBACK, ref = arrivedRef();
const paint = () => {
d.innerHTML = '<b>Part of the network</b><span>One account across the network:</span>' + list.map(s => (s.id === 'linkspin' || /linkspin\.app/.test(s.url))
? '<span aria-current="page" style="font-weight:700;color:var(--ink)">' + esc(s.name) + ' (you are here)</span>'
: '<a href="' + esc(withRef(s, ref)) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>').join('');
};
paint();
networkSites().then(l => { list = l; paint(); });
networkRef().then(r => { if (r !== ref) { ref = r; paint(); } });
}
// pages with their own footer (the members area) get the network line too
function decorateFooters() { document.querySelectorAll('footer.bo-pagefoot').forEach(f => { const w = document.createElement('div'); w.style.width = '100%'; f.appendChild(w); renderNetworkLine(w); }); }
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', decorateFooters); else decorateFooters();
async function refreshNavWallet() { async function refreshNavWallet() {
try { try {
const me = await (await fetch('/api/me')).json(); const me = await (await fetch('/api/me')).json();
@@ -198,8 +245,8 @@ window.IAP = (function () {
{ key: 'wallet', title: 'Link your wallet', done: !!m.address, href: '/wallet', cta: 'Wallet', { key: 'wallet', title: 'Link your wallet', done: !!m.address, href: '/wallet', cta: 'Wallet',
how: 'Wallet tab, Connect, sign the free message. MetaMask recommended. Never held crypto? The wallet guide in Training walks through buying POL with a card.', how: 'Wallet tab, Connect, sign the free message. MetaMask recommended. Never held crypto? The wallet guide in Training walks through buying POL with a card.',
why: 'Payouts go to this address. No wallet, nowhere to pay you.' }, why: 'Payouts go to this address. No wallet, nowhere to pay you.' },
{ key: 'payouts', title: 'Switch on payouts', done: !!m.memberId, href: '/wallet', cta: 'Wallet', { key: 'payouts', title: 'Payouts switched on', done: !!m.memberId, href: '/wallet', cta: 'Wallet',
how: 'Wallet tab, one small transaction. It registers your address with the contract.', how: 'Happens by itself once your wallet is linked and you have a sponsor: LinkSpin registers your address on the contract and pays the gas. Joined with no sponsor? Tell us who invited you, or you wait in the holding tank while one is matched (up to 24 hours after you link your wallet).',
why: 'The contract binds each buyer to their sponsor at their first purchase. If payouts are off when your first person buys, that commission is not yours.' }, why: 'The contract binds each buyer to their sponsor at their first purchase. If payouts are off when your first person buys, that commission is not yours.' },
{ key: 'level2', title: 'Qualify: open level 2', done: bc >= 2, href: '/credits', cta: 'Buy packages', { key: 'level2', title: 'Qualify: open level 2', done: bc >= 2, href: '/credits', cta: 'Buy packages',
how: 'Two of your people buy a $25 or more package. Or use Qualified Start: add two positions from extra wallets in your own MetaMask and buy a $25 package from each (about $23 of POL in each wallet).', how: 'Two of your people buy a $25 or more package. Or use Qualified Start: add two positions from extra wallets in your own MetaMask and buy a $25 package from each (about $23 of POL in each wallet).',
@@ -251,3 +298,21 @@ window.IAP = (function () {
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, requestCode, launchChecks, launchToggle, ask, confirmBox, $, return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, requestCode, launchChecks, launchToggle, ask, confirmBox, $,
guard: { FORM_TS, iconCheck, hpValue, formSettled } }; // guard: the sign-up walls, reused by /support and the chat hand-off guard: { FORM_TS, iconCheck, hpValue, formSettled } }; // guard: the sign-up walls, reused by /support and the chat hand-off
})(); })();
// Network links (2026-11-13): a click on a link to InstantAdPay goes through /go/iap, which signs a signed-in member in over there and is a
// plain redirect for everyone else. Rewritten at click time only, so links people copy to share stay clean. data-nogo opts a link out.
(function () {
if (window.__netlinks) return; window.__netlinks = 1;
const HOSTS = ['instantadpay.com', 'www.instantadpay.com'];
document.addEventListener('click', e => {
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
const a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
if (!a || a.hasAttribute('download') || a.hasAttribute('data-nogo')) return;
let u; try { u = new URL(a.href); } catch (x) { return; }
if (u.protocol !== 'https:' || !HOSTS.includes(u.hostname)) return;
a.href = '/go/iap?to=' + encodeURIComponent(u.pathname + u.search + u.hash);
}, true);
})();
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub)
(function () { try { if (window.__nwRibbon || document.querySelector('script[src^="/assets/netweekend.js"]')) return; var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117a'; s.defer = true; s.setAttribute('data-site', 'linkspin'); (document.head || document.documentElement).appendChild(s); } catch (e) {} })();
+27
View File
@@ -0,0 +1,27 @@
// Conversion tracking guide (/conversion-tracking, 2026-10-24): the Copy buttons on the code examples, and inside a
// traffic-exchange frame (session and sponsor cookies are dropped there) sign-in, join, Control Room and off-site links
// open in a new tab, /join carrying the ?ref= this page was opened with (same rule as refuel-guide.js).
(function () {
function flash(b, t) { var o = b.getAttribute('data-label') || b.textContent; b.setAttribute('data-label', o); b.textContent = t; setTimeout(function () { b.textContent = o; }, 1600); }
document.querySelectorAll('[data-copy]').forEach(function (b) {
b.addEventListener('click', function () {
var box = b.closest('.cg-code'); var pre = box && box.querySelector('pre'); if (!pre) return;
var text = pre.textContent;
var fallback = function () {
try { var r = document.createRange(); r.selectNodeContents(pre); var s = window.getSelection(); s.removeAllRanges(); s.addRange(r); var ok = document.execCommand && document.execCommand('copy'); flash(b, ok ? 'Copied' : 'Selected'); }
catch (e) { flash(b, 'Select and copy'); }
};
try { if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text).then(function () { flash(b, 'Copied'); }, fallback); else fallback(); } catch (e) { fallback(); }
});
});
var framed = false; try { framed = window.top !== window.self; } catch (e) { framed = true; }
if (!framed) return;
var ref = ''; try { ref = new URLSearchParams(location.search).get('ref') || ''; } catch (e) {}
ref = String(ref).toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 40);
document.querySelectorAll('a[href]').forEach(function (a) {
var h = a.getAttribute('href') || ''; if (h.charAt(0) === '#') return;
var member = a.host === location.host && /^\/(join|credits|ads|links|sources|conversions|signin|login)(\/|$)/.test(a.pathname);
if (member && ref && a.pathname === '/join' && !/[?&]ref=/.test(a.search)) a.search = (a.search ? a.search + '&' : '?') + 'ref=' + ref;
if (member || a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; }
});
})();
+71
View File
@@ -0,0 +1,71 @@
// LinkSpin Conversions (conversion pixel, 2026-10-23): goals + pixel ids, the two snippets, a test button, and per goal the
// conversions and cost per goal by ad campaign (LinkSpin and InstantAdPay), spin link, destination and traffic source.
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
let RANGE = 30, D = null, PICK = '';
CR.mount({ active: 'conversions', title: 'Conversions', sub: 'loading', actions: '<span style="display:inline-flex;gap:8px;align-items:center"><div class="range" id="range"><button type="button" data-d="7">7d</button><button type="button" data-d="30" class="on">30d</button><button type="button" data-d="90">90d</button></div> <a class="btn" id="csvBtn" href="/api/my/conversions.csv?days=30">CSV</a></span>' });
$('range').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { RANGE = Number(b.dataset.d); $('range').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); $('csvBtn').href = '/api/my/conversions.csv?days=' + RANGE; load(); }));
const ago = ts => { if (!ts) return 'never'; const m = Math.round((Date.now() - ts) / 60000); return m < 1 ? 'just now' : m < 60 ? m + ' min ago' : m < 1440 ? Math.round(m / 60) + ' h ago' : Math.round(m / 1440) + ' d ago'; };
const money = v => v ? '$' + Number(v).toFixed(2) : '';
const METH = [['url', 'Address'], ['stored', 'Kept'], ['cookie', 'Cookie'], ['soft', '24 h match']];
function snippets() {
const g = (D.goals || []).find(x => x.px === PICK) || (D.goals || [])[0];
const base = D.base || ('https://' + (D.host || 'linkspin.app'));
if (!g) { ['snTag', 'snImg', 'snJs'].forEach(k => { $(k).textContent = 'Add a goal first. Its snippets show here.'; }); $('testBtn').disabled = true; $('testNote').textContent = ''; return; }
$('testBtn').disabled = false;
$('snTag').textContent = '<script async src="' + base + '/t.js?px=' + g.px + '"></script>';
$('snImg').textContent = '<img src="' + base + '/cv.gif?px=' + g.px + '&goal=' + g.name + '" width="1" height="1" alt="" style="display:none">';
$('snJs').textContent = '<script async src="' + base + '/cv.js?px=' + g.px + '&goal=' + g.name + '"></script>';
$('testNote').textContent = g.lastTest ? 'Last test received ' + ago(g.lastTest) : 'No test received yet';
}
function paint() {
const goals = D.goals || [];
CR.sub(RANGE + ' days · ' + goals.length + ' goal' + (goals.length === 1 ? '' : 's') + ' · ' + fmt(D.total || 0) + ' counted');
$('goalRows').innerHTML = goals.length ? goals.map(g => '<div class="rw"><span><b>' + esc(g.name) + '</b><span class="muted" style="display:block;font-size:11px">last ' + esc(ago(g.lastAt)) + (g.lastTest ? ' · test ' + esc(ago(g.lastTest)) : '') + '</span></span><span class="mono">' + esc(g.px) + '</span><span class="r num">' + (g.value ? esc(money(g.value)) : '<span class="muted">none</span>') + '</span><span class="r num">' + fmt(g.conv) + '</span><span class="r"><button class="btn sm" type="button" data-pick="' + g.px + '">Snippets</button> <button class="btn sm" type="button" data-edit="' + g.px + '">Edit</button> <button class="btn sm" type="button" data-del="' + g.px + '">Remove</button></span></div>').join('')
: '<div class="rw"><span class="muted">No goals yet. Add one, for example <b>subscriber</b> or <b>sale</b>.</span><span></span><span></span><span></span><span></span></div>';
if (!goals.some(g => g.px === PICK)) PICK = goals.length ? goals[0].px : '';
$('goalPick').innerHTML = goals.map(g => '<option value="' + g.px + '"' + (g.px === PICK ? ' selected' : '') + '>' + esc(g.name) + '</option>').join('');
snippets();
const m = D.methods || {}; const tot = METH.reduce((n, [k]) => n + (m[k] || 0), 0);
$('methRows').innerHTML = METH.map(([k, label]) => '<div class="m"><span class="k">' + label + '</span><span class="v">' + fmt(m[k] || 0) + '</span><span class="muted mono" style="font-size:11px">' + (tot ? Math.round((m[k] || 0) / tot * 100) + '%' : '·') + '</span></div>').join('');
$('totalNote').textContent = D.selfTests ? D.selfTests + ' from your own clicks (ads, spin links, Banner Spins), kept as tests and left out' : '';
$('goalReports').innerHTML = (D.byGoal || []).filter(G => G.n || !G.removed).map(G => {
const camp = G.campaigns.length ? G.campaigns.map(c => '<div class="rw"><span>' + esc(c.name || ('Campaign #' + c.id)) + '<span class="muted" style="display:block;font-size:11px">' + esc(c.site) + ' #' + c.id + (c.spentAsOf ? ' · spend as of ' + esc(ago(c.spentAsOf)) : '') + '</span></span><span class="r num">' + (c.spent != null ? fmt(c.spent) + ' cr' : '·') + '</span><span class="r num">' + fmt(c.clicks) + '</span><span class="r num">' + fmt(c.n) + '</span><span class="r num">' + (c.rate != null ? c.rate + '%' : '·') + '</span><span class="r num">' + (c.costPer != null ? fmt(c.costPer) + ' cr' : '·') + '</span></div>').join('') : '<div class="rw"><span class="muted">No ad campaign conversions for this goal yet.</span><span></span><span></span><span></span><span></span><span></span></div>';
const lst = (rows, f) => rows && rows.length ? rows.map(x => '<div class="rw"><span style="overflow-wrap:anywhere">' + f(x) + '</span><span class="r num">' + fmt(x.n) + '</span></div>').join('') : '<div class="rw"><span class="muted">nothing yet</span><span></span></div>';
const gm = G.methods || {};
return '<div class="sec">Goal: ' + esc(G.goal) + (G.removed ? ' (removed)' : '') + ' · ' + fmt(G.n) + ' counted' + (G.value ? ' · ' + esc(money(G.value)) : '') + ' · ' + METH.map(([k, l]) => l + ' ' + fmt(gm[k] || 0)).join(', ') + '</div>'
+ '<div class="panel"><h2>By ad campaign</h2><div class="tbl camps"><div class="hd"><span>Campaign</span><span class="r">Spent</span><span class="r">Clicks</span><span class="r">Goals</span><span class="r">Rate</span><span class="r">Cost / goal</span></div>' + camp + '</div><div class="muted" style="margin-top:8px">Cost per goal = the credits the campaign has spent so far / its conversions of this goal, in that site\'s ad credits. Clicks and goals are for the range above; spend is the campaign\'s total.</div></div>'
+ '<div class="two"><div class="panel"><h2>By spin link</h2><div class="tbl lst"><div class="hd"><span>Link</span><span class="r">Goals</span></div>' + lst(G.links, x => esc(x.name || x.code) + ' <span class="pill">/r/' + esc(x.code) + '</span>') + '</div></div>'
+ '<div class="panel"><h2>By destination page</h2><div class="tbl lst"><div class="hd"><span>Page</span><span class="r">Goals</span></div>' + lst(G.dests, x => '<span class="mono">' + esc(x.k) + '</span>') + '</div></div></div>'
+ '<div class="panel"><h2>By Banner Spin</h2><div class="tbl lst"><div class="hd"><span>Banner Spin</span><span class="r">Goals</span></div>' + lst(G.banners, x => esc(x.name || x.code) + ' <span class="pill">/c/' + esc(x.code) + '</span>') + '</div><div class="muted" style="margin-top:8px">Banners that point straight at a page. A banner that points at a spin link is counted under that spin link.</div></div>'
+ '<div class="panel"><h2>By traffic source</h2><div class="tbl lst"><div class="hd"><span>Source</span><span class="r">Goals</span></div>' + lst(G.sources, x => esc(x.name)) + '</div><div class="muted" style="margin-top:8px">A named source is one you set up under <a href="/sources">Sources</a>; otherwise it is the referring site or the ad placement.</div></div>';
}).join('');
$('goalRows').querySelectorAll('[data-pick]').forEach(b => b.addEventListener('click', () => { PICK = b.dataset.pick; $('goalPick').value = PICK; snippets(); $('snTag').scrollIntoView({ behavior: 'smooth', block: 'center' }); }));
$('goalRows').querySelectorAll('[data-edit]').forEach(b => b.addEventListener('click', () => goalForm(goals.find(g => g.px === b.dataset.edit))));
$('goalRows').querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async () => {
if (!await CR.dialog({ title: 'Remove this goal?', text: 'Its pixel stops counting at once. Conversions already counted stay in your reports.', ok: 'Remove', danger: true })) return;
try { await CR.api('/api/my/conversions/goals/' + b.dataset.del, { remove: true }); CR.toast('Goal removed'); load(); } catch (e) { CR.toast(e.message, true); }
}));
}
async function goalForm(g) {
const v = await CR.dialog({ title: g ? 'Edit goal' : 'Add a goal', text: 'One word for what you count, like subscriber or sale. The default value is optional, in US dollars, used when the pixel carries none.',
fields: [{ k: 'name', label: 'Goal name', value: g ? g.name : '', placeholder: 'subscriber', max: 32 }, { k: 'value', label: 'Default value (optional)', value: g && g.value ? String(g.value) : '', placeholder: '0.00', max: 10 }], ok: g ? 'Save' : 'Add goal' });
if (!v) return;
try { const r = g ? await CR.api('/api/my/conversions/goals/' + g.px, v) : await CR.api('/api/my/conversions/goals', v); if (r.goal) PICK = r.goal.px; CR.toast(g ? 'Saved' : 'Goal added. Its snippets are ready below.'); load(); } catch (e) { CR.toast(e.message, true); }
}
$('addGoal').addEventListener('click', () => goalForm(null));
$('goalPick').addEventListener('change', () => { PICK = $('goalPick').value; snippets(); });
document.querySelectorAll('[data-copy]').forEach(b => b.addEventListener('click', () => CR.copy($(b.dataset.copy).textContent)));
// the test loads the real image pixel, the same request a thank-you page makes; it is recorded apart and never counted
$('testBtn').addEventListener('click', async () => {
const px = PICK; if (!px) return; $('testBtn').disabled = true; $('testNote').textContent = 'Sending...';
let ok = false; try { const r = await fetch('/cv.gif?px=' + px + '&test=1&r=' + Date.now(), { cache: 'no-store' }); ok = r.ok && /^test/.test(r.headers.get('X-LS-Result') || ''); } catch (e) {}
if (!ok) { try { await CR.api('/api/my/conversions/goals/' + px, { test: true }); ok = true; } catch (e) {} }
CR.toast(ok ? 'Test received. Your pixel id works.' : 'The test did not arrive. Try again in a minute.', !ok); $('testBtn').disabled = false; load();
});
async function load() {
try { D = await CR.get('/api/my/conversions?days=' + RANGE); } catch (e) { CR.sub('could not load'); return; }
paint();
}
CR.requireSession(load);
})();
+159 -17
View File
@@ -4,6 +4,10 @@
// <div id="page">, then CR.mount({active,title,sub,actions}) and CR.requireSession(cb). // <div id="page">, then CR.mount({active,title,sub,actions}) and CR.requireSession(cb).
window.CR = (function () { window.CR = (function () {
const $ = id => document.getElementById(id); const $ = id => document.getElementById(id);
// network sign-in (2026-11-12): signed in on InstantAdPay = signed in here, no code (netsso.js asks the server once; same file on both sites)
try { if (!document.querySelector('script[src^="/assets/netsso.js"]')) { const ns = document.createElement('script'); ns.src = '/assets/netsso.js?v=20261112sso'; ns.async = true; document.head.appendChild(ns); } } catch (e) {}
// launch day is 2026-11-15 Central: the pre-launch notice shows only before it
function prelaunch() { try { return new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) < '2026-11-15'; } catch (e) { return false; } }
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c])); const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const fmt = n => Number(n || 0).toLocaleString(); const fmt = n => Number(n || 0).toLocaleString();
const NAV = [ const NAV = [
@@ -13,20 +17,59 @@ window.CR = (function () {
['zones', 'Zones', '/zones', '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/>'], ['zones', 'Zones', '/zones', '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/>'],
['ads', 'Ads', '/ads', '<path d="M3 11l14-5v12L3 13v-2z"/><path d="M17 8a4 4 0 0 1 0 8"/>'], ['ads', 'Ads', '/ads', '<path d="M3 11l14-5v12L3 13v-2z"/><path d="M17 8a4 4 0 0 1 0 8"/>'],
['credits', 'Credits', '/credits', '<circle cx="12" cy="12" r="8"/><path d="M12 8v8M9.5 10.5h3.5a1.5 1.5 0 0 1 0 3H10a1.5 1.5 0 0 0 0 3h4.5"/>'], ['credits', 'Credits', '/credits', '<circle cx="12" cy="12" r="8"/><path d="M12 8v8M9.5 10.5h3.5a1.5 1.5 0 0 1 0 3H10a1.5 1.5 0 0 0 0 3h4.5"/>'],
['refuel', 'Refuel', '/credits#refuel', '<path d="M5 20V5a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v15"/><path d="M3.5 20h12"/><path d="M7 8h5"/><path d="M14 10h2a2 2 0 0 1 2 2v3.5a1.5 1.5 0 0 0 3 0V8l-3-3"/>'], // Monthly Refuel panel on Credits (Marty 2026-10-25: no refuel option in the menu)
['reports', 'Reports', '/reports', '<path d="M4 19V9M10 19V5M16 19v-8M22 19H2"/>'], ['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"/>'], ['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"/>'], ['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"/>'], ['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], ['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],
['pipeline', 'Pipeline', '/tools#pipeline', '<rect x="3" y="5" width="5" height="14" rx="1"/><rect x="9.5" y="5" width="5" height="10" rx="1"/><rect x="16" y="5" width="5" height="7" rx="1"/>', 1], ['pipeline', 'Pipeline', '/tools#pipeline', '<rect x="3" y="5" width="5" height="14" rx="1"/><rect x="9.5" y="5" width="5" height="10" rx="1"/><rect x="16" y="5" width="5" height="7" rx="1"/>', 1],
['profile', 'Profile', '/tools#profile', '<circle cx="12" cy="8" r="3.5"/><path d="M5 20c0-4 3-6 7-6s7 2 7 6"/>', 1], ['profile', 'Profile', '/tools#profile', '<circle cx="12" cy="8" r="3.5"/><path d="M5 20c0-4 3-6 7-6s7 2 7 6"/>', 1],
['forum', 'Earners Corner', 'https://earnerscorner.com/session/sso', '<path d="M4 5.5h16v10H9l-5 4z"/><path d="M8 9.5h8M8 13h5"/>'], // the network forum (2026-11-10), signs in with InstantAdPay
['help', 'Help', '/help', '<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.4a2.5 2.5 0 0 1 4.8.9c0 1.7-2.4 2.2-2.4 3.7"/><path d="M12 17h.01"/>'], ['help', 'Help', '/help', '<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.4a2.5 2.5 0 0 1 4.8.9c0 1.7-2.4 2.2-2.4 3.7"/><path d="M12 17h.01"/>'],
['tools', 'More', '/tools', '<circle cx="5" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="19" cy="12" r="1.6"/>'], ['tools', 'More', '/tools', '<circle cx="5" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="19" cy="12" r="1.6"/>'],
]; ];
// screens not built yet fall back to the classic dashboard pane so nothing is a dead end // 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 FALLBACK = {}; // the classic /my dashboard is retired (2026-10-08); its leftover panes live at /tools
const BUILT = new Set(['links', 'sources', 'pages', 'zones', 'ads', 'credits', 'reports', '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; 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.
const ANCHOR = { refuel: 'rfPanel', buy: 'buyPanel', engine: 'erPanel', kit: 'rkPanel' };
function focusAnchor() {
const id = ANCHOR[location.hash.slice(1)]; if (!id) return;
const t0 = Date.now();
const tick = () => {
const el = $(id);
if (!el || el.hidden || !el.offsetParent || document.querySelector('.modal-back')) { if (Date.now() - t0 < 90000) setTimeout(tick, 400); return; }
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
el.classList.remove('cr-flash'); void el.offsetWidth; el.classList.add('cr-flash');
// panels above it (packages, purchases) can still be loading and push it down, mostly on phones: settle once more
setTimeout(() => { const r = el.getBoundingClientRect(); if (Math.abs(r.top) > 60) el.scrollIntoView({ block: 'start' }); }, 1600);
};
setTimeout(tick, 200);
}
// Arrival strip (2026-10-25, Marty: "it took me to LinkSpin, but I really don't know how to pick up from there"): a link from
// InstantAdPay carries ?from=iap&task=<job>; the screen opens with one line naming the job, its first step, a guide and the way back.
const ARRIVE = {
refuel: ['refuel LinkSpin', 'pick a package of $25 or more (marked "counts for Refuel") under Buy a package, then press Buy. It counts toward the same streak as InstantAdPay.', '/refuel', 'How the Refuel streak works'],
conversions: ['set up conversion tracking', 'press Add a goal and name it, for example subscriber or sale. Then paste its two snippets on your pages.', '/conversion-tracking', 'Step-by-step setup guide'],
bannerspin: ['make a Banner Spin', 'press + New Banner Spin, pick a banner size and add up to 5 banners. LinkSpin keeps showing the one that gets clicked.'],
spinlink: ['make a spin link', 'press + New spin and paste the page you promote. You get one short link to use in your ads.'],
testing: ['test A against B', 'open your spin link and add a second page under Destinations (or a second banner to a Banner Spin). The rotation picks the winner.'],
page: ['build a page', 'press + New page, fill it in and publish it. Then add it to a spin link.'],
ads: ['check your LinkSpin ads', 'your LinkSpin ads are listed on this screen. Open the one you came for to top it up or relaunch it.'],
};
const qp = (() => { try { return new URLSearchParams(location.search); } catch (e) { return new URLSearchParams(''); } })();
const ARR = qp.get('from') === 'iap' ? (ARRIVE[qp.get('task')] || ['carry on from InstantAdPay', 'use the menu on the left. Everything here signs in with the same email.']) : null;
function arriveStrip() {
if (!ARR || $('crArrive')) return '';
if (!document.getElementById('crArriveCss')) { const st = document.createElement('style'); st.id = 'crArriveCss'; st.textContent = '.arrive{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;margin:12px 24px 0;padding:10px 14px;border:1px solid var(--sig,#ff6a1a);border-radius:8px;background:var(--sig-soft,#FFF8F2);font-size:13.5px;line-height:1.45}.arrive .grow{flex:1 1 auto}.arrive button{border:0;background:none;font-size:18px;line-height:1;cursor:pointer;color:inherit;padding:0 2px}@media (max-width:900px){.arrive{margin:10px 16px 0}}.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); }
return '<div class="arrive" id="crArrive" role="note"><span><b>You came from InstantAdPay to ' + esc(ARR[0]) + '.</b> <span id="crArriveSi">Sign in with the same email you use on InstantAdPay, then </span><b>Step 1:</b> ' + esc(ARR[1])
+ (ARR[2] ? ' <a href="' + ARR[2] + '" target="_blank" rel="noopener">' + esc(ARR[3]) + '</a>' : '') + '</span><span class="grow"></span><a href="/go/iap?to=%2Fmy%23engine">Back to InstantAdPay</a><button type="button" aria-label="Hide this note" id="crArriveX">&times;</button></div>';
}
// Expired session (Marty 2026-10-23: "told me to sign in but never redirected me"): sessions last 24 h, and a screen // Expired session (Marty 2026-10-23: "told me to sign in but never redirected me"): sessions last 24 h, and a screen
// left open past that got 'Sign in first.' errors with no way forward. Any 401 from our API, or coming back to a tab // left open past that got 'Sign in first.' errors with no way forward. Any 401 from our API, or coming back to a tab
// whose session has lapsed, opens the in-shell sign-in once and reloads the screen after it. // whose session has lapsed, opens the in-shell sign-in once and reloads the screen after it.
@@ -34,7 +77,18 @@ window.CR = (function () {
function sessionLost() { if (lostOpen) return; lostOpen = true; ME = null; toast('Your session ended. Sign in again to keep going.', true); signInFlow(() => location.reload()); } function sessionLost() { if (lostOpen) return; lostOpen = true; ME = null; toast('Your session ended. Sign in again to keep going.', true); signInFlow(() => location.reload()); }
(function () { const f0 = window.fetch.bind(window); window.fetch = async function (input, init) { const r = await f0(input, init); try { const u = new URL(typeof input === 'string' ? input : input.url, location.href); if (r.status === 401 && u.origin === location.origin && /^\/api\//.test(u.pathname) && !/^\/api\/(auth|me$)/.test(u.pathname) && !/^\/api\/admin\//.test(u.pathname)) sessionLost(); } catch (e) {} return r; }; })(); (function () { const f0 = window.fetch.bind(window); window.fetch = async function (input, init) { const r = await f0(input, init); try { const u = new URL(typeof input === 'string' ? input : input.url, location.href); if (r.status === 401 && u.origin === location.origin && /^\/api\//.test(u.pathname) && !/^\/api\/(auth|me$)/.test(u.pathname) && !/^\/api\/admin\//.test(u.pathname)) sessionLost(); } catch (e) {} return r; }; })();
document.addEventListener('visibilitychange', async () => { if (document.visibilityState !== 'visible' || lostOpen || !ME || !ME.signedIn || Date.now() - lastCheck < 60000) return; lastCheck = Date.now(); const m = await me(true); if (!m || !m.signedIn) sessionLost(); }); document.addEventListener('visibilitychange', async () => { if (document.visibilityState !== 'visible' || lostOpen || !ME || !ME.signedIn || Date.now() - lastCheck < 60000) return; lastCheck = Date.now(); const m = await me(true); if (!m || !m.signedIn) sessionLost(); });
function toast(msg, bad) { let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; t.setAttribute('role', 'status'); document.body.appendChild(t); } t.textContent = msg; t.classList.toggle('bad', !!bad); t.classList.add('on'); clearTimeout(toastT); toastT = setTimeout(() => t.classList.remove('on'), 2000); } // Errors stay until the member closes them (Michael Camire 2026-11-14: a failed top-up's reason vanished after 2 s,
// before he could read it); other notes stay long enough to read, a little longer for long ones.
function toast(msg, bad) {
let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; document.body.appendChild(t); }
const text = String(msg == null ? '' : msg);
t.textContent = ''; const sp = document.createElement('span'); sp.className = 'toast-msg'; sp.textContent = text; t.appendChild(sp);
const hide = () => { clearTimeout(toastT); t.classList.remove('on'); };
if (bad) { const x = document.createElement('button'); x.type = 'button'; x.className = 'toast-x'; x.setAttribute('aria-label', 'Close this message'); x.textContent = '\u00d7'; x.addEventListener('click', hide); t.appendChild(x); }
t.setAttribute('role', bad ? 'alert' : 'status');
t.classList.toggle('bad', !!bad); t.classList.add('on'); clearTimeout(toastT);
if (!bad) toastT = setTimeout(hide, Math.min(9000, Math.max(3500, 1500 + text.length * 45)));
}
async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; } async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; }
async function get(path) { const r = await (await fetch(path, { headers: { Accept: 'application/json' } })).json(); if (r.error) throw new Error(r.error); return r; } async function get(path) { const r = await (await fetch(path, { headers: { Accept: 'application/json' } })).json(); if (r.error) throw new Error(r.error); return r; }
function copy(text) { try { navigator.clipboard.writeText(text).then(() => toast('Copied'), () => toast('Select and copy: ' + text)); } catch (e) { toast('Select and copy: ' + text); } } function copy(text) { try { navigator.clipboard.writeText(text).then(() => toast('Copied'), () => toast('Select and copy: ' + text)); } catch (e) { toast('Select and copy: ' + text); } }
@@ -60,22 +114,32 @@ window.CR = (function () {
if (document.getElementById('iapChat') || document.querySelector('script[src^="/assets/chat.js"]')) return; if (document.getElementById('iapChat') || document.querySelector('script[src^="/assets/chat.js"]')) return;
const s = document.createElement('script'); s.src = '/assets/chat.js?v=20261018c'; s.defer = true; document.body.appendChild(s); const s = document.createElement('script'); s.src = '/assets/chat.js?v=20261018c'; s.defer = true; document.body.appendChild(s);
} }
function railActive(o) { let a = o.active; if (a === 'credits' && location.hash === '#refuel') a = 'refuel'; return a; }
function mount(o) { function mount(o) {
const page = $('page'); if (!page) return; const page = $('page'); if (!page) return;
chat(); chat();
if (!document.getElementById('crFlashCss')) { const st = document.createElement('style'); st.id = 'crFlashCss'; st.textContent = '.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); }
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 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>' 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" ' : '') + 'href="' + (BUILT.has(k) ? href : FALLBACK[k]) + '"' + (k === o.active ? ' 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>' + '<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><button class="who" type="button" id="crUserBtn" title="Account"><i id="crAv"></i><span id="crWho">Sign in</span></button></div>' + '<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 // 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
+ '<div class="prelaunch" role="note"><b>Pre-launch testing until November 15.</b> Everything is live and working, but features and screens may change while we test. Questions? Use <a href="/help">Help</a>.</div>' + (prelaunch() ? '<div class="prelaunch" role="note"><b>Pre-launch testing until November 15.</b> Everything is live and working, but features and screens may change while we test. Questions? Use <a href="/help">Help</a>.</div>' : '')
+ '<div id="crBody"></div>' + arriveStrip() + '<div id="crBody"></div>'
+ '<div class="strip" id="crStrip"><span><span class="dot off" id="stDot"></span>rotator <b id="stHealth">checking</b></span><span>served today <b id="stServed">·</b></span><span>zones live <b id="stZones">·</b></span><span>network <b id="stNet">·</b></span><span class="grow"></span><span id="stClock"></span></div></div>'; + '<div class="strip" id="crStrip"><span><span class="dot off" id="stDot"></span>rotator <b id="stHealth">checking</b></span><span>served today <b id="stServed">·</b></span><span>zones live <b id="stZones">·</b></span><span>network <b id="stNet">·</b></span><span class="grow"></span><span id="stClock"></span></div></div>';
page.parentNode.insertBefore(app, page); app.querySelector('#crBody').appendChild(page); page.parentNode.insertBefore(app, page); app.querySelector('#crBody').appendChild(page);
if ($('crArriveX')) $('crArriveX').addEventListener('click', () => { const a = $('crArrive'); if (a) a.remove(); });
// the rail's Refuel item while already on Credits: only the hash changes, so scroll by hand (and again on a repeat click)
const paintRail = () => { const a2 = railActive(o); app.querySelectorAll('.rail a[href]').forEach(x => { const k = x.getAttribute('href') === '/credits#refuel' ? 'refuel' : x.getAttribute('href') === '/credits' ? 'credits' : null; if (k) { x.classList.toggle('on', k === a2); if (k === a2) x.setAttribute('aria-current', 'page'); else x.removeAttribute('aria-current'); } }); };
app.querySelectorAll('.rail a[href="/credits#refuel"]').forEach(x => x.addEventListener('click', e => { if (location.pathname !== '/credits') return; e.preventDefault(); history.replaceState(null, '', location.pathname + location.search + '#refuel'); paintRail(); focusAnchor(); }));
window.addEventListener('hashchange', () => { paintRail(); focusAnchor(); });
focusAnchor();
$('crRailTog').addEventListener('click', () => { const wide = !app.classList.contains('wide'); app.classList.toggle('wide', wide); try { localStorage.setItem('cr.rail', wide ? 'wide' : 'narrow'); } catch (e) {} }); $('crRailTog').addEventListener('click', () => { const wide = !app.classList.contains('wide'); app.classList.toggle('wide', wide); try { localStorage.setItem('cr.rail', wide ? 'wide' : 'narrow'); } catch (e) {} });
$('crUserBtn').addEventListener('click', async e => { e.preventDefault(); if (!ME || !ME.signedIn) return signInFlow(() => location.reload()); const v = await dialog({ title: ME.username ? '@' + ME.username : (ME.email || 'Account'), text: 'Signed in on LinkSpin. Your classic dashboard is still at /my.', ok: 'Sign out', no: 'Close', danger: true }); if (v) { try { await api('/api/auth/logout'); } catch (er) {} location.reload(); } }); $('crUserBtn').addEventListener('click', async e => { e.preventDefault(); if (!ME || !ME.signedIn) return signInFlow(() => location.reload()); const v = await dialog({ title: ME.username ? '@' + ME.username : (ME.email || 'Account'), text: 'Signed in on LinkSpin. Your classic dashboard is still at /my.', ok: 'Sign out', no: 'Close', danger: true }); if (v) { const all = await dialog({ title: 'Sign out where?', text: 'Only LinkSpin, or every network site (InstantAdPay, LinkSpin and the others) at once?', ok: 'Everywhere', no: 'Only LinkSpin' }); try { await api(all ? '/api/auth/logout-everywhere' : '/api/auth/logout'); } catch (er) {} location.reload(); } });
clock(); setInterval(clock, 30000); clock(); setInterval(clock, 30000);
paintTheme();
} }
// status strip: the clock ticks locally (Central); the readouts come from /api/my/strip once the member is known // status strip: the clock ticks locally (Central); the readouts come from /api/my/strip once the member is known
function clock() { const c = $('stClock'); if (!c) return; try { c.textContent = new Date().toLocaleTimeString('en-US', { timeZone: 'America/Chicago', hour: 'numeric', minute: '2-digit' }) + ' CT'; } catch (e) { c.textContent = ''; } } function clock() { const c = $('stClock'); if (!c) return; try { c.textContent = new Date().toLocaleTimeString('en-US', { timeZone: 'America/Chicago', hour: 'numeric', minute: '2-digit' }) + ' CT'; } catch (e) { c.textContent = ''; } }
@@ -83,14 +147,25 @@ window.CR = (function () {
try { const s = await get('/api/my/strip'); $('stDot').className = 'dot' + (s.ok ? '' : ' off'); $('stHealth').textContent = s.ok ? 'healthy' : 'degraded'; $('stServed').textContent = fmt(s.served); $('stZones').textContent = fmt(s.zones); $('stNet').textContent = s.network ? 'on' : 'off'; } try { const s = await get('/api/my/strip'); $('stDot').className = 'dot' + (s.ok ? '' : ' off'); $('stHealth').textContent = s.ok ? 'healthy' : 'degraded'; $('stServed').textContent = fmt(s.served); $('stZones').textContent = fmt(s.zones); $('stNet').textContent = s.network ? 'on' : 'off'; }
catch (e) { $('stHealth').textContent = 'offline'; } catch (e) { $('stHealth').textContent = 'offline'; }
} }
function whoPaint(m) { const w = $('crWho'), a = $('crAv'); if (!w) return; if (m && m.signedIn) { const name = m.username ? '@' + m.username : (m.email || '').split('@')[0]; w.textContent = name; a.textContent = (m.username || m.email || '?').replace(/^@/, '').slice(0, 2).toUpperCase(); } else { w.textContent = 'Sign in'; a.textContent = ''; } } function whoPaint(m) { const si = $('crArriveSi'); if (si) si.hidden = !!(m && m.signedIn); const w = $('crWho'), a = $('crAv'); if (!w) return; if (m && m.signedIn) { const name = m.username ? '@' + m.username : (m.email || '').split('@')[0]; w.textContent = name; a.textContent = (m.username || m.email || '?').replace(/^@/, '').slice(0, 2).toUpperCase(); } else { w.textContent = 'Sign in'; a.textContent = ''; } }
const sub = t => { const s = $('crSub'); if (s) s.textContent = t; }; const sub = t => { const s = $('crSub'); if (s) s.textContent = t; };
// ── appearance (2026-11-01): Light / Dark / Auto. The head script (themehead.js) owns window.LSTheme and localStorage
// ls.theme; this paints every .theme-seg on the page, saves the choice to the account when signed in, and at sign-in lets
// the account value win over the local one (a local choice is pushed up when the account has none yet).
const THEMES = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']];
function themeSeg(id) { return '<span class="seg theme-seg"' + (id ? ' id="' + id + '"' : '') + ' role="group" aria-label="Theme">' + THEMES.map(([k, l]) => '<button type="button" data-theme="' + k + '" title="' + l + ' theme">' + l + '</button>').join('') + '</span>'; }
function storedTheme() { try { const v = localStorage.getItem('ls.theme'); return v === 'light' || v === 'dark' || v === 'auto' ? v : null; } catch (e) { return null; } }
function paintTheme() { const c = window.LSTheme ? LSTheme.get() : 'light'; document.querySelectorAll('.theme-seg [data-theme]').forEach(b => { const on = b.dataset.theme === c; b.classList.toggle('on', on); b.setAttribute('aria-pressed', on ? 'true' : 'false'); }); }
function themeSync(m) { if (!window.LSTheme) return; const acct = m && m.signedIn && (m.theme === 'light' || m.theme === 'dark' || m.theme === 'auto') ? m.theme : null; const local = storedTheme(); if (acct) { if (acct !== local) LSTheme.set(acct, true); } else if (m && m.signedIn && local) api('/api/my/profile', { theme: local }).catch(() => {}); paintTheme(); }
document.addEventListener('click', e => { const b = e.target.closest && e.target.closest('.theme-seg [data-theme]'); if (!b || !window.LSTheme) return; const v = b.dataset.theme; LSTheme.set(v); if (ME && ME.signedIn) api('/api/my/profile', { theme: v }).catch(() => {}); });
window.addEventListener('ls-theme', paintTheme);
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', paintTheme); else paintTheme();
async function me(force) { if (ME && !force) return ME; try { ME = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) { ME = { signedIn: false }; } return ME; } async function me(force) { if (ME && !force) return ME; try { ME = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) { ME = { signedIn: false }; } return ME; }
// sign-in inside the shell: email -> six-digit code, on the same endpoints and guards as the dashboard. // sign-in inside the shell: email -> six-digit code, on the same endpoints and guards as the dashboard.
const FTS = Date.now(); const FTS = Date.now();
async function signInFlow(onReady) { async function signInFlow(onReady) {
let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); } let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); }
host.innerHTML = '<div class="modal-back"><div class="modal" role="dialog" aria-modal="true"><h2>Sign in</h2><div class="ink2">Email first. We send a six-digit code; no password to remember. New here? The same box creates your account.</div>' host.innerHTML = '<div class="modal-back"><div class="modal" role="dialog" aria-modal="true"><h2>Sign in</h2>' + (ARR ? '<div class="ink2" style="margin-bottom:6px"><b>Use the same email you use on InstantAdPay.</b> You land right back here to ' + esc(ARR[0]) + '.</div>' : '') + '<div class="ink2">Email first. We send a six-digit code; no password to remember. New here? The same box creates your account.</div>'
+ '<label class="lbl">Email<input class="field" id="siEmail" type="email" autocomplete="email" placeholder="you@example.com"></label>' + '<label class="lbl">Email<input class="field" id="siEmail" type="email" autocomplete="email" placeholder="you@example.com"></label>'
+ '<div id="siCodeRow" hidden><label class="lbl">Code from the email<input class="field mono" id="siCode" inputmode="numeric" maxlength="6" placeholder="123456"></label></div>' + '<div id="siCodeRow" hidden><label class="lbl">Code from the email<input class="field mono" id="siCode" inputmode="numeric" maxlength="6" placeholder="123456"></label></div>'
+ '<div class="muted" id="siMsg"></div><div class="acts"><a class="btn" href="/tools">More tools</a><button class="btn pri" type="button" id="siGo">Send code</button></div></div></div>'; + '<div class="muted" id="siMsg"></div><div class="acts"><a class="btn" href="/tools">More tools</a><button class="btn pri" type="button" id="siGo">Send code</button></div></div></div>';
@@ -113,16 +188,18 @@ window.CR = (function () {
} else { } else {
go.disabled = true; say('Checking…'); go.disabled = true; say('Checking…');
await api('/api/auth/email/verify', { email: email.value.trim(), code: code.value.trim() }); await api('/api/auth/email/verify', { email: email.value.trim(), code: code.value.trim() });
host.innerHTML = ''; ME = null; await me(true); toast('You are in'); onReady && onReady(ME); host.innerHTML = ''; ME = null; await me(true); toast('You are in'); try { window.dispatchEvent(new Event('cr:signedin')); } catch (er) {} onReady && onReady(ME); // panels that loaded signed out (Refuel, Engine Room) reload on this
} }
} catch (e) { go.disabled = false; say(e.message, true); } } catch (e) { go.disabled = false; say(e.message, true); }
} }
go.addEventListener('click', step); go.addEventListener('click', step);
host.querySelector('.modal').addEventListener('keydown', e => { if (e.key === 'Enter') step(); }); host.querySelector('.modal').addEventListener('keydown', e => { if (e.key === 'Enter') step(); });
} }
// login ad on the member's clock (Marty 2026-11-15): every Control Room page asks; the server answers with an ad only when the
// last finished view is older than loginAdEveryHours (loginadclock.js), and the end of the countdown restarts that clock
let laAsked = false;
async function loginAd() { async function loginAd() {
let seen = false; try { seen = !!sessionStorage.getItem('ls.la'); } catch (e) {} if (laAsked) return; laAsked = true;
if (seen) return; try { sessionStorage.setItem('ls.la', '1'); } catch (e) {}
let ad = null; try { ad = (await get('/api/ads/slot?type=login')).ad; } catch (e) { return; } let ad = null; try { ad = (await get('/api/ads/slot?type=login')).ad; } catch (e) { return; }
if (!ad || !ad.targetUrl) return; if (!ad || !ad.targetUrl) return;
await new Promise(done => { await new Promise(done => {
@@ -135,7 +212,7 @@ window.CR = (function () {
back.querySelector('#laOpen').addEventListener('click', () => { back.querySelector('#laOpen').addEventListener('click', () => {
window.open(ad.targetUrl, '_blank'); back.querySelector('#laOpen').disabled = true; window.open(ad.targetUrl, '_blank'); back.querySelector('#laOpen').disabled = true;
let left = ad.dwell || 10; const t = back.querySelector('#laTimer'); t.hidden = false; t.textContent = left + ' s'; let left = ad.dwell || 10; const t = back.querySelector('#laTimer'); t.hidden = false; t.textContent = left + ' s';
const iv = setInterval(() => { left -= 1; if (left > 0) { t.textContent = left + ' s'; return; } clearInterval(iv); t.textContent = 'done'; back.querySelector('#laStatus').textContent = 'Thanks for the look.'; back.querySelector('#laGo').hidden = false; }, 1000); const iv = setInterval(() => { left -= 1; if (left > 0) { t.textContent = left + ' s'; return; } clearInterval(iv); t.textContent = 'done'; fetch('/api/ads/login/seen', { method: 'POST' }).catch(() => {}); back.querySelector('#laStatus').textContent = 'Thanks for the look.'; back.querySelector('#laGo').hidden = false; }, 1000);
}); });
back.querySelector('#laGo').addEventListener('click', () => { back.remove(); done(); }); back.querySelector('#laGo').addEventListener('click', () => { back.remove(); done(); });
}); });
@@ -152,16 +229,66 @@ window.CR = (function () {
} }
return m; 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) // 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() { async function helpBadge() {
const a = $('crHelp'); if (!a) return 0; 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; } 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; } 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); } 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; b.textContent = n > 9 ? '9+' : String(n); a.title = 'Help: ' + n + ' new repl' + (n === 1 ? 'y' : 'ies'); return n;
} }
async function requireSession(onReady) { let m = await me(); whoPaint(m); if (m && m.signedIn) { strip(); helpBadge(); m = await ensureUsername(m); await loginAd(); return onReady(m); } signInFlow(async r => { whoPaint(r); strip(); helpBadge(); await loginAd(); onReady(r); }); } // "Who invited you?" (Marty approved 2026-11-07): a member with no sponsor and no member number can name who invited them.
// LinkSpin members land on the Control Room, not on the /tools Overview, so it sits at the top of every screen, /tools included.
// Soft: nothing waits for it. "Nobody invited me" hides it everywhere; a small link on /tools brings it back.
function inviteCard(m) {
if ($('crInvite')) $('crInvite').remove();
const ask = m && m.signedIn && !m.memberId && m.inviteAsk; const body = $('crBody'); if (!ask || !body) return;
if (ask.dismissed && location.pathname !== '/tools') return;
if (!$('crInviteCss')) { const st = document.createElement('style'); st.id = 'crInviteCss'; st.textContent = '.invite{margin:12px 24px;padding:12px 14px;border:1px solid var(--line);background:var(--panel)}.invite h2{font:700 16px Manrope,system-ui;margin:0 0 4px}.invite .row{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;align-items:center}.invite .field{flex:1 1 180px;max-width:280px;margin:0}.invite .bad{color:var(--bad,#c0392b)}@media(max-width:640px){.invite{margin:10px 16px}}'; document.head.appendChild(st); }
const box = document.createElement('div'); box.id = 'crInvite'; box.className = 'invite'; body.insertBefore(box, body.firstChild);
const full = () => {
box.innerHTML = '<h2>Who invited you?</h2><div class="ink2">You joined without a sponsor. If someone told you about LinkSpin, type their username and they become your sponsor. Do it before your payouts switch on or you buy: your sponsor locks on the contract at that point.</div>'
+ '<div class="row"><input class="field" id="inviteWho" autocomplete="off" autocapitalize="none" spellcheck="false" aria-label="Their username" placeholder="their username"><button class="btn pri" type="button" id="inviteGo">Set my sponsor</button><button class="btn" type="button" id="inviteNo">Nobody invited me</button></div><div class="ink2" id="inviteMsg" style="margin-top:6px"></div>';
const say = (t, bad) => { const x = $('inviteMsg'); x.textContent = t || ''; x.classList.toggle('bad', !!bad); };
const go = async () => {
say('');
try {
const who = $('inviteWho').value;
const chk = await api('/api/my/tank/invited', { who, check: true });
const yes = await dialog({ title: 'Who invited you?', text: chk.name + ' becomes your sponsor. ' + (m.address ? 'Your wallet is linked, so your payouts switch on under them right away, and that locks them in for good on the contract.' : 'Your sponsor locks on the contract when your payouts switch on or you buy, so check this is the right person.'), ok: 'Yes, ' + chk.name, no: 'Not them' });
if (!yes) return;
const r = await api('/api/my/tank/invited', { who });
box.remove(); toast(r.name + ' is now your sponsor.'); setTimeout(() => location.reload(), 1400);
} catch (e) { say(e.message, true); }
};
$('inviteGo').addEventListener('click', go);
$('inviteWho').addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); go(); } });
$('inviteNo').addEventListener('click', async () => { try { await api('/api/my/tank/invited/dismiss', {}); } catch (e) {} if (location.pathname === '/tools') small(); else box.remove(); });
};
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();
}
// a network sign-in hop waiting on this sign-in (another site asked "Sign in with LinkSpin" while signed out here): finish it
// after the login ad, back to the site and page it came from, never left on the Control Room (2026-11-15)
const hopBack = m => { if (m && m.signedIn && m.nssoBack && m.username) { location.href = '/sso/resume'; return true; } return false; };
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(); if (hopBack(m)) return; inviteCard(m); return onReady(m); } signInFlow(async r => { whoPaint(r); themeSync(r); strip(); helpBadge(); let m2 = await me(true); m2 = await ensureUsername(m2); await loginAd(); if (hopBack(m2)) return; inviteCard(m2); onReady(m2 && m2.signedIn ? m2 : r); }); }
// tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first // tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first
function sparkline(series) { function sparkline(series) {
const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return ''; const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return '';
@@ -180,5 +307,20 @@ 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>' 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>'; + (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 };
})();
// Network links (2026-11-13): a click on a link to InstantAdPay goes through /go/iap, which signs a signed-in member in over there and is a
// plain redirect for everyone else. Rewritten at click time only, so links people copy to share stay clean. data-nogo opts a link out.
(function () {
if (window.__netlinks) return; window.__netlinks = 1;
const HOSTS = ['instantadpay.com', 'www.instantadpay.com'];
document.addEventListener('click', e => {
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
const a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
if (!a || a.hasAttribute('download') || a.hasAttribute('data-nogo')) return;
let u; try { u = new URL(a.href); } catch (x) { return; }
if (u.protocol !== 'https:' || !HOSTS.includes(u.hostname)) return;
a.href = '/go/iap?to=' + encodeURIComponent(u.pathname + u.search + u.hash);
}, true);
})(); })();
+84 -44
View File
@@ -4,21 +4,48 @@
scheme so every screen keeps working; only the values and the chrome changed. */ scheme so every screen keeps working; only the values and the chrome changed. */
:root{ :root{
--bg:#E9EEF5; --rail:#F3F6FB; --panel:#FFFFFF; --panel-2:#F3F6FB; --line:#CDD7E5; --line-strong:#AEBED4; --bg:#E9EEF5; --rail:#F3F6FB; --panel:#FFFFFF; --panel-2:#F3F6FB; --line:#CDD7E5; --line-strong:#AEBED4;
--ink:#0F1B2E; --ink-2:#324361; --muted:#66768F; --ink:#0F1B2E; --ink-2:#324361; --muted:#596984;
--accent:#1F6FEB; --accent-hi:#0B4BB3; --accent-ink:#FFFFFF; --accent-dim:#7CB2FF; --accent-soft:#E1ECFC; --accent:#1F6FEB; --accent-hi:#0B4BB3; --accent-ink:#FFFFFF; --accent-dim:#7CB2FF; --accent-pale:#A9CBFA; --accent-soft:#E1ECFC;
--sig:#FF6A1A; --sig-2:#D9530A; --sig-soft:#FFE9DC; --sig:#FF6A1A; --sig-2:#B8420A; --sig-soft:#FFE9DC; --sig-ink:#0F1B2E; --sig-line:rgba(255,106,26,.45);
--ok:#0E8A5C; --ok-soft:#DDF4E8; --warn:#C2410C; --warn-soft:#FFE7D8; --bad:#B91C1C; --bad-soft:#FBE0E0; --hi-row:#FFF3EA; --ok:#0B7A52; --ok-soft:#DDF4E8; --ok-ink:#FFFFFF; --ok-line:rgba(11,122,82,.4); --warn:#B23A0A; --warn-soft:#FFE7D8; --warn-line:rgba(178,58,10,.4);
--chrome:#0B1424; --chrome-2:#101D33; --chrome-ink:#EEF3FA; --chrome-sub:#8CA2C4; --chrome-line:#1E2E4A; --inset:#0F1B2E; --bad:#B91C1C; --bad-soft:#FBE0E0; --bad-ink:#FFFFFF; --bad-line:rgba(185,28,28,.4); --hi-row:#FFF3EA;
--sh:0 10px 24px -18px rgba(15,27,46,.45),0 1px 0 rgba(255,255,255,.9) inset; --violet:#6D4AFF; --violet-soft:#EEE9FF; --violet-line:rgba(109,74,255,.45);
--note-bg:#FFFBEB; --note-soft:#FEF3C7; --note-line:#F59E0B; --note-ink:#92400E;
--chrome:#0B1424; --chrome-2:#101D33; --chrome-ink:#EEF3FA; --chrome-sub:#8CA2C4; --chrome-line:#1E2E4A; --chrome-hi:#8CC8FF; --chrome-warm:#FFB37D; --inset:#0F1B2E;
--on-ink:#FFFFFF; --field-bg:#FFFFFF; --panel-glass:rgba(255,255,255,.55); --row-hover:rgba(31,111,235,.04);
--btn-bg:linear-gradient(180deg,#FFFFFF,#F3F6FB); --btn-blue:linear-gradient(180deg,#2A74EC,#1559CC);
--panel-grad:linear-gradient(180deg,#FFFFFF,#F6F8FC); --panel-grad-hi:linear-gradient(180deg,#FFFFFF,#EEF4FE); --ph-a:#EEF2F9; --ph-b:#F5F7FC;
--hl:rgba(255,255,255,.9); --grid-dot:rgba(31,111,235,.20); --bg-glow:rgba(255,255,255,.6);
--sh:0 10px 24px -18px rgba(15,27,46,.45),0 1px 0 rgba(255,255,255,.9) inset; --sh-lg:0 30px 60px -30px rgba(15,27,46,.6);
/* aliases some screens reached for */ /* aliases some screens reached for */
--line2:var(--line-strong); --accent2:var(--accent-hi); --ink2:var(--ink-2); --line2:var(--line-strong); --accent2:var(--accent-hi); --ink2:var(--ink-2);
--display:"Rajdhani","Segoe UI",system-ui,sans-serif; --body:"Manrope","Segoe UI",system-ui,sans-serif; --mono:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace; --display:"Rajdhani","Segoe UI",system-ui,sans-serif; --body:"Manrope","Segoe UI",system-ui,sans-serif; --mono:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;
--r:7px; --r:7px;
color-scheme:light; color-scheme:light;
} }
/* Dark workspace (2026-11-01: a member asked for light and dark, for vision-impaired readers and for people who
struggle with bright or with dark screens). Same token names; the chrome rail, topbar and strip stay as they are.
The head script (themehead.js) sets data-theme from localStorage ls.theme / the account; auto follows the device. */
:root[data-theme="dark"]{
--bg:#0B1424; --rail:#101D33; --panel:#142338; --panel-2:#1B2D47; --line:#273B5C; --line-strong:#3A5580;
--ink:#EEF3FA; --ink-2:#C5D2E6; --muted:#97A9C6;
--accent:#4D8DF7; --accent-hi:#8CC0FF; --accent-ink:#0B1424; --accent-dim:#3D6FC4; --accent-pale:#2E5699; --accent-soft:#1B325A;
--sig:#FF7A32; --sig-2:#FFA06A; --sig-soft:#3B2416; --sig-ink:#0B1424; --sig-line:rgba(255,122,50,.45);
--ok:#3FCF92; --ok-soft:#12352A; --ok-ink:#0B1424; --ok-line:rgba(63,207,146,.4); --warn:#F7A35E; --warn-soft:#3D2716; --warn-line:rgba(247,163,94,.4);
--bad:#FF8080; --bad-soft:#44202A; --bad-ink:#0B1424; --bad-line:rgba(255,128,128,.4); --hi-row:#2B2119;
--violet:#B19CFF; --violet-soft:#2A2350; --violet-line:rgba(177,156,255,.45);
--note-bg:#2A2410; --note-soft:#3B3014; --note-line:#B7791F; --note-ink:#F5C462;
--inset:#06101E;
--on-ink:#0B1424; --field-bg:#0F1B2E; --panel-glass:rgba(20,35,56,.6); --row-hover:rgba(140,192,255,.06);
--btn-bg:linear-gradient(180deg,#1E3150,#172743); --btn-blue:linear-gradient(180deg,#8CC0FF,#5A96F5);
--panel-grad:linear-gradient(180deg,#162741,#122035); --panel-grad-hi:linear-gradient(180deg,#172A47,#15284A); --ph-a:#182A45; --ph-b:#1B2E4B;
--hl:rgba(255,255,255,.05); --grid-dot:rgba(140,192,255,.10); --bg-glow:rgba(31,111,235,.12);
--sh:0 10px 24px -18px rgba(0,0,0,.85),0 1px 0 rgba(255,255,255,.04) inset; --sh-lg:0 30px 60px -30px rgba(0,0,0,.9);
color-scheme:dark;
}
*{box-sizing:border-box} *{box-sizing:border-box}
html,body{height:100%} html,body{height:100%}
body{margin:0;background:var(--bg);background-image:radial-gradient(circle,rgba(31,111,235,.20) 1px,transparent 1.3px),radial-gradient(120% 60% at 50% 0%,rgba(255,255,255,.6),transparent 60%);background-size:18px 18px,100% 100%;background-attachment:fixed;color:var(--ink);font-family:var(--body);font-size:13px;line-height:1.45} body{margin:0;background:var(--bg);background-image:radial-gradient(circle,var(--grid-dot) 1px,transparent 1.3px),radial-gradient(120% 60% at 50% 0%,var(--bg-glow),transparent 60%);background-size:18px 18px,100% 100%;background-attachment:fixed;color:var(--ink);font-family:var(--body);font-size:13px;line-height:1.45}
a{color:var(--accent-hi)} a:hover{color:var(--accent)} a{color:var(--accent-hi)} a:hover{color:var(--accent)}
button,input,select,textarea{font:inherit;color:inherit} button,input,select,textarea{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--sig);outline-offset:2px} :focus-visible{outline:2px solid var(--sig);outline-offset:2px}
@@ -61,40 +88,40 @@ button,input,select,textarea{font:inherit;color:inherit}
.topbar .readout{font-family:var(--mono);font-size:11px;color:var(--chrome-sub);letter-spacing:.02em;padding-left:14px;border-left:1px solid var(--chrome-line)} .topbar .readout{font-family:var(--mono);font-size:11px;color:var(--chrome-sub);letter-spacing:.02em;padding-left:14px;border-left:1px solid var(--chrome-line)}
.topbar .grow{flex:1} .topbar .grow{flex:1}
.topbar .who{display:inline-flex;align-items:center;gap:8px;font-weight:700;font-size:12px;color:var(--chrome-ink);padding:4px 10px 4px 5px;border:1px solid var(--chrome-line);border-radius:999px;background:transparent;cursor:pointer} .topbar .who{display:inline-flex;align-items:center;gap:8px;font-weight:700;font-size:12px;color:var(--chrome-ink);padding:4px 10px 4px 5px;border:1px solid var(--chrome-line);border-radius:999px;background:transparent;cursor:pointer}
.topbar .who i{width:20px;height:20px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--accent-dim));display:grid;place-items:center;font:700 9px var(--mono);color:#fff;font-style:normal} .topbar .who i{width:20px;height:20px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--accent-dim));display:grid;place-items:center;font:700 9px var(--mono);color:var(--accent-ink);font-style:normal}
.topbar .who:hover{border-color:var(--chrome-sub)} .topbar .who:hover{border-color:var(--chrome-sub)}
.topbar .btn{color:var(--ink)} .topbar .btn{color:var(--ink)}
.prelaunch{padding:9px 22px;background:#fff4d6;color:#4a3500;border-bottom:1px solid #f0d58a;font-size:13.5px;line-height:1.4}.prelaunch b{color:#2e2100}.prelaunch a{color:#7a4f00;font-weight:600} .prelaunch{padding:9px 22px;background:var(--note-soft);color:var(--note-ink);border-bottom:1px solid var(--note-line);font-size:13.5px;line-height:1.4}.prelaunch b{color:var(--ink)}.prelaunch a{color:var(--note-ink);font-weight:600}
.strip{display:flex;gap:22px;align-items:center;padding:8px 22px;margin-top:auto;background:var(--chrome);color:var(--chrome-sub);font-family:var(--mono);font-size:11px;letter-spacing:.03em;border-top:1px solid var(--chrome-line)} .strip{display:flex;gap:22px;align-items:center;padding:8px 22px;margin-top:auto;background:var(--chrome);color:var(--chrome-sub);font-family:var(--mono);font-size:11px;letter-spacing:.03em;border-top:1px solid var(--chrome-line)}
.strip b{color:var(--chrome-ink);font-weight:700} .strip b{color:var(--chrome-ink);font-weight:700}
.strip .dot{width:7px;height:7px;border-radius:50%;background:var(--ok);display:inline-block;margin-right:7px;box-shadow:0 0 0 3px rgba(14,138,92,.22);animation:crpulse 2.4s ease-in-out infinite} .strip .dot{width:7px;height:7px;border-radius:50%;background:var(--ok);display:inline-block;margin-right:7px;box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 22%,transparent);animation:crpulse 2.4s ease-in-out infinite}
.strip .dot.off{background:var(--muted);animation:none;box-shadow:none} .strip .dot.off{background:var(--muted);animation:none;box-shadow:none}
.strip .sig{color:var(--sig)} .strip .grow{flex:1} .strip .sig{color:var(--sig)} .strip .grow{flex:1}
@keyframes crpulse{0%,100%{box-shadow:0 0 0 3px rgba(14,138,92,.22)}50%{box-shadow:0 0 0 5px rgba(14,138,92,.08)}} @keyframes crpulse{0%,100%{box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 22%,transparent)}50%{box-shadow:0 0 0 5px color-mix(in srgb,var(--ok) 8%,transparent)}}
/* controls */ /* controls */
.btn{background:linear-gradient(180deg,#FFFFFF,#F3F6FB);color:var(--ink);border:1px solid var(--line-strong);border-radius:var(--r);padding:6px 12px;font-size:12px;font-weight:700;cursor:pointer;white-space:nowrap;box-shadow:0 1px 0 rgba(255,255,255,.9) inset,0 1px 2px rgba(15,27,46,.08);text-decoration:none;display:inline-flex;align-items:center;gap:6px;justify-content:center} .btn{background:var(--btn-bg);color:var(--ink);border:1px solid var(--line-strong);border-radius:var(--r);padding:6px 12px;font-size:12px;font-weight:700;cursor:pointer;white-space:nowrap;box-shadow:0 1px 0 var(--hl) inset,0 1px 2px rgba(15,27,46,.08);text-decoration:none;display:inline-flex;align-items:center;gap:6px;justify-content:center}
.btn:hover{border-color:var(--accent)} .btn:hover{border-color:var(--accent)}
.btn.pri{font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;background:linear-gradient(180deg,#FF7A32,var(--sig));color:#fff;border-color:var(--sig-2);padding:6px 13px;box-shadow:0 8px 18px -10px rgba(255,106,26,.9),0 1px 0 rgba(255,255,255,.35) inset} .btn.pri{font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;background:linear-gradient(180deg,#FF7A32,var(--sig));color:var(--sig-ink);border-color:var(--sig-2);padding:6px 13px;box-shadow:0 8px 18px -10px rgba(255,106,26,.9),0 1px 0 rgba(255,255,255,.35) inset}
.btn.pri:hover{background:linear-gradient(180deg,#FF8A48,#FF6A1A);border-color:var(--sig-2)} .btn.pri:hover{background:linear-gradient(180deg,#FF8A48,#FF6A1A);border-color:var(--sig-2)}
.btn.blue{background:linear-gradient(180deg,#3A83F0,var(--accent));color:#fff;border-color:var(--accent-hi);box-shadow:0 8px 18px -10px rgba(31,111,235,.9),0 1px 0 rgba(255,255,255,.3) inset} .btn.blue{background:var(--btn-blue);color:var(--accent-ink);border-color:var(--accent-hi);box-shadow:0 8px 18px -10px rgba(31,111,235,.9),0 1px 0 rgba(255,255,255,.3) inset}
.btn.sm{padding:4px 9px;font-size:11px} .btn.sm{padding:4px 9px;font-size:11px}
.btn.ghost{background:transparent;box-shadow:none} .btn.ghost{background:transparent;box-shadow:none}
.btn.danger:hover{border-color:var(--bad);color:var(--bad)} .btn.danger:hover{border-color:var(--bad);color:var(--bad)}
.btn.pri.danger{background:linear-gradient(180deg,#D93030,var(--bad));border-color:#991B1B} .btn.pri.danger{background:linear-gradient(180deg,#D93030,var(--bad));border-color:#991B1B;color:var(--bad-ink)}
.btn[disabled]{opacity:.5;cursor:default} .btn[disabled]{opacity:.5;cursor:default}
.field{background:#fff;border:1px solid var(--line-strong);border-radius:6px;padding:7px 10px;color:var(--ink);width:100%;min-width:0;box-shadow:0 1px 2px rgba(15,27,46,.06) inset} .field{background:var(--field-bg);border:1px solid var(--line-strong);border-radius:6px;padding:7px 10px;color:var(--ink);width:100%;min-width:0;box-shadow:0 1px 2px rgba(15,27,46,.06) inset}
.field:focus{border-color:var(--sig);outline:none;box-shadow:0 0 0 3px rgba(255,106,26,.18)} .field:focus{border-color:var(--sig);outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--sig) 18%,transparent)}
.field.mono{font-size:12px} .field.mono{font-size:12px}
select.field{appearance:auto} select.field{appearance:auto}
label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)} label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
.code{font-family:var(--mono);font-size:12px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;padding:6px 10px;color:#8CC8FF;overflow-wrap:anywhere} .code{font-family:var(--mono);font-size:12px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;padding:6px 10px;color:var(--chrome-hi);overflow-wrap:anywhere}
.led{display:inline-flex;align-items:baseline;gap:8px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;padding:7px 12px;color:var(--chrome-sub);font-family:var(--mono);font-size:11px} .led{display:inline-flex;align-items:baseline;gap:8px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;padding:7px 12px;color:var(--chrome-sub);font-family:var(--mono);font-size:11px}
.led b{font-family:var(--display);font-size:20px;line-height:1;color:var(--sig);letter-spacing:.04em;font-variant-numeric:tabular-nums} .led b{font-family:var(--display);font-size:20px;line-height:1;color:var(--sig);letter-spacing:.04em;font-variant-numeric:tabular-nums}
/* tiles */ /* tiles */
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px} .tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
.tile{position:relative;background:linear-gradient(180deg,#FFFFFF,#F6F8FC);border:1px solid var(--line);border-radius:8px;padding:12px 14px;display:grid;gap:3px;box-shadow:var(--sh)} .tile{position:relative;background:var(--panel-grad);border:1px solid var(--line);border-radius:8px;padding:12px 14px;display:grid;gap:3px;box-shadow:var(--sh)}
.tile::before,.tile::after{content:"";position:absolute;width:11px;height:11px;border:1.5px solid var(--line-strong);pointer-events:none} .tile::before,.tile::after{content:"";position:absolute;width:11px;height:11px;border:1.5px solid var(--line-strong);pointer-events:none}
.tile::before{top:5px;left:5px;border-right:0;border-bottom:0} .tile::after{bottom:5px;right:5px;border-left:0;border-top:0} .tile::before{top:5px;left:5px;border-right:0;border-bottom:0} .tile::after{bottom:5px;right:5px;border-left:0;border-top:0}
.tile .k{display:flex;align-items:center;gap:8px;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)} .tile .k{display:flex;align-items:center;gap:8px;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)}
@@ -102,7 +129,7 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
.tile .v{font-family:var(--display);font-weight:700;font-size:30px;line-height:1.05;letter-spacing:.02em;font-variant-numeric:tabular-nums;color:var(--ink)} .tile .v{font-family:var(--display);font-weight:700;font-size:30px;line-height:1.05;letter-spacing:.02em;font-variant-numeric:tabular-nums;color:var(--ink)}
.tile .row{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;min-width:0} .tile .row{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;min-width:0}
.tile .v small{font-family:var(--mono);font-size:12px;font-weight:500;color:var(--muted);margin-left:4px;letter-spacing:0} .tile .v small{font-family:var(--mono);font-size:12px;font-weight:500;color:var(--muted);margin-left:4px;letter-spacing:0}
.tile.hi{background:linear-gradient(180deg,#FFFFFF,#EEF4FE)} .tile.hi::before,.tile.hi::after{border-color:var(--sig)} .tile.hi .k::before{background:var(--sig)} .tile.hi .v{color:var(--accent-hi)} .tile.hi{background:var(--panel-grad-hi)} .tile.hi::before,.tile.hi::after{border-color:var(--sig)} .tile.hi .k::before{background:var(--sig)} .tile.hi .v{color:var(--accent-hi)}
.tile .delta{justify-self:start;font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.04em;color:var(--ok);background:var(--ok-soft);border-radius:4px;padding:2px 6px;margin-top:2px} .tile .delta{justify-self:start;font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.04em;color:var(--ok);background:var(--ok-soft);border-radius:4px;padding:2px 6px;margin-top:2px}
.tile .delta.flat{color:var(--muted);background:var(--panel-2)} .tile .delta.flat{color:var(--muted);background:var(--panel-2)}
.tile .delta.down{color:var(--warn);background:var(--warn-soft)} .tile .delta.down{color:var(--warn);background:var(--warn-soft)}
@@ -110,31 +137,31 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
/* tags + chips */ /* tags + chips */
.tag{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;border:1px solid var(--line-strong);border-radius:4px;padding:1px 7px;white-space:nowrap;color:var(--ink-2);background:var(--panel-2);vertical-align:middle} .tag{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;border:1px solid var(--line-strong);border-radius:4px;padding:1px 7px;white-space:nowrap;color:var(--ink-2);background:var(--panel-2);vertical-align:middle}
.tag::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--line-strong);flex:none} .tag::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--line-strong);flex:none}
.tag.ok{color:var(--ok);border-color:rgba(14,138,92,.4);background:var(--ok-soft)} .tag.ok::before{background:var(--ok);box-shadow:0 0 0 2px rgba(14,138,92,.2)} .tag.ok{color:var(--ok);border-color:var(--ok-line);background:var(--ok-soft)} .tag.ok::before{background:var(--ok);box-shadow:0 0 0 2px color-mix(in srgb,var(--ok) 20%,transparent)}
.tag.warn{color:var(--warn);border-color:rgba(194,65,12,.4);background:var(--warn-soft)} .tag.warn::before{background:var(--warn)} .tag.warn{color:var(--warn);border-color:var(--warn-line);background:var(--warn-soft)} .tag.warn::before{background:var(--warn)}
.tag.bad{color:var(--bad);border-color:rgba(185,28,28,.4);background:var(--bad-soft)} .tag.bad::before{background:var(--bad)} .tag.bad{color:var(--bad);border-color:var(--bad-line);background:var(--bad-soft)} .tag.bad::before{background:var(--bad)}
.tag.dim{color:var(--muted)} .tag.dim{color:var(--muted)}
.tag.t,.tag.plain{color:var(--accent-hi);border-color:var(--accent-soft);background:var(--accent-soft)} .tag.t::before,.tag.plain::before{display:none} .tag.t,.tag.plain{color:var(--accent-hi);border-color:var(--accent-soft);background:var(--accent-soft)} .tag.t::before,.tag.plain::before{display:none}
.dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor;margin-right:6px;vertical-align:middle} .dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor;margin-right:6px;vertical-align:middle}
.chips{display:flex;gap:6px;flex-wrap:wrap} .chips{display:flex;gap:6px;flex-wrap:wrap}
.chip{font-size:11px;font-weight:700;color:var(--ink-2);border:1px solid var(--line-strong);border-radius:999px;padding:3px 10px;cursor:pointer;background:#fff} .chip{font-size:11px;font-weight:700;color:var(--ink-2);border:1px solid var(--line-strong);border-radius:999px;padding:3px 10px;cursor:pointer;background:var(--panel)}
.chip.on{border-color:var(--accent);color:var(--accent-hi);background:var(--accent-soft)} .chip.on{border-color:var(--accent);color:var(--accent-hi);background:var(--accent-soft)}
.seg{display:inline-flex;border:1px solid var(--line-strong);border-radius:8px;overflow:hidden;background:var(--panel-2)} .seg{display:inline-flex;border:1px solid var(--line-strong);border-radius:8px;overflow:hidden;background:var(--panel-2)}
.seg button{background:transparent;border:0;border-right:1px solid var(--line-strong);padding:7px 13px;font-weight:700;font-size:12px;color:var(--ink-2);cursor:pointer;display:inline-flex;align-items:center;gap:6px} .seg button{background:transparent;border:0;border-right:1px solid var(--line-strong);padding:7px 13px;font-weight:700;font-size:12px;color:var(--ink-2);cursor:pointer;display:inline-flex;align-items:center;gap:6px}
.seg button:last-child{border-right:0} .seg button.on{background:var(--ink);color:#fff} .seg button:last-child{border-right:0} .seg button.on{background:var(--ink);color:var(--on-ink)}
/* tables + panels */ /* tables + panels */
.tbl{border:1px solid var(--line);border-radius:8px;background:var(--panel);overflow:hidden;box-shadow:var(--sh)} .tbl{border:1px solid var(--line);border-radius:8px;background:var(--panel);overflow:hidden;box-shadow:var(--sh)}
.tbl .hd,.tbl .rw{display:grid;gap:12px;padding:10px 16px;align-items:center} .tbl .hd,.tbl .rw{display:grid;gap:12px;padding:10px 16px;align-items:center}
.tbl .hd{font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--muted);border-bottom:1px solid var(--line);background:var(--panel-2)} .tbl .hd{font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--muted);border-bottom:1px solid var(--line);background:var(--panel-2)}
.tbl .rw{position:relative;border-bottom:1px solid var(--line)} .tbl .rw:last-child{border-bottom:0} .tbl .rw{position:relative;border-bottom:1px solid var(--line)} .tbl .rw:last-child{border-bottom:0}
.tbl .rw:hover{background:rgba(31,111,235,.04)} .tbl .rw:hover{background:var(--row-hover)}
.tbl .rw.on,.tbl .rw.hi-row{background:var(--hi-row)} .tbl .rw.on::before,.tbl .rw.hi-row::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--sig)} .tbl .rw.on,.tbl .rw.hi-row{background:var(--hi-row)} .tbl .rw.on::before,.tbl .rw.hi-row::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--sig)}
/* an empty-state row (one muted note) spans every column instead of wrapping inside the first */ /* an empty-state row (one muted note) spans every column instead of wrapping inside the first */
.tbl .rw > .muted:only-child{grid-column:1/-1} .tbl .rw > .muted:only-child{grid-column:1/-1}
.tbl .ft{padding:9px 16px;border-top:1px solid var(--line);font-family:var(--mono);font-size:10.5px;color:var(--muted);background:var(--panel-2);letter-spacing:.02em} .tbl .ft{padding:9px 16px;border-top:1px solid var(--line);font-family:var(--mono);font-size:10.5px;color:var(--muted);background:var(--panel-2);letter-spacing:.02em}
.r{text-align:right} .r{text-align:right}
.ph{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 14px;border-bottom:1px solid var(--line);background:repeating-linear-gradient(135deg,#EEF2F9 0 6px,#F5F7FC 6px 12px)} .ph{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 14px;border-bottom:1px solid var(--line);background:repeating-linear-gradient(135deg,var(--ph-a) 0 6px,var(--ph-b) 6px 12px)}
.ph h2,.ph h3{font-family:var(--display);font-size:14px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;margin:0;display:flex;align-items:center;gap:8px} .ph h2,.ph h3{font-family:var(--display);font-size:14px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;margin:0;display:flex;align-items:center;gap:8px}
.ph h2::before,.ph h3::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block;flex:none} .ph h2::before,.ph h3::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block;flex:none}
.ph .meta{font-family:var(--mono);font-size:10.5px;color:var(--muted);letter-spacing:.04em;text-align:right} .ph .meta{font-family:var(--mono);font-size:10.5px;color:var(--muted);letter-spacing:.04em;text-align:right}
@@ -142,7 +169,7 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
.split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--line)} .split i{display:block;height:100%} .split .a{background:var(--accent)} .split .b{background:var(--accent-dim)} .split .c{background:var(--sig)} .split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--line)} .split i{display:block;height:100%} .split .a{background:var(--accent)} .split .b{background:var(--accent-dim)} .split .c{background:var(--sig)}
.prog{height:10px;background:var(--line);border-radius:5px;overflow:hidden} .prog i{display:block;height:100%;background:linear-gradient(90deg,var(--accent-hi),var(--accent) 70%,var(--sig))} .prog{height:10px;background:var(--line);border-radius:5px;overflow:hidden} .prog i{display:block;height:100%;background:linear-gradient(90deg,var(--accent-hi),var(--accent) 70%,var(--sig))}
.gauge{display:grid;grid-template-columns:repeat(5,1fr);gap:5px} .gauge i{display:block;height:12px;border-radius:2px;background:var(--line);border:1px solid var(--line-strong)} .gauge{display:grid;grid-template-columns:repeat(5,1fr);gap:5px} .gauge i{display:block;height:12px;border-radius:2px;background:var(--line);border:1px solid var(--line-strong)}
.gauge i.on{background:linear-gradient(180deg,#3A83F0,var(--accent));border-color:var(--accent-hi);box-shadow:0 0 8px rgba(31,111,235,.45)} .gauge i.on{background:var(--btn-blue);border-color:var(--accent-hi);box-shadow:0 0 8px color-mix(in srgb,var(--accent) 45%,transparent)}
.tabs{display:flex;gap:4px} .tabs button{background:transparent;border:1px solid transparent;border-radius:var(--r);color:var(--muted);font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;padding:6px 12px;cursor:pointer} .tabs{display:flex;gap:4px} .tabs button{background:transparent;border:1px solid transparent;border-radius:var(--r);color:var(--muted);font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;padding:6px 12px;cursor:pointer}
.tabs button.on{background:var(--panel);border-color:var(--accent);color:var(--accent-hi);box-shadow:0 1px 2px rgba(15,27,46,.08)} .tabs button.on{background:var(--panel);border-color:var(--accent);color:var(--accent-hi);box-shadow:0 1px 2px rgba(15,27,46,.08)}
@@ -153,21 +180,25 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
.panel h2::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block;flex:none} .panel h2::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block;flex:none}
/* tiny charts: gradient bars, glow on the peak */ /* tiny charts: gradient bars, glow on the peak */
.bars{display:grid;gap:3px;align-items:end;height:120px;border-bottom:1px solid var(--line-strong);background:repeating-linear-gradient(180deg,transparent 0 29px,rgba(31,111,235,.08) 29px 30px)} .bars{display:grid;gap:3px;align-items:end;height:120px;border-bottom:1px solid var(--line-strong);background:repeating-linear-gradient(180deg,transparent 0 29px,color-mix(in srgb,var(--accent) 10%,transparent) 29px 30px)}
.bars i{display:block;width:100%;max-width:56px;justify-self:center;background:linear-gradient(180deg,var(--accent),var(--accent-hi));min-height:1px;border-radius:2px 2px 0 0} .bars i{display:block;width:100%;max-width:56px;justify-self:center;background:linear-gradient(180deg,var(--accent),var(--accent-hi));min-height:1px;border-radius:2px 2px 0 0}
.bars i.dim{background:linear-gradient(180deg,var(--accent-dim),#A9CBFA)} .bars i.dim{background:linear-gradient(180deg,var(--accent-dim),var(--accent-pale))}
.bars i.hi{background:linear-gradient(180deg,#FF8A48,var(--sig));box-shadow:0 -4px 12px -4px rgba(255,106,26,.6)} .bars i.hi{background:linear-gradient(180deg,#FF8A48,var(--sig));box-shadow:0 -4px 12px -4px rgba(255,106,26,.6)}
.axis{display:flex;justify-content:space-between;font-family:var(--mono);font-size:10px;color:var(--muted)} .axis{display:flex;justify-content:space-between;font-family:var(--mono);font-size:10px;color:var(--muted)}
.spark{display:flex;gap:1px;align-items:end;height:12px} .spark i{display:block;width:5px;background:linear-gradient(180deg,var(--accent-dim),#A9CBFA);border-radius:1px 1px 0 0} .spark i.hi{background:linear-gradient(180deg,var(--accent),var(--accent-hi))} .spark{display:flex;gap:1px;align-items:end;height:12px} .spark i{display:block;width:5px;background:linear-gradient(180deg,var(--accent-dim),var(--accent-pale));border-radius:1px 1px 0 0} .spark i.hi{background:linear-gradient(180deg,var(--accent),var(--accent-hi))}
.sparkline{width:74px;height:26px;display:block} .sparkline polyline{fill:none;stroke:var(--accent);stroke-width:1.6;stroke-linejoin:round} .sparkline .fill{fill:rgba(31,111,235,.12);stroke:none} .sparkline{width:74px;height:26px;display:block} .sparkline polyline{fill:none;stroke:var(--accent);stroke-width:1.6;stroke-linejoin:round} .sparkline .fill{fill:color-mix(in srgb,var(--accent) 12%,transparent);stroke:none}
.tile.hi .sparkline polyline{stroke:var(--sig)} .tile.hi .sparkline .fill{fill:rgba(255,106,26,.12)} .tile.hi .sparkline polyline{stroke:var(--sig)} .tile.hi .sparkline .fill{fill:color-mix(in srgb,var(--sig) 12%,transparent)}
/* toast + modal */ /* toast + modal */
.toast{position:fixed;left:50%;bottom:20px;transform:translateX(-50%);background:var(--chrome);color:var(--chrome-ink);border:1px solid var(--chrome-line);border-left:3px solid var(--ok);padding:9px 14px;border-radius:6px;font-size:12px;font-weight:600;opacity:0;transition:opacity .2s;pointer-events:none;z-index:50;box-shadow:0 12px 30px -12px rgba(15,27,46,.6)} .toast{position:fixed;left:50%;bottom:20px;transform:translateX(-50%);background:var(--chrome);color:var(--chrome-ink);border:1px solid var(--chrome-line);border-left:3px solid var(--ok);padding:9px 14px;border-radius:6px;font-size:12px;font-weight:600;opacity:0;transition:opacity .2s;pointer-events:none;z-index:50;box-shadow:0 12px 30px -12px rgba(15,27,46,.6)}
.toast.bad{border-left-color:var(--sig)} .toast.bad{border-left-color:var(--sig)}
.toast.on{opacity:1} .toast.on{opacity:1}
.toast{max-width:min(92vw,620px);line-height:1.45;display:flex;align-items:flex-start;gap:10px}
.toast.on.bad{pointer-events:auto}
.toast-x{flex:none;background:none;border:0;color:inherit;font:inherit;font-size:16px;line-height:1;padding:0 2px;margin:-1px -4px 0 0;cursor:pointer;opacity:.75}
.toast-x:hover,.toast-x:focus-visible{opacity:1}
.modal-back{position:fixed;inset:0;background:rgba(11,20,36,.55);backdrop-filter:blur(2px);display:flex;align-items:center;justify-content:center;padding:16px;z-index:40} .modal-back{position:fixed;inset:0;background:rgba(11,20,36,.55);backdrop-filter:blur(2px);display:flex;align-items:center;justify-content:center;padding:16px;z-index:40}
.modal{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:18px;width:min(520px,100%);display:grid;gap:12px;box-shadow:0 30px 60px -30px rgba(15,27,46,.6)} .modal{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:18px;width:min(520px,100%);display:grid;gap:12px;box-shadow:var(--sh-lg)}
.modal h2{font-family:var(--display);font-size:20px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;margin:0;display:flex;align-items:center;gap:8px} .modal h2{font-family:var(--display);font-size:20px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;margin:0;display:flex;align-items:center;gap:8px}
.modal h2::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block} .modal h2::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block}
.modal .acts{display:flex;justify-content:flex-end;gap:8px} .modal .acts{display:flex;justify-content:flex-end;gap:8px}
@@ -189,20 +220,20 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
/* JetBrains Mono joins "//" into a ligature that reads as a missing slash in URLs (Marty 2026-10-07): no ligatures anywhere */ /* JetBrains Mono joins "//" into a ligature that reads as a missing slash in URLs (Marty 2026-10-07): no ligatures anywhere */
body,input,textarea,button,code,.mono{font-variant-ligatures:none;font-feature-settings:"liga" 0,"calt" 0} body,input,textarea,button,code,.mono{font-variant-ligatures:none;font-feature-settings:"liga" 0,"calt" 0}
/* chat widget on Control Room screens (2026-10-18: the bubble only lived on the retired /my dashboard) */ /* chat widget on Control Room screens (2026-10-18: the bubble only lived on the retired /my dashboard) */
#iapChatBtn{position:fixed;right:20px;bottom:44px;z-index:60;width:56px;height:56px;border-radius:50%;border:0;background:var(--accent,#3b9dff);color:#fff;font-size:24px;cursor:pointer;box-shadow:0 8px 28px rgba(20,60,140,.35)} #iapChatBtn{position:fixed;right:20px;bottom:44px;z-index:60;width:56px;height:56px;border-radius:50%;border:0;background:var(--accent,#3b9dff);color:var(--accent-ink,#fff);font-size:24px;cursor:pointer;box-shadow:0 8px 28px rgba(20,60,140,.35)}
#iapChatBtn:hover{transform:scale(1.06)} #iapChatBtn:hover{transform:scale(1.06)}
#iapChatPanel{position:fixed;right:20px;bottom:112px;z-index:60;width:min(360px,calc(100vw - 40px));background:#fff;color:var(--ink,#14213d);border:1px solid var(--line-strong,#c9d3e3);border-radius:16px;overflow:hidden;box-shadow:0 24px 60px rgba(10,20,50,.28);display:flex;flex-direction:column} #iapChatPanel{position:fixed;right:20px;bottom:112px;z-index:60;width:min(360px,calc(100vw - 40px));background:var(--panel,#fff);color:var(--ink,#14213d);border:1px solid var(--line-strong,#c9d3e3);border-radius:16px;overflow:hidden;box-shadow:0 24px 60px rgba(10,20,50,.28);display:flex;flex-direction:column}
#iapChatPanel .ch-head{padding:14px 16px;border-bottom:1px solid var(--line,#e2e8f2);font-family:var(--display,inherit);position:relative;font-weight:700} #iapChatPanel .ch-head{padding:14px 16px;border-bottom:1px solid var(--line,#e2e8f2);font-family:var(--display,inherit);position:relative;font-weight:700}
#iapChatPanel .ch-head .ch-sub{display:block;font-size:12px;font-weight:400;color:var(--muted,#64748b)} #iapChatPanel .ch-head .ch-sub{display:block;font-size:12px;font-weight:400;color:var(--muted,#64748b)}
#iapChatClose{position:absolute;right:10px;top:10px;background:transparent;border:0;color:var(--muted,#64748b);font-size:22px;cursor:pointer;line-height:1} #iapChatClose{position:absolute;right:10px;top:10px;background:transparent;border:0;color:var(--muted,#64748b);font-size:22px;cursor:pointer;line-height:1}
#iapChatPanel .ch-msgs{padding:14px;overflow-y:auto;max-height:340px;display:flex;flex-direction:column;gap:10px} #iapChatPanel .ch-msgs{padding:14px;overflow-y:auto;max-height:340px;display:flex;flex-direction:column;gap:10px}
#iapChatPanel .ch-m{border-radius:12px;padding:9px 13px;font-size:13.5px;line-height:1.5;max-width:86%} #iapChatPanel .ch-m{border-radius:12px;padding:9px 13px;font-size:13.5px;line-height:1.5;max-width:86%}
#iapChatPanel .ch-m.bot{background:rgba(59,157,255,.08);border:1px solid rgba(59,157,255,.22);align-self:flex-start} #iapChatPanel .ch-m.bot{background:var(--accent-soft);border:1px solid var(--accent-dim);align-self:flex-start}
#iapChatPanel .ch-m.me{background:#f1f4f9;border:1px solid var(--line,#e2e8f2);align-self:flex-end} #iapChatPanel .ch-m.me{background:var(--panel-2);border:1px solid var(--line,#e2e8f2);align-self:flex-end}
#iapChatPanel .ch-m a{word-break:break-all} #iapChatPanel .ch-m a{word-break:break-all}
#iapChatPanel .ch-input{display:flex;gap:8px;padding:11px;border-top:1px solid var(--line,#e2e8f2)} #iapChatPanel .ch-input{display:flex;gap:8px;padding:11px;border-top:1px solid var(--line,#e2e8f2)}
#iapChatPanel .ch-input input{flex:1;min-width:0;padding:9px 11px;border:1px solid var(--line-strong,#c9d3e3);border-radius:10px;font:inherit} #iapChatPanel .ch-input input{flex:1;min-width:0;padding:9px 11px;border:1px solid var(--line-strong,#c9d3e3);border-radius:10px;font:inherit;background:var(--field-bg);color:var(--ink)}
#iapChatPanel .ch-input button{background:var(--accent,#3b9dff);color:#fff;border:0;border-radius:10px;padding:0 16px;font-weight:700;cursor:pointer} #iapChatPanel .ch-input button{background:var(--accent,#3b9dff);color:var(--accent-ink,#fff);border:0;border-radius:10px;padding:0 16px;font-weight:700;cursor:pointer}
/* Stage + status colour (Orlando via Marty 2026-10-20): the Pipeline board's stage colours carried to Team rows, and a /* Stage + status colour (Orlando via Marty 2026-10-20): the Pipeline board's stage colours carried to Team rows, and a
matching traffic-light for ad status. --st drives the row stripe, the pill and the chip dot. */ matching traffic-light for ad status. --st drives the row stripe, the pill and the chip dot. */
@@ -211,11 +242,20 @@ body,input,textarea,button,code,.mono{font-variant-ligatures:none;font-feature-s
[data-st="bought"]{--st:#16a34a} [data-st="building"]{--st:#b7791f} [data-st="quiet"]{--st:#d97706} [data-st="bought"]{--st:#16a34a} [data-st="building"]{--st:#b7791f} [data-st="quiet"]{--st:#d97706}
[data-st="live"]{--st:#16a34a} [data-st="low"]{--st:#d97706} [data-st="out"]{--st:#dc2626} [data-st="paused"]{--st:#64748b} [data-st="sched"]{--st:#2563eb} [data-st="ended"]{--st:#94a3b8} [data-st="live"]{--st:#16a34a} [data-st="low"]{--st:#d97706} [data-st="out"]{--st:#dc2626} [data-st="paused"]{--st:#64748b} [data-st="sched"]{--st:#2563eb} [data-st="ended"]{--st:#94a3b8}
.tbl .rw.st-row{box-shadow:inset 4px 0 0 var(--st)} .tbl .rw.st-row{box-shadow:inset 4px 0 0 var(--st)}
.tbl .rw.st-row.stalled{background:#fffbeb} .tbl .rw.st-row.stalled{background:var(--note-bg)}
.stg{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;white-space:nowrap;border-radius:999px;padding:2px 9px;color:var(--st);background:color-mix(in srgb,var(--st) 11%,#fff);border:1px solid color-mix(in srgb,var(--st) 38%,#fff)} .stg{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;white-space:nowrap;border-radius:999px;padding:2px 9px;color:color-mix(in srgb,var(--st) 72%,var(--ink));background:color-mix(in srgb,var(--st) 11%,var(--panel));border:1px solid color-mix(in srgb,var(--st) 38%,var(--panel))}
.stg::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--st);flex:none} .stg::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--st);flex:none}
.stg.quiet{margin-top:4px;color:#92400e;background:#fef3c7;border-color:#f59e0b} .stg.quiet{margin-top:4px;color:var(--note-ink);background:var(--note-soft);border-color:var(--note-line)}
.chip[data-st]{display:inline-flex;align-items:center;gap:6px} .chip[data-st]{display:inline-flex;align-items:center;gap:6px}
.chip[data-st]::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--st);flex:none} .chip[data-st]::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--st);flex:none}
.chip[data-st].on{border-color:var(--st);color:#0f172a;background:color-mix(in srgb,var(--st) 13%,#fff)} .chip[data-st].on{border-color:var(--st);color:var(--ink);background:color-mix(in srgb,var(--st) 13%,var(--panel))}
.bar.st i{background:var(--st)} .bar.st i{background:var(--st)}
/* dark theme: the stage / status palette lifted so 10.5px pill text still clears 4.5:1 on dark panels */
:root[data-theme="dark"] [data-st]{--st:#8E9FB8}
:root[data-theme="dark"] [data-st="joined"],:root[data-theme="dark"] [data-st="sched"]{--st:#7AAAFF} :root[data-theme="dark"] [data-st="wallet"]{--st:#4FC3E6} :root[data-theme="dark"] [data-st="payouts"]{--st:#FF9A5C}
:root[data-theme="dark"] [data-st="bought"],:root[data-theme="dark"] [data-st="live"]{--st:#4CCB7A} :root[data-theme="dark"] [data-st="building"]{--st:#D9A441} :root[data-theme="dark"] [data-st="quiet"],:root[data-theme="dark"] [data-st="low"]{--st:#F0B44A}
:root[data-theme="dark"] [data-st="out"]{--st:#FF7B7B} :root[data-theme="dark"] [data-st="paused"]{--st:#8E9FB8} :root[data-theme="dark"] [data-st="ended"]{--st:#6F7F99}
/* theme switch (Light / Dark / Auto) in the topbar and on the Profile pane */
.theme-seg button{min-width:0}
.topbar .theme-seg{background:transparent;border-color:var(--chrome-line)} .topbar .theme-seg button{color:var(--chrome-sub);border-color:var(--chrome-line);padding:5px 10px;font-size:11px} .topbar .theme-seg button:hover{color:var(--chrome-ink)} .topbar .theme-seg button.on{background:var(--accent);color:var(--accent-ink)}
@media (max-width:760px){.topbar .theme-seg button{padding:5px 8px}}
+16 -8
View File
@@ -28,12 +28,16 @@
CR.tile({ k: 'Qualification', v: bc + ' of ' + (bc >= 5 ? 5 : bc >= 2 ? 5 : 2), note: bc >= 5 ? 'levels 2 and 3 open' : bc >= 2 ? 'level 2 open · 5 opens level 3' : 'buyers to open level 2' }) CR.tile({ k: 'Qualification', v: bc + ' of ' + (bc >= 5 ? 5 : bc >= 2 ? 5 : 2), note: bc >= 5 ? 'levels 2 and 3 open' : bc >= 2 ? 'level 2 open · 5 opens level 3' : 'buyers to open level 2' })
].join(''); ].join('');
} }
// the Monthly Refuel threshold in cents once fuel.js has the member's refuel view (2026-10-25); 0 while the switch is off
const rfMin = () => { const v = window.FUEL && window.FUEL.refuel; return v && v.on && v.minUsd ? Math.round(Number(v.minUsd.linkspin) * 100) : 0; };
window.LSCredits = { repaint: () => { if (CAT && CAT.length) paintPkgs(); } };
function paintPkgs() { function paintPkgs() {
const live = CAT.filter(p => p.active !== false && p.exists !== false); const live = CAT.filter(p => p.active !== false && p.exists !== false);
if (!live.length) { $('pkgs').innerHTML = '<div class="muted">No packages are on sale right now.</div>'; return; } if (!live.length) { $('pkgs').innerHTML = '<div class="muted">No packages are on sale right now.</div>'; return; }
if (!SEL) SEL = (live.find(p => p.priceCents === 2500) || live[0]).id; if (!SEL) SEL = (live.find(p => p.priceCents === 2500) || live[0]).id;
$('pkgs').innerHTML = live.map(p => '<button type="button" class="pk' + (p.id === SEL ? ' on' : '') + '" data-id="' + p.id + '"><span class="k">' + esc(NAMES[p.priceCents] || 'Package') + '</span><span class="price">' + usd(p.priceCents) + '</span><span class="cr">' + fmt(p.creditAmount) + ' credits</span>' $('pkgs').innerHTML = live.map(p => '<button type="button" class="pk' + (p.id === SEL ? ' on' : '') + '" data-id="' + p.id + '"><span class="k">' + esc(NAMES[p.priceCents] || 'Package') + '</span><span class="price">' + usd(p.priceCents) + '</span><span class="cr">' + fmt(p.creditAmount) + ' credits</span>'
+ (p.priceCents >= 2500 ? '<span class="tag ok">qualifies</span>' : '<span class="tag">does not qualify</span>') + '</button>').join(''); + (p.priceCents >= 2500 ? '<span class="tag ok">qualifies</span>' : '<span class="tag">does not qualify</span>')
+ (rfMin() && p.priceCents >= rfMin() ? '<span class="tag ok" title="A package this size counts as your monthly refuel (or a Pit Stop when this cycle is already refueled here)">counts for Refuel</span>' : '') + '</button>').join('');
$('pkgs').querySelectorAll('.pk').forEach(b => b.addEventListener('click', () => { SEL = Number(b.dataset.id); paintPkgs(); paintQuote(); paintGoes(); })); $('pkgs').querySelectorAll('.pk').forEach(b => b.addEventListener('click', () => { SEL = Number(b.dataset.id); paintPkgs(); paintQuote(); paintGoes(); }));
} }
const sel = () => CAT.find(p => p.id === SEL); const sel = () => CAT.find(p => p.id === SEL);
@@ -78,6 +82,7 @@
$('walletBox').innerHTML = addr $('walletBox').innerHTML = addr
? '<div class="code" style="display:block">' + esc(addr) + '</div>' ? '<div class="code" style="display:block">' + esc(addr) + '</div>'
+ (on ? '<div class="ok"><span class="dot"></span>Payouts on. Every package your people buy pays this wallet in the same transaction.</div>' + (on ? '<div class="ok"><span class="dot"></span>Payouts on. Every package your people buy pays this wallet in the same transaction.</div>'
: ME.tankHold ? '<div class="ink2" id="tankHoldNote" style="font-size:13px;color:var(--ok)">' + esc(tankHoldText(ME.tankHold)) + '</div>' // held for an adopter: no activate button
: '<div class="ink2" style="font-size:13px">Linked, but payouts are off until this wallet is on the contract. Buying a package does that. So does the free activation below (gas only).</div><div class="acts"><button class="btn blue" type="button" id="activateBtn">Switch on payouts (free)</button></div>') : '<div class="ink2" style="font-size:13px">Linked, but payouts are off until this wallet is on the contract. Buying a package does that. So does the free activation below (gas only).</div><div class="acts"><button class="btn blue" type="button" id="activateBtn">Switch on payouts (free)</button></div>')
+ '<div class="acts"><a class="btn sm" href="' + esc((CFG && CFG.explorer) || 'https://polygonscan.com') + '/address/' + esc(addr) + '" target="_blank" rel="noopener">Open on the explorer</a><button class="btn sm" type="button" id="switchBtn">Switch account</button><button class="btn sm" type="button" id="dropBtn">Disconnect</button></div>' + '<div class="acts"><a class="btn sm" href="' + esc((CFG && CFG.explorer) || 'https://polygonscan.com') + '/address/' + esc(addr) + '" target="_blank" rel="noopener">Open on the explorer</a><button class="btn sm" type="button" id="switchBtn">Switch account</button><button class="btn sm" type="button" id="dropBtn">Disconnect</button></div>'
+ posBlock() + posBlock()
@@ -141,8 +146,17 @@
} }
async function guard(btn, fn) { if (btn.disabled) return; btn.disabled = true; try { await fn(); } catch (e) { CR.toast((e && e.message) || 'Something went wrong.', true); } finally { btn.disabled = false; } } async function guard(btn, fn) { if (btn.disabled) return; btn.disabled = true; try { await fn(); } catch (e) { CR.toast((e && e.message) || 'Something went wrong.', true); } finally { btn.disabled = false; } }
// holding tank (2026-10-27): no sponsor yet, so the free Switch on payouts waits for an adopter (24 hours at most).
// A purchase is never held: buying goes ahead as before.
const holdLeft = ms => { const m = Math.max(1, Math.round(ms / 60000)); const h = Math.floor(m / 60); return h ? h + ' h ' + (m % 60) + ' min' : m + ' min'; };
function tankHoldText(h) {
let t = "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours).";
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
return t + ' Did someone invite you? Tell us in the Who invited you box.';
}
// a named sponsor that cannot be paid right now: hold the transaction and say why (never credit the company by default) // a named sponsor that cannot be paid right now: hold the transaction and say why (never credit the company by default)
function holdText(sp) { function holdText(sp) {
if (sp.sponsorBlocked === 'tankHold') return tankHoldText(sp.tankHold); // the free activation only (intent=activate), never a buy
const who = sp.sponsorName ? ('@' + String(sp.sponsorName).replace(/^@/, '')) : 'your sponsor'; const who = sp.sponsorName ? ('@' + String(sp.sponsorName).replace(/^@/, '')) : 'your sponsor';
if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. ') + 'Your first purchase waits until ' + (sp.claim.deadline ? new Date(sp.claim.deadline).toLocaleDateString() : 'they do') + ', then it goes ahead with the nearest member above who has one. Nothing was charged.'; if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. ') + 'Your first purchase waits until ' + (sp.claim.deadline ? new Date(sp.claim.deadline).toLocaleDateString() : 'they do') + ', then it goes ahead with the nearest member above who has one. Nothing was charged.';
if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts first (one free transaction).'; if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts first (one free transaction).';
@@ -151,7 +165,7 @@
} }
async function linkWallet() { CR.toast('Check your wallet for the free link signature…'); await IAPWallet.signIn(); CR.toast('Wallet linked. Earnings pay there from now on.'); await load(); } async function linkWallet() { CR.toast('Check your wallet for the free link signature…'); await IAPWallet.signIn(); CR.toast('Wallet linked. Earnings pay there from now on.'); await load(); }
async function activate() { async function activate() {
const sp = await CR.get('/api/sponsor?intent=buy'); if (sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; return; } const sp = await CR.get('/api/sponsor?intent=activate'); if (sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; if (sp.sponsorBlocked === 'tankHold') { ME.tankHold = sp.tankHold || {}; paintWallet(); } return; }
CR.toast('Confirm the free activation in your wallet…'); CR.toast('Confirm the free activation in your wallet…');
const r = await IAPWallet.activate(sp.sponsorId || 0); const r = await IAPWallet.activate(sp.sponsorId || 0);
if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Check the explorer.'); if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Check the explorer.');
@@ -194,12 +208,6 @@
} }
$('buyBtn').addEventListener('click', () => guard($('buyBtn'), buy)); $('buyBtn').addEventListener('click', () => guard($('buyBtn'), buy));
$('buyFrom').addEventListener('change', () => { FROM = $('buyFrom').value || 'main'; paintFrom(); paintQuote(); }); $('buyFrom').addEventListener('change', () => { FROM = $('buyFrom').value || 'main'; paintFrom(); paintQuote(); });
$('cardBtn').addEventListener('click', () => guard($('cardBtn'), async () => {
const p = sel(); const need = p && p.costWei ? Math.max(10, Math.ceil(Number(BigInt(p.costWei) / 1000000000000000000n)) + 3) : 30;
const q = '/api/moonpay-url?pol=' + need + (ME && ME.address ? '&address=' + encodeURIComponent(ME.address) : '');
const r = await CR.get(q); if (!r.url) throw new Error('The card on-ramp is not available right now.');
window.open(r.url, '_blank', 'noopener'); CR.toast('MoonPay opened in a new tab. POL lands straight in your own wallet.');
}));
async function load() { async function load() {
try { [CFG, ME] = await Promise.all([CR.get('/api/config'), CR.me(true)]); } catch (e) { CR.sub('could not load'); return; } try { [CFG, ME] = await Promise.all([CR.get('/api/config'), CR.me(true)]); } catch (e) { CR.sub('could not load'); return; }
+82
View File
@@ -0,0 +1,82 @@
// The Engine Room (2026-10-24). The SAME file ships in InstantAdPay (Members > Engine Room) and LinkSpin (Ads screen panel).
// Plain dials, real numbers, colour only for warnings. Renders into #erRoot from /api/my/engine; hidden while the
// refuelStreak switch is off. Unlocked by the first counted refuel, greyed "Refuel to start your engine" until then.
(function () {
const root = document.getElementById('erRoot'); if (!root) return;
const host = document.getElementById(root.dataset.host || 'erPanel');
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const n = v => Number(v || 0).toLocaleString('en-US');
// a link on this site becomes a plain path; a link to the other site carries ?from=<this site>&task=<job> so the other
// site opens with an arrival strip naming the job and its first step (2026-10-25, Marty lost the thread on LinkSpin)
const TASK = { tracking: 'conversions', start: 'refuel', refuel: 'refuel', pitstop: 'refuel', bannerspin: 'bannerspin', testing: 'testing', relaunch: 'ads', topup: 'ads', cut: 'ads', cruise: 'ads' };
let FROM = 'iap';
const siteOf = u => /linkspin/i.test(u.host) ? 'linkspin' : 'iap'; // which site a link belongs to, by its host (also right on a local copy)
// a link to the other site goes through this site's /go/<other> hop (network sign-in, 2026-11-12): the member arrives signed in
const go = (url, task) => { try { const u = new URL(url); if (u.host === location.host || siteOf(u) === FROM) return u.pathname + u.search + u.hash; if (task) { u.searchParams.set('from', FROM); u.searchParams.set('task', task); } return '/go/' + (FROM === 'iap' ? 'linkspin' : 'iap') + '?to=' + encodeURIComponent(u.pathname + u.search + u.hash); } catch (e) { return url; } };
// "Refuel LinkSpin this cycle..." gets a way there (2026-10-25): the other site's buy screen, tagged for its arrival strip
const otherBuy = note => { const m = /^Refuel (LinkSpin|InstantAdPay) /.exec(note || ''); if (!m) return '';
const url = m[1] === 'LinkSpin' ? 'https://linkspin.app/credits#refuel' : 'https://instantadpay.com/my#buy';
return ' <a href="' + esc(go(url, 'refuel')) + '">Refuel ' + m[1] + (ext(url) ? ' &#8599;' : '') + '</a>'; };
const ext = url => { try { const u = new URL(url); return u.host !== location.host && siteOf(u) !== FROM; } catch (e) { return false; } };
const css = '.er{display:grid;gap:14px}.er-locked{opacity:.45;filter:grayscale(1);pointer-events:none}.er-dials{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:12px}'
+ '.er-dial{border:1px solid rgba(127,127,127,.3);border-radius:10px;padding:10px 12px;text-align:center;min-width:0}.er-dial svg{width:100%;max-width:200px;height:auto;display:block;margin:0 auto}'
+ '.er-dial .v{font-size:22px;font-weight:700;margin-top:-6px}.er-dial .c{font-size:12px;opacity:.8}.er-row{display:flex;flex-wrap:wrap;gap:8px}'
+ '.er-light{display:flex;gap:6px;align-items:center;border:1px solid rgba(127,127,127,.3);border-radius:999px;padding:4px 10px;font-size:12.5px}.er-dot{width:10px;height:10px;border-radius:50%;background:rgba(127,127,127,.45);flex:none}'
+ '.er-dot.on{background:var(--warn,#e8a317)}.er-dot.green{background:var(--ok,#2fa36b)}.er-dot.amber{background:var(--warn,#e8a317)}.er-dot.grey{background:rgba(127,127,127,.45)}.er-parts{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr));gap:8px}'
+ '.er-part{border:1px solid rgba(127,127,127,.3);border-radius:8px;padding:8px 10px;font-size:13px;display:grid;gap:3px;min-width:0}.er-part b{display:flex;flex-wrap:wrap;gap:2px 6px;align-items:center}.er-next{border:1px solid rgba(127,127,127,.4);border-radius:10px;padding:12px;display:flex;gap:12px;align-items:center;flex-wrap:wrap}'
+ '.er-next .w{flex:1 1 220px;font-size:13px}.er-h{font-size:12px;letter-spacing:.06em;text-transform:uppercase;opacity:.75;margin:0}.er-streak{font-size:13.5px;line-height:1.5}.er-goal{display:flex;gap:6px;align-items:center;justify-content:center;margin-top:6px;font-size:12px}.er-goal input{width:70px}';
if (!document.getElementById('erCss')) { const st = document.createElement('style'); st.id = 'erCss'; st.textContent = css; document.head.appendChild(st); }
// a plain 180-degree dial; pct null = no reading
function dial(pct, value, caption, aria, warn) {
const p = pct == null ? 0 : Math.max(0, Math.min(100, pct));
const a = Math.PI * (1 - p / 100); const x = 100 + 80 * Math.cos(a), y = 100 - 80 * Math.sin(a);
const col = warn ? 'var(--warn,#e8a317)' : 'currentColor';
return '<div class="er-dial" role="img" aria-label="' + esc(aria) + '"><svg viewBox="0 0 200 112" aria-hidden="true"><path d="M20 100 A80 80 0 0 1 180 100" fill="none" stroke="rgba(127,127,127,.3)" stroke-width="14" stroke-linecap="round"/>'
+ (pct == null ? '' : '<path d="M20 100 A80 80 0 0 1 ' + x.toFixed(1) + ' ' + y.toFixed(1) + '" fill="none" stroke="' + col + '" stroke-width="14" stroke-linecap="round"/>') + '</svg>'
+ '<div class="v">' + esc(value) + '</div><div class="c">' + caption + '</div></div>';
}
function view(d) {
const f = d.fuel, c = d.clicks, g = d.goals, s = d.streak;
const fuelCap = (f.refuelCredits ? n(f.left) + ' of ' + n(f.refuelCredits) + ' credits this cycle' : n(f.left) + ' credits on both sites') + (f.daysLeft != null ? '<br>about ' + n(f.daysLeft) + ' days at your burn (' + n(f.burnPerDay) + ' a day)' : '');
const fuelAria = 'Fuel left: ' + n(f.left) + ' credits' + (f.pct != null ? ', ' + f.pct + ' percent of this cycle’s refuel' : '') + (f.daysLeft != null ? ', about ' + f.daysLeft + ' days at your current burn' : '');
const clickCap = (c.prevWeek ? 'last week: ' + n(c.prevWeek) + ' (half way = the same)<br>' : '') + (c.per1000 != null ? n(c.per1000) + ' clicks per 1,000 credits' : 'clicks per 1,000 credits: not enough delivery yet') + '<br>all ads, both sites';
const goalCap = (g.month == null ? 'LinkSpin did not answer' : g.tracking ? (g.target ? 'goal: ' + n(g.target) + ' this month' : 'set a goal for the month') : 'set up conversion tracking') + '<span class="er-goal"><label>goal <input type="number" min="0" max="100000" data-er-goal value="' + (g.target || '') + '" aria-label="Your goal for this month"></label><button class="btn small sec" type="button" data-er-save>Save</button></span>';
const dials = '<div class="er-dials">'
+ dial(f.pct, f.pct != null ? f.pct + '%' : n(f.left), 'Fuel left<br>' + fuelCap, fuelAria, f.daysLeft != null && f.daysLeft < 5)
+ dial(c.pct, n(c.week), 'Clicks this week<br>' + clickCap, 'Clicks this week: ' + n(c.week) + (c.prevWeek ? ', last week ' + n(c.prevWeek) : '') + (c.per1000 != null ? ', ' + c.per1000 + ' per 1,000 credits' : ''), false)
+ dial(g.pct, g.month == null ? '?' : n(g.month), 'Goals this month<br>' + goalCap, 'Goals this month: ' + (g.month == null ? 'unknown' : g.month) + (g.target ? ' of ' + g.target : ''), false) + '</div>';
const streak = '<div class="er-streak"><p class="er-h">Streak</p>' + (s.active ? '<b>' + s.months + ' month' + (s.months === 1 ? '' : 's') + '</b>' + (s.both ? ', both engines this cycle' : '') + '. Refuel day <b>' + esc(s.refuelDay) + '</b>, grace to ' + esc(s.graceEnd) + ' (Central).'
+ (typeof s.note === 'string' ? (s.note ? ' ' + esc(s.note) + otherBuy(s.note) : '') : s.next ? (s.windowOpen ? ' Window open: next refuel +' + s.next.single + '% (+' + s.next.both + '% on each with both).' : s.both ? ' Both engines fueled this cycle.' : s.next.secondEngine ? ' Refuel the other site this cycle for +' + s.next.secondEngine + '% on both.' : '') : '') // s.note from engine.js (2026-10-24: no 'refuel the other site' once both are done)
+ (s.pitStop ? ' Pit Stop: +' + s.pitStop.pct + '% ' + (s.pitStop.iap || s.pitStop.linkspin ? 'available' : 'used') + ' this cycle.' : '') + (s.best > s.months ? ' Best: ' + s.best + '.' : '') : 'Not started.') + '</div>';
const warns = '<div><p class="er-h">Warning lights</p><div class="er-row">' + d.warnings.map(w => '<span class="er-light" title="' + esc(w.note) + '"><span class="er-dot' + (w.on ? ' on' : '') + '" aria-hidden="true"></span>' + esc(w.label) + ': ' + (w.on ? '<b>on</b>' : 'off') + '<span class="sr" style="position:absolute;left:-9999px"> (' + esc(w.note) + ')</span></span>').join('') + '</div></div>';
const parts = '<div><p class="er-h">The six parts</p><div class="er-parts">' + d.parts.map(p => '<div class="er-part"><b><span class="er-dot ' + p.state + '" aria-hidden="true"></span>' + esc(p.label) + ' <span style="font-weight:400;opacity:.75">(' + (p.state === 'green' ? 'working' : p.state === 'amber' ? 'needs attention' : 'not started') + ')</span></b><span>' + esc(p.note) + '</span>'
+ (p.state !== 'green' && p.link ? '<a href="' + esc(go(p.link, p.key)) + '">' + (p.state === 'grey' ? 'Set it up' : 'Fix it') + (ext(p.link) ? ' on ' + (FROM === 'iap' ? 'LinkSpin' : 'InstantAdPay') + ' &#8599;' : '') + '</a>' : '') + '</div>').join('') + '</div></div>';
const nextLink = go(d.next.link, TASK[d.next.key]);
const next = '<div class="er-next"><div class="w"><p class="er-h">Next move</p><b>' + esc(d.next.label) + '</b><br>' + esc(d.next.why)
+ (d.next.guide ? '<br><a href="' + esc(d.next.guide) + '" target="_blank" rel="noopener" style="font-size:12.5px">' + (d.next.key === 'tracking' ? 'Step-by-step setup guide' : 'How the Refuel streak works') + '</a>' : '') + '</div>'
+ '<a class="btn' + (d.locked ? '' : ' pri') + '" href="' + esc(nextLink) + '">' + esc(d.next.label) + (ext(d.next.link) ? ' on ' + (FROM === 'iap' ? 'LinkSpin' : 'InstantAdPay') : '') + '</a></div>';
const how = d.next.guide === '/refuel' ? '' : '<p style="margin:0;font-size:12.5px"><a href="/refuel" target="_blank" rel="noopener">How the Refuel streak works</a></p>'; // the member guide (2026-10-24)
if (d.locked) return '<div class="er">' + next + how + '<div class="er-locked" aria-hidden="true">' + dials + warns + parts + '</div></div>';
return '<div class="er">' + next + dials + streak + how + warns + parts + '<p class="small muted" style="margin:0;font-size:12px;opacity:.75">Numbers cover InstantAdPay and LinkSpin together' + (d.sites && (!d.sites.iap || !d.sites.linkspin) ? ' (one site did not answer just now)' : '') + '. Credits buy ad delivery only.</p></div>';
}
async function load(fresh) {
try {
const d = await (await fetch('/api/my/engine' + (fresh ? '?fresh=1' : ''), { cache: 'no-store' })).json();
window.FUEL = window.FUEL || {}; window.FUEL.engine = d;
if (!d || !d.on) { if (host) host.hidden = true; return; }
if (host) host.hidden = false;
if (d.error) { root.innerHTML = '<p class="small muted">' + esc(d.error) + '</p>'; return; }
FROM = d.site === 'linkspin' ? 'linkspin' : 'iap';
root.innerHTML = view(d);
const save = root.querySelector('[data-er-save]');
if (save) save.addEventListener('click', async () => {
const v = root.querySelector('[data-er-goal]').value; save.disabled = true;
try { const r = await (await fetch('/api/my/engine/goal', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ goal: Number(v) || 0 }) })).json(); if (r.error) throw new Error(r.error); load(true); }
catch (e) { save.disabled = false; save.textContent = 'Try again'; }
});
} catch (e) { if (host) host.hidden = true; }
}
window.ENGINE_ROOM = { load };
load(); setInterval(() => { if (!document.hidden) load(); }, 120000);
window.addEventListener('cr:signedin', () => load(true)); // LinkSpin's in-shell sign-in: the panel loaded signed out
})();
+109
View File
@@ -0,0 +1,109 @@
// Fuel Your Offers (2026-10-24), LinkSpin: the Monthly Refuel panel on Credits and Ads. The streak lives on InstantAdPay
// and is shared by both sites; /api/my/refuel relays InstantAdPay's view. Hidden while the refuelStreak switch is off.
(function () {
const $ = id => document.getElementById(id);
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const n = v => Number(v || 0).toLocaleString('en-US');
window.FUEL = window.FUEL || {};
const HOW = '<p class="muted" style="margin:10px 0 0"><a href="/refuel" target="_blank" rel="noopener">How the Refuel streak works</a>' + (location.pathname === '/ads' ? '' : ' &middot; <a href="/ads#engine">Engine Room</a>') + '</p>'; // the member guide (2026-10-24); Engine Room link (2026-10-25)
// the one action, said plainly (2026-10-25): which package counts, and a button that lands on the package picker
const buyBtn = (v, label, pri) => '<p style="margin:0 0 8px">Any package of <b>$' + v.minUsd.linkspin + ' or more</b> here counts (marked <b>counts for Refuel</b> under Buy a package).</p>'
+ '<a class="btn' + (pri ? ' pri' : '') + '" href="/credits#buy" data-rf-buy>' + label + '</a>';
function site(name, s, minUsd) {
const row = '<div class="row" style="display:flex;justify-content:space-between;align-items:baseline;gap:4px 12px;flex-wrap:wrap;padding:3px 0"><span>' + name + ':</span> '; // own spacing: the Ads screen has no .row rule (2026-10-24)
return s && s.refueled ? row + '<b>+' + s.pct + '% &middot; ' + n(s.bonus) + ' bonus credits</b></div>'
: row + '<span class="muted">not yet ($' + minUsd + '+ counts)</span></div>';
}
function body(v) {
if (v.error) return '<p class="muted">' + esc(v.error) + '</p>';
if (!v.active) {
return '<p style="margin:0 0 8px">' + (v.started ? 'Your last streak ended. ' : '') + 'A package of <b>$' + v.minUsd.linkspin + ' or more</b> here, or $' + v.minUsd.iap + '+ on InstantAdPay, ' + (v.started ? 'starts it again' : 'starts your monthly refuel streak and sets your own refuel day') + '.</p>'
+ '<p class="muted" style="margin:0 0 10px">Bonus ad credits: month 1 +' + v.ladder.single[0] + '%, then +' + v.ladder.single.slice(1).join('%, +') + '%. Refuel both sites in the same cycle and each gets +' + v.ladder.both.join('%, +') + '%.</p>'
+ buyBtn(v, 'Buy a $' + v.minUsd.linkspin + '+ package to start', true) + HOW;
}
const c = v.cycle || {};
let h = v.windowOpen
? '<p style="margin:0 0 8px"><b>Your refuel window is open.</b> Refuel day <b>' + esc(v.refuelDayLabel) + '</b>, grace to ' + esc(v.graceLabel) + ' (Central). Next refuel: +' + v.next.single + '%, or +' + v.next.both + '% on each site with both.</p>'
: '<p style="margin:0 0 8px">Next refuel day <b>' + esc(v.refuelDayLabel) + '</b> (Central). Window opens ' + esc(v.opensLabel) + ', grace to ' + esc(v.graceLabel) + '.</p>';
if (c.month) h += '<div style="margin:0 0 8px">' + site('InstantAdPay', c.iap, v.minUsd.iap) + site('LinkSpin', c.linkspin, v.minUsd.linkspin) + '</div>';
if (!v.windowOpen && c.month && !c.both) h += '<p class="muted" style="margin:0 0 8px">Refuel ' + (c.linkspin && c.linkspin.refueled ? 'InstantAdPay ($' + v.minUsd.iap + '+)' : 'LinkSpin ($' + v.minUsd.linkspin + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to +' + v.next.secondEngine + '%.'
+ (c.linkspin && c.linkspin.refueled ? ' <a href="/go/iap?to=%2Fmy%23buy" target="_blank" rel="noopener">Buy on InstantAdPay &#8599;</a>' : '') + '</p>';
if (v.pitStop && (v.pitStop.linkspin || v.pitStop.usedLinkspin)) h += '<p class="muted" style="margin:0 0 8px"><b>Pit Stop</b> ' + (v.pitStop.linkspin ? 'available here: +' + v.pitStop.pct + '% on a $' + v.minUsd.linkspin + '+ top-up, once this cycle. It does not count as your refuel.' : 'used here this cycle.') + '</p>';
h += '<p class="muted" style="margin:0 0 10px">' + (v.freeMiss.available ? 'One free miss left this year.' : 'Free miss for this year used.') + '</p>';
const lsDone = c.linkspin && c.linkspin.refueled;
return h + buyBtn(v, v.windowOpen ? 'Refuel now: buy a $' + v.minUsd.linkspin + '+ package' : lsDone ? 'Buy another package' : 'Buy a $' + v.minUsd.linkspin + '+ package', v.windowOpen || !lsDone) + HOW;
}
async function load() {
const panel = $('rfPanel'); if (!panel) return;
try {
const v = await (await fetch('/api/my/refuel', { cache: 'no-store' })).json();
window.FUEL.refuel = v;
if (!v || !v.on) { panel.hidden = true; return; }
$('rfMeta').textContent = v.active ? 'streak: ' + v.streak + ' month' + (v.streak === 1 ? '' : 's') : 'shared with InstantAdPay';
$('rfBody').innerHTML = body(v); panel.hidden = false;
// on Credits the button just scrolls to the package picker (no reload); the picker then marks which packages count
panel.querySelectorAll('[data-rf-buy]').forEach(a => a.addEventListener('click', e => { if (location.pathname !== '/credits') return; e.preventDefault(); history.replaceState(null, '', location.pathname + location.search + '#buy'); window.dispatchEvent(new HashChangeEvent('hashchange')); }));
if (window.LSCredits) window.LSCredits.repaint();
} catch (e) { panel.hidden = true; }
}
window.FUEL.loadRefuel = load;
load(); setInterval(load, 300000);
// ---- the Refuel Kit: members-only LinkSpin banners with your @name and a QR to your link ----
const post = async (url, body) => { const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }); const j = await r.json().catch(() => ({})); if (!r.ok || j.error) throw new Error(j.error || ('HTTP ' + r.status)); return j; };
const note = (el, m) => { if (el) el.textContent = m; };
// Banner Spin sizes to load (2026-10-24): each size needs its own Banner Spin, and a Starter tier holds 2, so the sizes that
// fit are ticked first (728x90 and 300x250 when nothing is set up yet) and the panel says why before the member presses Load
function spinPick(k, d) {
const R = d.spinRoom; const sizes = k.sizes.filter(s => s.ready && (!R || !R.sizes || R.sizes.includes(s.size))).map(s => s.size).filter(z => z !== '1200x630');
if (!sizes.length) return '';
const pick = R && R.ok && R.suggested ? R.suggested : sizes;
const note = R && R.ok && !R.all ? '<p class="muted" style="margin:0 0 6px">Each size goes into its own Banner Spin. Your ' + esc(R.tier) + ' tier holds ' + R.spins + ' (' + R.used + ' in use), so the sizes that fit are ticked. Untick one to load another instead' + (R.next ? ', or reach ' + esc(R.next.label) + ' (' + esc(R.next.need) + ') for ' + R.next.spins : '') + '.</p>' : '';
return note + '<div style="display:flex;gap:6px 14px;flex-wrap:wrap;margin:0 0 8px">' + sizes.map(z => '<label class="muted" style="display:flex;gap:4px;align-items:center"><input type="checkbox" data-ksize="' + esc(k.month) + '" value="' + z + '"' + (pick.includes(z) ? ' checked' : '') + '> ' + z + '</label>').join('') + '</div>';
}
function kitHtml(k, d) {
const head = '<div style="display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap"><b>' + esc(k.label) + (k.theme ? ' &middot; ' + esc(k.theme) : '') + '</b><span class="muted">' + (k.unlocked ? 'yours' : 'locked') + '</span></div>';
if (!k.unlocked) return head + '<p class="muted" style="margin:6px 0 0">Your next counted refuel unlocks it: $25+ here or $20+ on InstantAdPay' + (d.nextRefuel ? ' (refuel day ' + esc(d.nextRefuel) + ')' : '') + '.</p>';
return head + '<p class="muted" style="margin:6px 0">Your ' + esc(d.name || 'name') + ' and a QR to your link on every banner. Yours to keep after the month.</p>'
+ spinPick(k, d)
+ '<div style="display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px"><button class="btn pri" type="button" data-kbs="' + esc(k.month) + '">Load into my Banner Spin</button>'
+ (k.gif ? '<label class="muted" style="display:flex;gap:4px;align-items:center"><input type="checkbox" data-kgif="' + esc(k.month) + '"> animated</label>' : '') + '</div>'
+ '<div class="muted" data-kres="' + esc(k.month) + '" role="status"></div>'
+ '<div style="display:grid;gap:8px">' + k.sizes.filter(s => s.ready).map(s => '<div data-kcell data-month="' + esc(k.month) + '" data-size="' + s.size + '" style="border:1px solid var(--line);border-radius:6px;padding:8px;min-width:0">'
+ '<div style="display:flex;justify-content:space-between;gap:6px;align-items:center"><span class="mono" style="font-size:11px">' + s.size + '</span><button class="btn" type="button" data-kmake>Make mine</button></div><div data-kimg style="margin-top:6px"></div></div>').join('') + '</div>';
}
async function loadKits() {
const panel = $('rkPanel'); if (!panel) return;
try {
const d = await (await fetch('/api/my/kits', { cache: 'no-store' })).json();
if (!d || !d.on || !d.kits || !d.kits.length) { panel.hidden = true; return; }
$('rkBody').innerHTML = d.kits.slice(0, 3).map(k => '<div style="margin-bottom:14px">' + kitHtml(k, d) + '</div>').join('')
+ (d.customNote ? '<p class="muted"><b>Custom banners credit:</b> ' + esc(d.customNote) + '</p>' : '') + '<p class="muted" style="margin:0">Ad credits buy delivery only. No banner may promise income.</p>';
panel.hidden = false;
panel.querySelectorAll('[data-kbs]').forEach(b => b.addEventListener('click', async () => {
const m = b.dataset.kbs; const out = panel.querySelector('[data-kres="' + m + '"]'); const g = panel.querySelector('[data-kgif="' + m + '"]');
b.disabled = true; note(out, 'Drawing your banners and loading them...');
try {
const boxes = panel.querySelectorAll('[data-ksize="' + m + '"]'); const sizes = Array.prototype.filter.call(boxes, c => c.checked).map(c => c.value);
if (boxes.length && !sizes.length) { note(out, 'Tick at least one size to load.'); b.disabled = false; return; }
const r = await post('/api/my/kits/bannerspin', Object.assign({ month: m, variant: g && g.checked ? 'gif' : 'still' }, boxes.length ? { sizes } : {}));
note(out, (r.message || r.results.map(x => x.size + ': ' + (x.error ? x.error : x.already ? 'already in "' + x.spin + '"' : (x.created ? 'new Banner Spin "' : 'added to "') + x.spin + '"')).join(' | ')) + ' See Banner Spin under Links.');
} catch (e) { note(out, e.message); }
b.disabled = false;
}));
panel.querySelectorAll('[data-kmake]').forEach(b => b.addEventListener('click', async () => {
const cell = b.closest('[data-kcell]'); b.disabled = true;
try {
const g = panel.querySelector('[data-kgif="' + cell.dataset.month + '"]');
const r = await post('/api/my/kits/render', { month: cell.dataset.month, size: cell.dataset.size, variant: g && g.checked && cell.dataset.size !== '1200x630' ? 'gif' : 'still' });
cell.querySelector('[data-kimg]').innerHTML = '<img src="' + esc(r.url) + '" alt="Your ' + esc(r.size) + ' Refuel Kit banner" style="max-width:100%;height:auto;display:block"><div style="display:flex;gap:6px;flex-wrap:wrap;margin-top:6px"><a class="btn" href="' + esc(r.url) + '" download>Download</a><button class="btn" type="button" data-kcopy="' + esc(r.abs) + '">Copy image link</button></div>';
const c = cell.querySelector('[data-kcopy]'); c.addEventListener('click', () => { try { navigator.clipboard.writeText(c.dataset.kcopy); c.textContent = 'Copied'; } catch (e) {} });
} catch (e) { cell.querySelector('[data-kimg]').textContent = e.message; }
b.disabled = false;
}));
} catch (e) { panel.hidden = true; }
}
window.FUEL.loadKits = loadKits;
loadKits();
window.addEventListener('cr:signedin', () => { load(); loadKits(); }); // signed in from the shell's pop-up (arrivals from InstantAdPay)
})();
+23
View File
@@ -37,7 +37,9 @@
+ '<label>What is it about?<select class="field" id="hnCat">' + CATS.map(c => '<option>' + esc(c) + '</option>').join('') + '</select></label>' + '<label>What is it about?<select class="field" id="hnCat">' + CATS.map(c => '<option>' + esc(c) + '</option>').join('') + '</select></label>'
+ '<label>Subject<input class="field" id="hnSubject" maxlength="140" placeholder="A few words, like: my spin link stopped rotating"></label>' + '<label>Subject<input class="field" id="hnSubject" maxlength="140" placeholder="A few words, like: my spin link stopped rotating"></label>'
+ '<label>Message<textarea class="field" id="hnBody" rows="6" maxlength="5000" placeholder="What happened, what you expected, and anything you already tried. Never send your recovery phrase or private key."></textarea></label>' + '<label>Message<textarea class="field" id="hnBody" rows="6" maxlength="5000" placeholder="What happened, what you expected, and anything you already tried. Never send your recovery phrase or private key."></textarea></label>'
+ '<div id="hnSuggest" class="hsg" hidden aria-live="polite"></div>'
+ '<div class="acts"><button class="btn pri" type="button" id="hnSend">Send to support</button><button class="btn" type="button" id="hnCancel">Cancel</button><span class="hmsg" id="hnMsg"></span></div></div>'; + '<div class="acts"><button class="btn pri" type="button" id="hnSend">Send to support</button><button class="btn" type="button" id="hnCancel">Cancel</button><span class="hmsg" id="hnMsg"></span></div></div>';
suggest();
$('hnCancel').addEventListener('click', () => { box.hidden = true; box.innerHTML = ''; }); $('hnCancel').addEventListener('click', () => { box.hidden = true; box.innerHTML = ''; });
const send = $('hnSend'); const send = $('hnSend');
send.addEventListener('click', async () => { send.addEventListener('click', async () => {
@@ -50,6 +52,27 @@
}); });
$('hnSubject').focus(); $('hnSubject').focus();
} }
// help answers while typing (2026-11-16): debounced, from the KB only (the hub's semantic match); a suggestion never blocks Send
function suggest() {
const box = $('hnSuggest'), subj = $('hnSubject'), body = $('hnBody');
if (!box || !subj || !body) return;
let timer = null, seq = 0, last = '';
const run = async () => {
const text = (subj.value + ' ' + body.value).replace(/\s+/g, ' ').trim();
if (text.replace(/[^A-Za-z0-9]/g, '').length < 10) { box.hidden = true; box.innerHTML = ''; last = ''; return; }
if (text === last) return; last = text; const mine = ++seq;
let r; try { r = await CR.api('/api/my/support/suggest', { subject: subj.value, body: body.value }); } catch (e) { return; }
if (mine !== seq || !document.body.contains(box)) return;
const items = (r && r.items) || [];
if (!items.length) { box.hidden = true; box.innerHTML = ''; return; }
box.innerHTML = '<p class="hsg-h"><b>These answers may help</b> <span>You can still send your ticket.</span></p>'
+ items.map(i => '<details><summary>' + esc(i.title) + (i.site ? ' <span class="hsg-s">(' + esc(i.site) + ')</span>' : '') + (i.fromTicket ? ' <span class="hsg-s">from a past ticket</span>' : '') + '</summary>'
+ '<div class="hsg-b">' + linkify(i.answer) + (i.link && i.site ? '<br><a href="' + esc(i.link) + '" target="_blank" rel="noopener">Open ' + esc(i.site) + '</a>' : '') + '</div></details>').join('');
box.hidden = false;
};
const kick = () => { clearTimeout(timer); timer = setTimeout(run, 700); };
subj.addEventListener('input', kick); body.addEventListener('input', kick);
}
async function open(ref) { async function open(ref) {
host().innerHTML = '<div class="panel"><span class="muted">loading</span></div>'; host().innerHTML = '<div class="panel"><span class="muted">loading</span></div>';
let v; try { v = await CR.get('/api/my/support/' + encodeURIComponent(ref)); } let v; try { v = await CR.get('/api/my/support/' + encodeURIComponent(ref)); }
+11
View File
@@ -89,3 +89,14 @@
finally { $('verifyBtn').disabled = false; } finally { $('verifyBtn').disabled = false; }
}); });
})(); })();
// Signed in already (an email code here, or network sign-in from InstantAdPay): the header buttons open the dashboard instead of
// offering Sign in / Start free again (Marty 2026-11-13: arrived signed in from InstantAdPay and the home page still said Sign in)
(function () {
fetch('/api/me', { credentials: 'same-origin', cache: 'no-store' }).then(r => r.json()).then(me => {
if (!me || !me.signedIn) return;
const btns = document.querySelectorAll('header [data-join]');
if (btns.length) { btns[0].textContent = 'Open my dashboard'; btns[0].href = '/ads'; btns[0].removeAttribute('data-join'); btns[0].className = 'btn pri'; }
for (let i = 1; i < btns.length; i++) btns[i].hidden = true;
}).catch(() => {});
})();
+3 -2
View File
@@ -13,10 +13,11 @@
ledger: { eyebrow: 'No back office', h: 'No back office. <em>No payday.</em>', lead: 'Your last program paid you on the 15th, if it paid you. Here every payout is a public transaction on Polygon you can read yourself, and the contract holds zero balance.', points: ['Every payout is public. Click it, read it, verify it.', 'The contract has no pause button and no owner power over money.', 'Join free by email. The ledger is one click from your dashboard.'], cta: 'Check the ledger yourself, then decide', sub: 'free account by email' }, ledger: { eyebrow: 'No back office', h: 'No back office. <em>No payday.</em>', lead: 'Your last program paid you on the 15th, if it paid you. Here every payout is a public transaction on Polygon you can read yourself, and the contract holds zero balance.', points: ['Every payout is public. Click it, read it, verify it.', 'The contract has no pause button and no owner power over money.', 'Join free by email. The ledger is one click from your dashboard.'], cta: 'Check the ledger yourself, then decide', sub: 'free account by email' },
two: { eyebrow: 'The referral side, exactly as coded', h: 'Two buyers open <em>level two.</em>', lead: 'Every direct buyer pays you half of their package from their very first purchase. Two qualifying buyers open level two at 20 percent. Five open level three at 10 percent. Constants in a verified contract.', points: ['Half of every direct purchase, instantly.', 'Level 2 at two qualifying buyers, level 3 at five.', 'Your invite link is live the moment you are in.'], cta: 'Start your line. Two buyers is the target.', sub: 'free account by email' }, two: { eyebrow: 'The referral side, exactly as coded', h: 'Two buyers open <em>level two.</em>', lead: 'Every direct buyer pays you half of their package from their very first purchase. Two qualifying buyers open level two at 20 percent. Five open level three at 10 percent. Constants in a verified contract.', points: ['Half of every direct purchase, instantly.', 'Level 2 at two qualifying buyers, level 3 at five.', 'Your invite link is live the moment you are in.'], cta: 'Start your line. Two buyers is the target.', sub: 'free account by email' },
links: { video: 'links', eyebrow: 'One link, every page you promote', h: 'Stop <em>juggling links.</em>', lead: 'One short link stands in for all of yours. Behind it, the pages you promote, served in turn by the weights you set, with hours, caps and a fallback. The link never changes, so every copy out in the world keeps working.', points: ['Weights, hours of the day, daily caps, a fallback.', 'A report by source, country and device; your tracker click id filled in.', 'Free. Try a spin on the home page with no account.'], cta: 'Make your first spin link', sub: 'free account by email' }, links: { video: 'links', eyebrow: 'One link, every page you promote', h: 'Stop <em>juggling links.</em>', lead: 'One short link stands in for all of yours. Behind it, the pages you promote, served in turn by the weights you set, with hours, caps and a fallback. The link never changes, so every copy out in the world keeps working.', points: ['Weights, hours of the day, daily caps, a fallback.', 'A report by source, country and device; your tracker click id filled in.', 'Free. Try a spin on the home page with no account.'], cta: 'Make your first spin link', sub: 'free account by email' },
pages: { video: 'pages', eyebrow: 'Bridge pages in a minute', h: 'Point it at any offer. <em>Get a page.</em>', lead: 'Paste the address of the offer you promote. LinkSpin reads its headline and points, you add one line of angle, and you get a bridge, review or squeeze page on a clean pages domain. Leads are yours.', points: ['Bridge, review or squeeze. Your colours, a niche hero image.', 'Leads to your own list: CSV or webhook.', 'Put the page behind your spin link and send traffic by weight.'], cta: 'Scan an offer you already promote', sub: 'free account by email' }, pages: { video: 'pages', eyebrow: 'Bridge pages in a minute', h: 'Point it at any offer. <em>Get a page.</em>', lead: 'Paste the address of the offer you promote. LinkSpin reads its headline and points, you add one line of angle, and you get a bridge, review or squeeze page on a clean pages domain. Leads are yours.', points: ['Bridge, review or squeeze. Your colours, a niche hero image.', 'Leads to your own list with a CSV download, or paste your autoresponder form.', 'Put the page behind your spin link and send traffic by weight.'], cta: 'Scan an offer you already promote', sub: 'free account by email' },
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' }, 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' }, 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' }, 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' } 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(); 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; $('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 // 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; } 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); }); $('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 // ?name=First personalises the page (site-owner links): letters, spaces, hyphens, apostrophes only, 30 chars
+34 -50
View File
@@ -15,87 +15,71 @@
const pb = $('printBtn'); if (pb) pb.addEventListener('click', () => window.print()); const pb = $('printBtn'); if (pb) pb.addEventListener('click', () => window.print());
const tok = me.username || me.refCode || me.memberId; const tok = me.username || me.refCode || me.memberId;
if (tok) document.querySelectorAll('[data-link]').forEach(el => { el.textContent = location.origin + '/join/' + tok; }); if (tok) document.querySelectorAll('[data-link]').forEach(el => { el.textContent = location.origin + '/join/' + tok; });
// launch week swipes: four promoter emails, the member's link + FOUNDER code filled in (Marty, 2026-09-15) // launch swipes for LinkSpin's public launch, Sun 2026-11-15 6 AM Central (copy from campaign-2026-11/SWIPES.md, facts
const LINK = location.origin + '/join/' + (tok || '') + '?promo=FOUNDER'; // checked 2026-11-02). Replaced InstantAdPay's September founding-week set and its FOUNDER code (Marty 2026-11-05).
const BASE = location.origin + '/join/' + (tok || '');
const fill = t => t.replace(/\{link(?::(\w+))?\}/g, (m, v) => v ? BASE + '?v=' + v : BASE);
const SW = [ const SW = [
{ when: 'Day 1 · six days out', subject: 'Something opens Monday. I am bringing a few people in early.', body: `Quick one, because I want you positioned before this goes public. { when: 'Short · any day before Sunday', subject: 'Opens to the world Sunday, 6 AM Central', body: `Quick one.
I have been inside a new advertising platform for a week. It pays sponsors in the same transaction a package is bought, wallet to wallet, on the Polygon ledger where anyone can check it. No back office. No payday. I have watched the payouts land. LinkSpin opens to the world on Sunday, November 15 at 6 AM Central. I have been using it through pre-launch: one short link that rotates every page I promote, a bridge page built from any offer in a minute, and an ad slot on my site that pays me ad credits. All three are free with an email.
It opens to everyone Monday, September 21 at 9 AM Central. Founding members are in now, and the people they bring in before then are the ones the launch traffic lands under. The paid side is advertising. A package buys ad credits, one cent each, and a public contract on Polygon splits each package to the sponsor line in the same transaction. Every payout is on the ledger.
Joining is free with an email. This week the code FOUNDER gives you 500 ad credits to run a campaign on day one: Join before Sunday and you are placed under me; join after and you still get the same tools: {link}
{link} Ad credits buy advertising, not income. Crypto carries risk of loss.`},
{ when: 'Standard · the rotator story', subject: 'The rotator I wish I had ten years ago', body: `I have run link rotators for years and never trusted one. The clicks never matched my tracker, dead links kept serving, and there was no report worth reading.
No income is promised. It is an ad platform with a referral program. But the payment mechanics are real and public, and that is why I am in. LinkSpin is the first one I keep open all day.
Look before Monday. I will walk you through the first three steps.`}, One short link stands in for every page I promote. I set the share each page gets, give a page hours of the day, pause it when it stops pulling, and name a fallback. Every destination is health-checked every 30 minutes and paused for me if it dies. My tracker's click id rides through. The report shows which page converts, by source, country and device, with bots dropped on the server.
{ when: 'Day 2 · five days out', subject: 'Five hundred free credits, and what you can do with them', body: `Yesterday I sent you a link. Here is what is on the other side of it.
You join free with your email. Every day you view a short set of ads and earn credits. Credits run your own ads: banners, text ads, video ads, solo mailings, verified visits, across the whole network. It also builds a bridge, review or squeeze page from any offer I paste in, published on a clean domain with the leads going to my list. And one script tag turns the empty ad space on my site into a zone that pays me ad credits.
This week the FOUNDER code adds 500 credits on top the moment you join, enough to launch a real campaign pointed at whatever you are promoting. Watch it deliver before Monday, when everyone else arrives. All of that is free with an email. The paid side is advertising: six packages, $10 to $500, one credit per cent of delivery, and a verified contract on Polygon that splits each package to the sponsor line in the same transaction it sells in.
The other half is simple. When someone you invite buys an ad package, the contract pays you 50 percent instantly. Level two gets 20 percent, level three 10 percent. Same transaction, on the public ledger. LinkSpin opens to the world Sunday, November 15 at 6 AM Central. Have a look before then: {link:links}
{link} Ad credits buy advertising, not income. Payouts come only from purchases in your line. Crypto carries risk of loss.`}
Use the code before it expires Monday morning. Then tell me you are in and I will show you the checklist.`},
{ when: 'Day 4 · the weekend', subject: 'The two people you bring in this weekend', body: `The doors open Monday morning and I am spending the weekend getting my first people set up. I want you to be one of them.
Here is why the weekend matters. Everyone who joins now is a founding member. The traffic that arrives Monday lands under whoever is already in and set up. Two people under you before Monday, and your line is built when the wave hits.
Setup takes ten minutes: username, link a wallet, switch on payouts. Then share your link. The site gives you posts, swipes, banners and a leaderboard with weekly credit prizes for the top sponsors.
Join with the FOUNDER code and the 500 credits are yours:
{link}
Message me when you are in and I will go through the checklist with you before Monday.`},
{ when: 'Day 6 · Sunday evening', subject: 'Doors open tomorrow at 9 AM Central', body: `Last note before the launch.
LinkSpin opens to the public tomorrow, Monday, at 9 AM Central. After that the FOUNDER code is gone. Tonight it still gives you 500 free ad credits.
If you join tonight you are in as a founding member with a campaign already funded and your link ready when the first wave arrives. If you wait, you join the wave.
Free to join, real advertising, and every payment lands in your own wallet the second it happens, on a ledger anyone can read. No income promises. Just mechanics you can verify.
{link}
I will be online from 8 AM tomorrow walking people through the first three steps. Get in tonight and you are ahead of them.`}
]; ];
// short posts and a DM for the same days, one per day, link + code included
const POSTS = [ const POSTS = [
{ when: 'Day 1 · six days out', text: `Something I have been inside for a week opens to the public Monday, September 21 at 9 AM Central. An ad platform that pays sponsors in the same transaction a package is bought, on the Polygon ledger where anyone can check it. Free to join. Code FOUNDER gives you 500 ad credits before then. No income promises, just mechanics you can verify. {link}` }, { when: 'X · one link', text: `One short link that rotates every page I promote, with weights, hours and a fallback, and a report that shows which page converts. LinkSpin is open for pre-launch and goes live to the world Nov 15. Free, try a spin with no account: {link:links}` },
{ when: 'Day 2 · five days out', text: `500 free ad credits for joining before Monday. View a short daily set of ads, earn more, run banners, text ads, video ads and solo mailings across the network. When someone you invite buys a package, the contract pays you 50 percent instantly, wallet to wallet. Code FOUNDER. {link}` }, { when: 'Facebook · three tools', text: `Three tools I used to pay for separately, now free with an email address.
{ when: 'Day 4 · the weekend', text: `The doors open Monday morning. Everyone joining this weekend is a founding member, and the launch traffic lands under whoever is already set up. Ten minutes to set up, 500 credits with code FOUNDER, and a leaderboard that pays weekly credit prizes to the top sponsors. {link}` },
{ when: 'Day 6 · Sunday evening', text: `Doors open tomorrow, 9 AM Central. Tonight the FOUNDER code still gives you 500 free ad credits; tomorrow it is gone. Free to join, real advertising, every payment on a public ledger. Get in tonight and you are ahead of the wave. {link}` }, One link that rotates every page I promote and reports which one converts. A page builder that turns any offer I paste in into a bridge, review or squeeze page on a clean domain, with the leads going to my own list. And an ad slot for my own site that pays me ad credits for every viewable view.
{ when: 'Text or DM · any day', text: `Hey, I am in something that opens publicly Monday and I am bringing a few people in early. Free to join, real advertising, every payment lands in your own wallet the second it happens. Use code FOUNDER for 500 free credits. Ten minutes to set up and I will walk you through it: {link}` }
It is open for pre-launch now and goes live to the world on Sunday, November 15. The paid side is advertising, split by a public contract on Polygon in the same transaction; read that part on the site before you spend a dollar.
{link:stack}
Ad credits buy advertising, not income. Crypto carries risk of loss.` },
{ when: 'Telegram or WhatsApp group', text: `Quick one for the group. LinkSpin opens to the world Sunday, Nov 15, 6 AM Central. Free with an email: one link that rotates every page you promote, a bridge-page builder, and an ad slot for your site that pays ad credits. Members who join before Sunday are placed under whoever brought them. Tour: {link}` },
{ when: 'Text a friend', text: `Found a link rotator that is actually free and actually reports. One link spins every page you promote. It opens to everyone Sunday 6 AM Central; join before and you are on my team: {link:links}` }
]; ];
const pl = $('postList'); const pl = $('postList');
if (pl) { if (pl) {
pl.innerHTML = POSTS.map((s, i) => '<div class="swipe"><div class="cap"><span>' + s.when + '</span><button type="button" class="btn sec" data-post="' + i + '">Copy post</button></div><pre>' + s.text.replace('{link}', LINK).replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</pre></div>').join(''); pl.innerHTML = POSTS.map((s, i) => '<div class="swipe"><div class="cap"><span>' + s.when + '</span><button type="button" class="btn sec" data-post="' + i + '">Copy post</button></div><pre>' + fill(s.text).replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</pre></div>').join('');
pl.querySelectorAll('[data-post]').forEach(b => b.addEventListener('click', async () => { pl.querySelectorAll('[data-post]').forEach(b => b.addEventListener('click', async () => {
const t = POSTS[Number(b.dataset.post)].text.replace('{link}', LINK); const t = fill(POSTS[Number(b.dataset.post)].text);
try { await navigator.clipboard.writeText(t); b.textContent = 'Copied'; setTimeout(() => { b.textContent = 'Copy post'; }, 1500); } catch (e) { IAP.status('Copy failed; select the text by hand.', 'bad'); } try { await navigator.clipboard.writeText(t); b.textContent = 'Copied'; setTimeout(() => { b.textContent = 'Copy post'; }, 1500); } catch (e) { IAP.status('Copy failed; select the text by hand.', 'bad'); }
})); }));
} }
const wrap = $('swipeList'); const wrap = $('swipeList');
if (wrap) { if (wrap) {
wrap.innerHTML = SW.map((s, i) => '<div class="swipe"><div class="cap"><span>Email ' + (i + 1) + ' · ' + s.when + '</span><button type="button" class="btn sec" data-swipe="' + i + '">Copy email</button></div><div class="subj">Subject: ' + s.subject + '</div><pre>' + s.body.replace('{link}', LINK).replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</pre></div>').join(''); wrap.innerHTML = SW.map((s, i) => '<div class="swipe"><div class="cap"><span>Email ' + (i + 1) + ' · ' + s.when + '</span><button type="button" class="btn sec" data-swipe="' + i + '">Copy email</button></div><div class="subj">Subject: ' + s.subject + '</div><pre>' + fill(s.body).replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</pre></div>').join('');
wrap.querySelectorAll('[data-swipe]').forEach(b => b.addEventListener('click', async () => { wrap.querySelectorAll('[data-swipe]').forEach(b => b.addEventListener('click', async () => {
const s = SW[Number(b.dataset.swipe)]; const text = 'Subject: ' + s.subject + '\n\n' + s.body.replace('{link}', LINK); const s = SW[Number(b.dataset.swipe)]; const text = 'Subject: ' + s.subject + '\n\n' + fill(s.body);
try { await navigator.clipboard.writeText(text); b.textContent = 'Copied'; setTimeout(() => { b.textContent = 'Copy email'; }, 1500); } catch (e) { IAP.status('Copy failed; select the text by hand.', 'bad'); } try { await navigator.clipboard.writeText(text); b.textContent = 'Copied'; setTimeout(() => { b.textContent = 'Copy email'; }, 1500); } catch (e) { IAP.status('Copy failed; select the text by hand.', 'bad'); }
})); }));
} }
// launch moment (admin: Settings > launchAt, ISO 8601 with offset) // launch moment (admin: Settings > launchAt, ISO 8601 with offset)
const at = cfg.launchAt ? new Date(cfg.launchAt) : null; const at = new Date(cfg.launchAt || '2026-11-15T06:00:00-06:00'); // public launch, Sunday 6 AM Central
if (at && !isNaN(at)) { if (at && !isNaN(at)) {
$('lwWhen').hidden = false; $('lwWhen').hidden = false;
$('lwWhenAt').textContent = at.toLocaleString([], { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }); $('lwWhenAt').textContent = at.toLocaleString([], { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });
const tick = () => { const ms = at - Date.now(); if (ms <= 0) { $('lwWhenIn').textContent = 'doors are open'; return; } const tick = () => { const ms = at - Date.now(); if (ms <= 0) { $('lwWhenIn').textContent = 'LinkSpin is live'; return; }
const d = Math.floor(ms / 86400000), h = Math.floor(ms % 86400000 / 3600000), m = Math.floor(ms % 3600000 / 60000); const d = Math.floor(ms / 86400000), h = Math.floor(ms % 86400000 / 3600000), m = Math.floor(ms % 3600000 / 60000);
$('lwWhenIn').textContent = (d ? d + 'd ' : '') + h + 'h ' + m + 'm to go'; }; $('lwWhenIn').textContent = (d ? d + 'd ' : '') + h + 'h ' + m + 'm to go'; };
tick(); setInterval(tick, 30000); tick(); setInterval(tick, 30000);
+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') : ''); 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 } 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) { async function load(keep) {
let r; try { r = await CR.get('/api/my/rotations'); } catch (e) { CR.sub('could not load'); return; } 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; 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; $('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.'; 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>' 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="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>' + '<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 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>' + '<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('') + (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>'; : '<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'; $('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); }; 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)); })); $('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]'); 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' }); }); $('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'; $('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); 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'; }); catch (e) { toast(e.message, true); } b.disabled = false; b.textContent = 'Check now'; });
$('pbNew').addEventListener('click', () => pbForm(null)); $('pbNew').addEventListener('click', () => pbForm(null));
$('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches; $('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches;
+68 -47
View File
@@ -26,7 +26,17 @@
return r; return r;
} }
// holding tank (2026-10-27): no sponsor yet, so the free Switch on payouts waits for an adopter (24 hours at most).
// A purchase is never held: buying goes ahead as before.
const holdLeft = ms => { const m = Math.max(1, Math.round(ms / 60000)); const h = Math.floor(m / 60); return h ? h + ' h ' + (m % 60) + ' min' : m + ' min'; };
function tankHoldText(h) {
let t = "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours).";
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
return t + ' Did someone invite you? Tell us in the Who invited you box.';
}
let TANK_HOLD = null;
function nextMove(d) { function nextMove(d) {
if (TANK_HOLD && d.address && !d.memberId) return tankHoldText(TANK_HOLD);
if (!d.address) return 'Grab your link below and start sharing today. Then link your wallet (one free signature) so every payment can lock to you before your people start buying.'; if (!d.address) return 'Grab your link below and start sharing today. Then link your wallet (one free signature) so every payment can lock to you before your people start buying.';
if (!d.memberId) return 'Your wallet is linked. Switch on payouts above (one free transaction) and every purchase in your line pays you the moment it happens.'; if (!d.memberId) return 'Your wallet is linked. Switch on payouts above (one free transaction) and every purchase in your line pays you the moment it happens.';
if (d.buyerCount === 0) return 'Payouts are on and your link is live. Your next milestone: your first buyer of $25 or more. Every direct pays you 50 percent from their very first package.'; if (d.buyerCount === 0) return 'Payouts are on and your link is live. Your next milestone: your first buyer of $25 or more. Every direct pays you 50 percent from their very first package.';
@@ -73,7 +83,9 @@
{ key: 'payouts', label: 'Spark', sub: 'payouts on', img: '/badges/badge-spark.jpg', ribbonY: 0.873 }, { key: 'payouts', label: 'Spark', sub: 'payouts on', img: '/badges/badge-spark.jpg', ribbonY: 0.873 },
{ key: 'firstBuyer', label: 'Surge', sub: 'first qualifying buyer', img: '/badges/badge-surge.jpg?v=2', ribbonY: 0.873 }, { key: 'firstBuyer', label: 'Surge', sub: 'first qualifying buyer', img: '/badges/badge-surge.jpg?v=2', ribbonY: 0.873 },
{ key: 'level2', label: 'Circuit', sub: '2 qualifying buyers', img: '/badges/badge-circuit.jpg?v=2', ribbonY: 0.873 }, { key: 'level2', label: 'Circuit', sub: '2 qualifying buyers', img: '/badges/badge-circuit.jpg?v=2', ribbonY: 0.873 },
{ key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.873 } { key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.873 },
// Founder (2026-11-05): cosmetic, stored on the account, granted at the launch moment to everyone who signed in before it
{ key: 'founder', label: 'Founder', sub: 'in before launch', img: '/badges/badge-founder.jpg?v=1', ribbonY: 0.873, extra: true }
]; ];
let lastMilestones = []; let lastMilestones = [];
function renderBadges(d) { function renderBadges(d) {
@@ -82,12 +94,14 @@
const strip = $('badgeStrip'); const strip = $('badgeStrip');
if (!strip) return; if (!strip) return;
$('badgeCard').hidden = false; $('badgeCard').hidden = false;
strip.innerHTML = BADGES.map(b => { const held = reached.concat(d.founder ? ['founder'] : []);
const got = reached.includes(b.key); strip.innerHTML = BADGES.filter(b => !b.extra || d.founder || d.founderPending).map(b => {
const got = held.includes(b.key);
return '<div class="badge-a' + (got ? '' : ' locked') + '">' return '<div class="badge-a' + (got ? '' : ' locked') + '">'
+ '<img class="badge-img" src="' + b.img + '" alt="' + b.label + ' badge" loading="lazy">' + '<img class="badge-img" src="' + b.img + '" alt="' + b.label + ' badge" loading="lazy">'
+ '<div class="bl">' + b.label + '</div><div class="bs">' + b.sub + '</div>' + '<div class="bl">' + b.label + '</div><div class="bs">' + b.sub + '</div>'
+ (got ? '<button class="share" data-badge="' + b.key + '">Share</button> <button class="share" data-badgepost="' + b.key + '" hidden>Post to Telegram</button>' : '<div class="bs">🔒 locked</div>') + '</div>'; + (got ? '<button class="share" data-badge="' + b.key + '">Share</button>' + (b.extra ? '' : ' <button class="share" data-badgepost="' + b.key + '" hidden>Post to Telegram</button>')
: b.key === 'founder' ? '<div class="bs">arrives at launch, Sunday Nov 15</div>' : '<div class="bs">🔒 locked</div>') + '</div>';
}).join(''); }).join('');
strip.querySelectorAll('[data-badge]').forEach(btn => strip.querySelectorAll('[data-badge]').forEach(btn =>
btn.addEventListener('click', () => shareBadge(btn.dataset.badge, d))); btn.addEventListener('click', () => shareBadge(btn.dataset.badge, d)));
@@ -227,7 +241,8 @@
} }
// ── overview v3 charts: hand-rolled SVG/CSS, real data only ── // ── overview v3 charts: hand-rolled SVG/CSS, real data only ──
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c])); const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const CH = { mint: '#3b9dff', cyan: '#54ccff', violet: '#9d7dff', amber: '#ffb238', track: 'rgba(139,166,156,.18)' }; // chart colours come from the live theme tokens (2026-11-01): read at draw time so a theme switch repaints correctly
const CH = new Proxy({}, { get: (_, k) => { const cs = getComputedStyle(document.documentElement); const v = { mint: '--mint', cyan: '--cyan', violet: '--violet', amber: '--amber', track: '--muted-soft' }[k]; return (v && cs.getPropertyValue(v).trim()) || { mint: '#3b9dff', cyan: '#54ccff', violet: '#9d7dff', amber: '#ffb238', track: 'rgba(139,166,156,.18)' }[k]; } });
function bars(el, xel, data) { // data: [{v,label,tip,alt}] function bars(el, xel, data) { // data: [{v,label,tip,alt}]
if (!el) return; if (!el) return;
const max = Math.max(1, ...data.map(d => d.v)); const max = Math.max(1, ...data.map(d => d.v));
@@ -249,7 +264,7 @@
off -= len; off -= len;
} }
out += '<text x="21" y="20.5" text-anchor="middle" fill="currentColor" font-size="6.5" font-weight="800" class="donut-center">' + esc(center.big) + '</text>' out += '<text x="21" y="20.5" text-anchor="middle" fill="currentColor" font-size="6.5" font-weight="800" class="donut-center">' + esc(center.big) + '</text>'
+ '<text x="21" y="26.5" text-anchor="middle" fill="#8ba69c" font-size="3.1">' + esc(center.small) + '</text>'; + '<text x="21" y="26.5" text-anchor="middle" style="fill:var(--muted)" font-size="3.1">' + esc(center.small) + '</text>';
el.innerHTML = out; el.innerHTML = out;
} }
function legend(el, rows) { function legend(el, rows) {
@@ -467,7 +482,7 @@
const r = await (await fetch('/api/leaderboard?period=week')).json(); const r = await (await fetch('/api/leaderboard?period=week')).json();
const esc = t => String(t == null ? '' : t).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c])); const esc = t => String(t == null ? '' : t).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
let h = r.prize ? '<p style="margin:0 0 8px"><b>Prize this week:</b> ' + esc(r.prize) + '</p>' : ''; let h = r.prize ? '<p style="margin:0 0 8px"><b>Prize this week:</b> ' + esc(r.prize) + '</p>' : '';
h += r.top.length ? '<table style="width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums">' + r.top.slice(0, 5).map(x => '<tr><td style="padding:3px 0;width:26px;color:' + (x.rank === 1 ? '#ffd15c' : 'var(--muted)') + '">' + x.rank + '</td><td style="padding:3px 0"><b>' + esc(x.name) + '</b></td><td style="padding:3px 0;text-align:right">' + x.sales + ' sold · $' + x.usd + '</td></tr>').join('') + '</table>' h += r.top.length ? '<table style="width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums">' + r.top.slice(0, 5).map(x => '<tr><td style="padding:3px 0;width:26px;color:' + (x.rank === 1 ? 'var(--gold)' : 'var(--muted)') + '">' + x.rank + '</td><td style="padding:3px 0"><b>' + esc(x.name) + '</b></td><td style="padding:3px 0;text-align:right">' + x.sales + ' sold · $' + x.usd + '</td></tr>').join('') + '</table>'
: '<p class="muted" style="margin:0">No packages sold yet this week. First sale takes the top spot.</p>'; : '<p class="muted" style="margin:0">No packages sold yet this week. First sale takes the top spot.</p>';
h += r.me ? '<p style="margin:8px 0 0">You: <b>#' + r.me.rank + '</b> · ' + r.me.sales + ' sold · $' + r.me.usd + '</p>' : '<p class="muted" style="margin:8px 0 0">You: no sales yet this week. Sales are $25+ packages bought by people you sponsor.</p>'; h += r.me ? '<p style="margin:8px 0 0">You: <b>#' + r.me.rank + '</b> · ' + r.me.sales + ' sold · $' + r.me.usd + '</p>' : '<p class="muted" style="margin:8px 0 0">You: no sales yet this week. Sales are $25+ packages bought by people you sponsor.</p>';
h += '<p style="margin:6px 0 0"><a href="/leaderboard" target="_blank" rel="noopener" style="color:var(--mint)">Full leaderboard: week, month, all time →</a></p>'; h += '<p style="margin:6px 0 0"><a href="/leaderboard" target="_blank" rel="noopener" style="color:var(--mint)">Full leaderboard: week, month, all time →</a></p>';
@@ -498,8 +513,9 @@
payouts: ['Switch on payouts', 'One small transaction registers your wallet with the contract so commissions can reach it. Buying any package does this automatically.', 'Activate payouts', () => jumpTo('wallet', 'activateBtn')], payouts: ['Switch on payouts', 'One small transaction registers your wallet with the contract so commissions can reach it. Buying any package does this automatically.', 'Activate payouts', () => jumpTo('wallet', 'activateBtn')],
package: ['Your first package', 'From $10. The $25 package is the one that counts you as a qualifying buyer for your sponsor and unlocks adopting from the holding tank.', 'See packages', () => jumpTo('buy', null)] package: ['Your first package', 'From $10. The $25 package is the one that counts you as a qualifying buyer for your sponsor and unlocks adopting from the holding tank.', 'See packages', () => jumpTo('buy', null)]
}[cur.k]; }[cur.k];
$('gsNow').innerHTML = '<p><b>Next: ' + copy[0] + '</b>' + copy[1] + (cur.k === 'wallet' ? ' <a href="/wallets" target="_blank" rel="noopener" style="color:var(--mint)">Wallet guide</a>' : '') + '</p><button type="button" class="btn" id="gsGo">' + copy[2] + '</button>'; if (cur.k === 'payouts' && TANK_HOLD) { copy[0] = 'Matching you with a sponsor'; copy[1] = tankHoldText(TANK_HOLD); copy[2] = null; } // no activate button while held
$('gsGo').addEventListener('click', copy[3]); $('gsNow').innerHTML = '<p><b>Next: ' + copy[0] + '</b>' + copy[1] + (cur.k === 'wallet' ? ' <a href="/wallets" target="_blank" rel="noopener" style="color:var(--mint)">Wallet guide</a>' : '') + '</p>' + (copy[2] ? '<button type="button" class="btn" id="gsGo">' + copy[2] + '</button>' : '');
if (copy[2]) $('gsGo').addEventListener('click', copy[3]);
card.hidden = false; card.hidden = false;
} }
function jumpTo(pane, id) { function jumpTo(pane, id) {
@@ -591,7 +607,7 @@
const at = cfg.launchAt ? new Date(cfg.launchAt).getTime() : 0; const at = cfg.launchAt ? new Date(cfg.launchAt).getTime() : 0;
const show = done < items.length && !(at && Date.now() > at + 7 * 86400000); const show = done < items.length && !(at && Date.now() > at + 7 * 86400000);
const lm = $('launchMark'); const lm = $('launchMark');
if (lm) { lm.hidden = !show; lm.innerHTML = show ? '<b>Launch ready: ' + done + ' of ' + items.length + '.</b> ' + (at && Date.now() < at ? 'Doors open ' + new Date(at).toLocaleString([], { weekday: 'short', hour: 'numeric', minute: '2-digit' }) + '. ' : '') + '<a href="/launch">Open the founding-week checklist</a>' : ''; } if (lm) { lm.hidden = !show; lm.innerHTML = show ? '<b>Launch ready: ' + done + ' of ' + items.length + '.</b> ' + (at && Date.now() < at ? 'Doors open ' + new Date(at).toLocaleString([], { weekday: 'short', hour: 'numeric', minute: '2-digit' }) + '. ' : '') + '<a href="/launch">Open the launch week checklist</a>' : ''; }
} catch (e) {} } catch (e) {}
// people waiting for a sponsor in the holding tank (Marty, 2026-09-12): every Overview sees it // people waiting for a sponsor in the holding tank (Marty, 2026-09-12): every Overview sees it
try { try {
@@ -600,7 +616,8 @@
tn.hidden = !(tw && tw.count); tn.hidden = !(tw && tw.count);
if (tw && tw.count) tn.innerHTML = '<b>' + tw.count + (tw.count === 1 ? ' person is' : ' people are') + ' waiting for a sponsor in the holding tank</b> \u00b7 ' if (tw && tw.count) tn.innerHTML = '<b>' + tw.count + (tw.count === 1 ? ' person is' : ' people are') + ' waiting for a sponsor in the holding tank</b> \u00b7 '
+ tw.names.map(esc).join(', ') + (tw.count > tw.names.length ? ' and more' : '') + '. <a href="#line">Adopt them from My line</a>' + tw.names.map(esc).join(', ') + (tw.count > tw.names.length ? ' and more' : '') + '. <a href="#line">Adopt them from My line</a>'
+ (tw.eligible ? '.' : ' (you need your own $25 package first).'); + (tw.eligible ? '.' : ' (you need your own $25 package first).')
+ (tw.ready ? ' <b style="color:var(--ok)">' + tw.ready + ' of them ' + (tw.ready === 1 ? 'has' : 'have') + ' linked a wallet and ' + (tw.ready === 1 ? 'is' : 'are') + ' ready to switch on payouts.</b>' : '');
} }
} catch (e) {} } catch (e) {}
if (d.username) { // wall link rides the username if (d.username) { // wall link rides the username
@@ -697,6 +714,8 @@
else if (!render.waiting) { render.waiting = true; window.addEventListener('ls:session', () => { render.waiting = false; render(); }, { once: true }); } else if (!render.waiting) { render.waiting = true; window.addEventListener('ls:session', () => { render.waiting = false; render(); }, { once: true }); }
} }
if (!signedIn) return; if (!signedIn) return;
if (me.nssoBack && me.username && !render.toNsso) { render.toNsso = true; location.href = '/sso/resume'; return; } // tapped "Sign in with LinkSpin" on another network site while signed out here (2026-11-14)
TANK_HOLD = (!me.memberId && me.tankHold) || null;
if ($('adminLink')) $('adminLink').hidden = !me.isAdmin; // admin portal link, only for ADMIN_EMAIL if ($('adminLink')) $('adminLink').hidden = !me.isAdmin; // admin portal link, only for ADMIN_EMAIL
// REQUIRED first step (Marty, 2026-09-12): no username, nothing else. The modal cannot be // REQUIRED first step (Marty, 2026-09-12): no username, nothing else. The modal cannot be
// skipped or dismissed; it resolves only when a username is saved, then the area renders. // skipped or dismissed; it resolves only when a username is saved, then the area renders.
@@ -722,17 +741,20 @@
const who = []; const who = [];
if (me.email) who.push(me.email); if (me.email) who.push(me.email);
// members kept asking whether the wallet was really connected (Marty, 2026-09-12): say it, with a green check // members kept asking whether the wallet was really connected (Marty, 2026-09-12): say it, with a green check
if (me.address) who.push('<span style="display:inline-flex;align-items:center;gap:8px"><span aria-hidden="true" style="display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:#22c55e;color:#04140a;font-weight:900;font-size:13px;line-height:1">&#10003;</span><b style="color:#22c55e">Wallet connected</b> <span class="mono">' + me.address.slice(0, 8) + '…' + me.address.slice(-6) + '</span></span>'); if (me.address) who.push('<span style="display:inline-flex;align-items:center;gap:8px"><span aria-hidden="true" style="display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--ok);color:var(--ok-ink);font-weight:900;font-size:13px;line-height:1">&#10003;</span><b style="color:var(--ok)">Wallet connected</b> <span class="mono">' + me.address.slice(0, 8) + '…' + me.address.slice(-6) + '</span></span>');
else who.push('<span style="display:inline-flex;align-items:center;gap:8px"><span aria-hidden="true" style="display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;border:2px solid var(--muted);color:var(--muted);font-weight:900;font-size:12px;line-height:1">!</span><b>No wallet connected yet</b> <span class="muted">(link one below)</span></span>'); else who.push('<span style="display:inline-flex;align-items:center;gap:8px"><span aria-hidden="true" style="display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;border:2px solid var(--muted);color:var(--muted);font-weight:900;font-size:12px;line-height:1">!</span><b>No wallet connected yet</b> <span class="muted">(link one below)</span></span>');
if (me.memberId) who.push('on-chain <b>member #' + me.memberId + '</b>' if (me.memberId) who.push('on-chain <b>member #' + me.memberId + '</b>'
+ (me.onchainSponsorId ? ', sponsored by #' + me.onchainSponsorId : '')); + (me.onchainSponsorId ? ', sponsored by #' + me.onchainSponsorId : ''));
else if (me.sponsorId) who.push('invited by member #' + me.sponsorId); else if (me.sponsorId && !TANK_HOLD) who.push('invited by member #' + me.sponsorId);
$('posLine').innerHTML = who.join('<br>'); $('posLine').innerHTML = who.join('<br>');
$('creditLine').textContent = (me.credits || 0).toLocaleString(); $('creditLine').textContent = (me.credits || 0).toLocaleString();
loadPositions(me); loadPositions(me);
$('linkCard').hidden = !!me.address; $('linkCard').hidden = !!me.address;
$('activateCard').hidden = !(me.address && !me.memberId); $('activateCard').hidden = !(me.address && !me.memberId);
{ let hn = $('tankHoldNote'); // held for an adopter: say so, and no activate button
if (!hn) { hn = document.createElement('p'); hn.id = 'tankHoldNote'; hn.className = 'small'; hn.style.cssText = 'margin:8px 0 0;color:var(--ok)'; $('activateBtn').insertAdjacentElement('beforebegin', hn); }
hn.hidden = !TANK_HOLD; hn.textContent = TANK_HOLD ? tankHoldText(TANK_HOLD) : ''; $('activateBtn').hidden = !!TANK_HOLD; }
$('activityArea').hidden = !me.memberId; $('activityArea').hidden = !me.memberId;
$('campGate').hidden = true; // earned credits fund campaigns for everyone $('campGate').hidden = true; // earned credits fund campaigns for everyone
$('campaignCard').hidden = false; $('campaignCard').hidden = false;
@@ -815,12 +837,15 @@
if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; return; } if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; return; }
const tbl = document.createElement('div'); const tbl = document.createElement('div');
tbl.className = 'tablewrap'; tbl.className = 'tablewrap';
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>' const synN = Math.max(1, Math.floor(Number(r.rates && r.rates.synRateDivisor) || 1)); // network rate (Marty, 2026-10-27, 4:1)
const synT = Math.max(1, Math.floor(Number(r.rates && r.rates.synRateDivisorText != null ? r.rates.synRateDivisorText : synN) || 1)); // text ads (Marty, 2026-11-12, 1/10)
const nOf = c => c.type === 'text' ? synT : synN;
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions on the partner ad network plus views in other members\u2019 zones on their own sites (banner and text ads)' + (synN > 1 ? ', at 1/' + synN + ' of the rate here' : '') + '">Network views</th><th class="num">Clicks</th>'
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>' + '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '</td>' + r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '</td>'
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c) + '</td>' + '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c) + '</td>'
+ '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>' + '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>'
+ '<td class="num" data-l="Network views">' + (['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() : '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>') + '</td>' + '<td class="num" data-l="Network views">' + (['banner', 'text'].includes(c.type) ? ((c.impsNas || 0) + (c.impsSyn || 0)).toLocaleString() + (nOf(c) > 1 && (c.impsNas || c.impsSyn) ? ' <span class="muted small">at 1/' + nOf(c) + '</span>' : '') : '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>') + '</td>'
+ '<td class="num" data-l="Clicks">' + c.clicks + (r.clickSources && r.clickSources[c.id] ? '<div class="muted small clk-src" title="where the clicks happened">' + Object.entries(r.clickSources[c.id]).sort((a, b) => b[1] - a[1]).map(([k, v]) => '<span>' + esc(k) + ' ' + v + '</span>').join('') + (c.impsNas ? ' · network: see Network views' : '') + '</div>' : '') + '</td>' + '<td class="num" data-l="Clicks">' + c.clicks + (r.clickSources && r.clickSources[c.id] ? '<div class="muted small clk-src" title="where the clicks happened">' + Object.entries(r.clickSources[c.id]).sort((a, b) => b[1] - a[1]).map(([k, v]) => '<span>' + esc(k) + ' ' + v + '</span>').join('') + (c.impsNas ? ' · network: see Network views' : '') + '</div>' : '') + '</td>'
+ '<td class="num" data-l="Spent">' + c.spent + '</td><td class="num" data-l="Budget">' + c.budget + '</td>' + '<td class="num" data-l="Spent">' + c.spent + '</td><td class="num" data-l="Budget">' + c.budget + '</td>'
+ '<td data-l="Status">' + (c.status === 'out' ? '<span class="badge amber">budget spent</span>' : c.status === 'done' ? '<span class="muted">ended</span>' : c.scheduled ? '<span class="badge">scheduled</span>' : c.status) + '</td>' + '<td data-l="Status">' + (c.status === 'out' ? '<span class="badge amber">budget spent</span>' : c.status === 'done' ? '<span class="muted">ended</span>' : c.scheduled ? '<span class="badge">scheduled</span>' : c.status) + '</td>'
@@ -1249,13 +1274,14 @@
} }
// ── holding tank: waiting members, adopt, my open adoptions ── // ── holding tank: waiting members, adopt, my open adoptions ──
const ago = ts => { if (!ts) return 'never'; const d = Math.floor((Date.now() - ts) / 86400000); return d === 0 ? 'today' : d === 1 ? 'yesterday' : d + ' days ago'; }; const ago = ts => { if (!ts) return 'never'; const d = Math.floor((Date.now() - ts) / 86400000); return d === 0 ? 'today' : d === 1 ? 'yesterday' : d + ' days ago'; };
let TANK_WARM_ONLY = false; // the "Warm or hot only" toggle on the holding tank (2026-11-18)
async function loadTank() { async function loadTank() {
const el = $('tankList'); if (!el) return; const el = $('tankList'); if (!el) return;
try { try {
const r = await (await fetch('/api/my/tank')).json(); const r = await (await fetch('/api/my/tank')).json();
if (r.error) { el.innerHTML = ''; return; } if (r.error) { el.innerHTML = ''; return; }
$('tankCap').textContent = r.cap; $('tankTtl').textContent = r.ttlDays; $('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); 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>' $('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>' + '<span class="em">' + (m.bought ? 'bought' : m.wallet ? 'wallet linked' : 'free, no wallet yet') + ' · last seen ' + ago(m.lastSeen) + '</span>'
@@ -1265,10 +1291,20 @@
$('tankMine').querySelectorAll('[data-tchat]').forEach(b => b.addEventListener('click', () => openConvo(b.dataset.tchat, b.dataset.tname))); $('tankMine').querySelectorAll('[data-tchat]').forEach(b => b.addEventListener('click', () => openConvo(b.dataset.tchat, b.dataset.tname)));
$('tankMine').querySelectorAll('[data-pif]').forEach(b => b.addEventListener('click', () => pif(b.dataset.pif, b.dataset.pname, b.dataset.paddr))); $('tankMine').querySelectorAll('[data-pif]').forEach(b => b.addEventListener('click', () => pif(b.dataset.pif, b.dataset.pname, b.dataset.paddr)));
if (!r.waiting.length) { el.innerHTML = '<p class="muted small">The tank is empty. Anyone who joins from the public site without a sponsor lands here.</p>'; return; } if (!r.waiting.length) { el.innerHTML = '<p class="muted small">The tank is empty. Anyone who joins from the public site without a sponsor lands here.</p>'; return; }
el.innerHTML = r.waiting.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + '</span>' const opens = w => w.opensAt > Date.now(); // new sign-up: they have 24 hours to say who invited them
+ '<span class="em">joined ' + ago(w.joined) + '</span>' const opensBadge = w => ' <span class="badge amber" title="New member. They have 24 hours from sign-up to tell us who invited them. You can adopt them after that.">Opens in ' + holdLeft(w.opensAt - Date.now()) + '</span>';
const readyBadge = w => w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)" title="Wallet linked. If nobody adopts them, the site assigns them to the next eligible adopter when the time runs out.">Ready to activate \u00b7 ' + (w.holdUntil > Date.now() ? holdLeft(w.holdUntil - Date.now()) + ' left' : 'assigning now') + '</span>' : '';
// readiness (2026-11-18, network hub): hottest first inside the usual groups, a "Warm or hot" toggle, and under each lead its stage,
// heat, last action and how they got here; the hub down = the list exactly as before
const RD = window.TankReady; const rdOn = !!(RD && r.waiting.some(w => w.rd));
const heatOrder = (a, b) => (rdOn ? RD.score(b) - RD.score(a) : 0);
const list = r.waiting.filter(w => !(rdOn && TANK_WARM_ONLY) || (w.rd && w.rd.heat && w.rd.heat.score >= 40));
const bar = rdOn ? '<div class="rd-bar"><span class="small muted">Hottest first</span> <button type="button" class="btn sec small' + (TANK_WARM_ONLY ? ' on' : '') + '" id="tankWarmOnly" aria-pressed="' + (TANK_WARM_ONLY ? 'true' : 'false') + '">' + (TANK_WARM_ONLY ? 'Showing warm or hot only' : 'Warm or hot only') + '</button> <span class="small muted">' + list.length + ' of ' + r.waiting.length + '</span></div>' : '';
el.innerHTML = bar + (list.length ? list.slice().sort((a, b) => (opens(a) ? 1 : 0) - (opens(b) ? 1 : 0) || (b.ready ? 1 : 0) - (a.ready ? 1 : 0) || heatOrder(a, b)).map(w => '<div class="lin-row' + (w.rd ? ' rd-row' : '') + '"><span class="nm">' + esc(w.name) + (opens(w) ? opensBadge(w) : readyBadge(w)) + '</span>'
+ '<span class="em">joined ' + ago(w.joined) + (w.rd && RD ? RD.html(w.rd) : '') + '</span>'
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>' + '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
+ (r.eligible ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join(''); + (r.eligible && !opens(w) ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('') : '<p class="muted small">Nobody warm or hot is waiting right now. Switch the filter off to see everyone.</p>');
{ const t = $('tankWarmOnly'); if (t) t.addEventListener('click', () => { TANK_WARM_ONLY = !TANK_WARM_ONLY; loadTank(); }); }
el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => { el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => {
const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the LinkSpin holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' }); const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the LinkSpin holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' });
if (note === null) return; if (note === null) return;
@@ -1528,7 +1564,7 @@
} }
el.innerHTML = r.levels.map(L => !L.members.length ? '' : el.innerHTML = r.levels.map(L => !L.members.length ? '' :
'<div class="lin-lvl"><div class="cap">Level ' + L.level + ' · ' + L.members.length + (L.level === 1 ? ' direct' : '') + '</div>' '<div class="lin-lvl"><div class="cap">Level ' + L.level + ' · ' + L.members.length + (L.level === 1 ? ' direct' : '') + '</div>'
+ L.members.map(m => '<div class="lin-row' + (m.own ? ' own' : '') + '"><span class="nm">' + esc(m.name) + (m.own ? ' <span class="badge">yours</span>' : '') + '</span>' + L.members.map(m => '<div class="lin-row' + (m.own ? ' own' : '') + '"><span class="nm">' + esc(m.name) + (m.own ? ' <span class="badge">yours</span>' : '') + (m.founder ? ' <span class="badge" title="Founder badge: signed in before LinkSpin launched" style="background:#ffc94d;border-color:#ffc94d;color:#5a3f00">Founder</span>' : '') + '</span>'
+ '<span class="em">' + (m.email ? esc(m.email) : (m.memberId ? '<span class="id">#' + m.memberId + '</span>' : '')) + (m.sponsor ? '<span class="sp">sponsored by ' + esc(m.sponsor) + '</span>' : '') + (m.own ? '' : '<span class="sp">' + (m.bought ? '$25+ buy ✓' : 'no $25+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</span>') + '</span>' + '<span class="em">' + (m.email ? esc(m.email) : (m.memberId ? '<span class="id">#' + m.memberId + '</span>' : '')) + (m.sponsor ? '<span class="sp">sponsored by ' + esc(m.sponsor) + '</span>' : '') + (m.own ? '' : '<span class="sp">' + (m.bought ? '$25+ buy ✓' : 'no $25+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</span>') + '</span>'
+ '<span class="earn' + (m.earnedWei && m.earnedWei !== '0' ? ' on' : '') + '" title="POL this person has paid you so far">' + '<span class="earn' + (m.earnedWei && m.earnedWei !== '0' ? ' on' : '') + '" title="POL this person has paid you so far">'
+ (m.earnedWei && m.earnedWei !== '0' ? '+' + IAP.fmtPol(m.earnedWei) + ' POL' : '0.00 POL') + '</span>' + (m.earnedWei && m.earnedWei !== '0' ? '+' + IAP.fmtPol(m.earnedWei) + ' POL' : '0.00 POL') + '</span>'
@@ -1565,7 +1601,7 @@
+ chip('Link', (a.linkViews30 || 0) + ' views (30d) · ' + (a.joins || 0) + ' joined', (a.linkViews30 || 0) > 0 ? 'on' : '') + chip('Link', (a.linkViews30 || 0) + ' views (30d) · ' + (a.joins || 0) + ' joined', (a.linkViews30 || 0) > 0 ? 'on' : '')
+ chip('Line', (a.directs || 0) + ' direct' + (a.directs === 1 ? '' : 's') + ' · ' + (a.buyerCount || 0) + ' qualifying', (a.buyerCount || 0) > 0 ? 'on' : '') + chip('Line', (a.directs || 0) + ' direct' + (a.directs === 1 ? '' : 's') + ' · ' + (a.buyerCount || 0) + ' qualifying', (a.buyerCount || 0) > 0 ? 'on' : '')
+ chip('Wallet', a.wallet ? (a.badges && a.badges.includes('payouts') ? 'linked · payouts on' : 'linked') : 'not linked', a.wallet ? '' : 'warn') + chip('Wallet', a.wallet ? (a.badges && a.badges.includes('payouts') ? 'linked · payouts on' : 'linked') : 'not linked', a.wallet ? '' : 'warn')
+ (a.badges && a.badges.length ? chip('Badges', a.badges.map(b => ({ payouts: 'Spark', firstBuyer: 'Surge', level2: 'Circuit', level3: 'Nexus' }[b] || b)).join(' · ')) : '') + (a.badges && a.badges.length ? chip('Badges', a.badges.map(b => ({ payouts: 'Spark', firstBuyer: 'Surge', level2: 'Circuit', level3: 'Nexus', founder: 'Founder' }[b] || b)).join(' · ')) : '')
+ '<span class="lin-verdict' + (working ? ' on' : '') + '">' + (working ? 'Working' : 'Quiet') + '</span>'; + '<span class="lin-verdict' + (working ? ' on' : '') + '">' + (working ? 'Working' : 'Quiet') + '</span>';
} }
async function loadUplineMessages() { async function loadUplineMessages() {
@@ -1858,6 +1894,9 @@
{ title: '1200×630 · social posts, link previews, group covers', items: [ { title: '1200×630 · social posts, link previews, group covers', items: [
{ file: 'ls-social-a.jpg', size: '1200×630 · one link, every page you promote · Join free' }, { file: 'ls-social-a.jpg', size: '1200×630 · one link, every page you promote · Join free' },
{ file: 'ls-social-b.jpg', size: '1200×630 · paid the moment they buy · Join free' } ] }, { file: 'ls-social-b.jpg', size: '1200×630 · paid the moment they buy · Join free' } ] },
{ title: '600×300 · traffic exchanges, splash pages, safelist mailers', items: [
{ file: 'ls-wide-a.png', size: '600×300 · one link, every page you promote · Join free' },
{ file: 'ls-wide-b.png', size: '600×300 · paid the moment they buy · Join free' } ] },
{ title: '1080×1080 and 1080×1920 · Instagram, Facebook, stories, reels', items: [ { title: '1080×1080 and 1080×1920 · Instagram, Facebook, stories, reels', items: [
{ file: 'ls-square.jpg', size: '1080×1080 · square' }, { file: 'ls-square.jpg', size: '1080×1080 · square' },
{ file: 'ls-story.jpg', size: '1080×1920 · story / reel' } ] }, { file: 'ls-story.jpg', size: '1080×1920 · story / reel' } ] },
@@ -1915,23 +1954,6 @@
// ── in-dashboard package buying ── // ── in-dashboard package buying ──
const PKG = { 1: 'Micro', 2: 'Activation', 3: 'Builder', 4: 'Growth', 5: 'Leader' }; const PKG = { 1: 'Micro', 2: 'Activation', 3: 'Builder', 4: 'Growth', 5: 'Leader' };
// Card on-ramp: buy POL with a card via MoonPay, delivered to the buyer's own
// wallet. Signed + wallet-prefilled once MoonPay keys are set; generic page
// otherwise. The site never touches funds — MoonPay is merchant of record.
async function openMoonpay(pol) {
try {
let addr = '';
try { const me = await (await fetch('/api/me')).json(); addr = me.address || ''; } catch (e) {}
const q = '/api/moonpay-url?pol=' + encodeURIComponent(pol || '') + (addr ? '&address=' + encodeURIComponent(addr) : '');
const r = await (await fetch(q)).json();
if (r && r.url) {
window.open(r.url, '_blank', 'noopener');
IAP.status(r.signed
? 'MoonPay opened in a new tab with your wallet address pre-filled. Choose POL on Polygon, finish the purchase, then come back and buy your package.'
: 'MoonPay opened in a new tab. Choose POL on the Polygon network and paste your own wallet address as the destination, then come back.', 'ok');
}
} catch (e) { IAP.status('Could not open MoonPay: ' + ((e && e.message) || e), 'bad'); }
}
// ── linked positions (Qualified Start) ── // ── linked positions (Qualified Start) ──
const short = a => a ? a.slice(0, 6) + '…' + a.slice(-4) : ''; const short = a => a ? a.slice(0, 6) + '…' + a.slice(-4) : '';
let noPayoutAddrs = new Set(); // positions the site refuses to buy from (see siteConfig.noPayoutIds) let noPayoutAddrs = new Set(); // positions the site refuses to buy from (see siteConfig.noPayoutIds)
@@ -2072,15 +2094,12 @@
} catch (e) { IAP.status('Purchase failed: ' + ((e && e.message) || e), 'bad'); } } catch (e) { IAP.status('Purchase failed: ' + ((e && e.message) || e), 'bad'); }
finally { b.disabled = false; } finally { b.disabled = false; }
})); }));
// brand new to crypto? buy POL with a card, sent straight to the wallet // brand new to crypto? point to the wallet guide (buy POL on any exchange or on-ramp, send it to your own wallet)
const builder = products.find(p => p.priceCents === 5000) || products[products.length - 1];
const needPol = (builder && builder.costWei) ? Math.max(30, Math.ceil(Number(builder.costWei) / 1e18) + 3) : 30;
const cta = document.createElement('div'); const cta = document.createElement('div');
cta.style.cssText = 'grid-column:1/-1;margin-top:10px;text-align:center'; cta.style.cssText = 'grid-column:1/-1;margin-top:10px;text-align:center';
cta.innerHTML = '<p class="muted small" style="margin:0 0 8px">New to crypto? Buy POL with a debit or credit card, Apple Pay, or Google Pay. It lands straight in your own wallet, and this site never touches your money.</p>' cta.innerHTML = '<p class="muted small" style="margin:0 0 8px">New to crypto? Buy POL with a card on any major exchange or on-ramp, then send it to your own wallet on the Polygon network. This site never touches your money.</p>'
+ '<button class="btn small sec" id="moonpayBtn" type="button">💳 Buy POL with a card</button> <a class="btn small sec" href="/wallets" target="_blank" rel="noopener">Wallet and MoonPay guide</a>'; + '<a class="btn small sec" href="/wallets" target="_blank" rel="noopener">Wallet help</a>';
wrap.appendChild(cta); wrap.appendChild(cta);
const mb = $('moonpayBtn'); if (mb) mb.addEventListener('click', () => openMoonpay(needPol));
} catch (e) {} } catch (e) {}
} }
loadBuyTiles(); loadBuyTiles();
@@ -2288,10 +2307,12 @@
if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. They have until ' + new Date(sp.claim.deadline).toLocaleString() + ' to do it, and we have told them. ') + 'You can use everything else meanwhile; your purchase waits so it pays the right person.'; if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. They have until ' + new Date(sp.claim.deadline).toLocaleString() + ' to do it, and we have told them. ') + 'You can use everything else meanwhile; your purchase waits so it pays the right person.';
if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts (Wallet tab, one free transaction), then try again.'; if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts (Wallet tab, one free transaction), then try again.';
if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.'; if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.';
if (sp.sponsorBlocked === 'tankHold') return tankHoldText(sp.tankHold);
return 'Your sponsor link could not be matched to a member. Send a ticket from Help (/help) before buying so ' + who + ' gets credit.'; return 'Your sponsor link could not be matched to a member. Send a ticket from Help (/help) before buying so ' + who + ' gets credit.';
} }
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => { $('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
const me = await (await fetch('/api/sponsor?intent=buy')).json(); const me = await (await fetch('/api/sponsor?intent=activate')).json(); // the free activation: a tank member waits for an adopter (a buy never does)
if (me.sponsorBlocked === 'tankHold') { TANK_HOLD = me.tankHold || {}; IAP.status(tankHoldText(me.tankHold), 'ok'); await render(); return; }
if (me.sponsorBlocked) { IAP.status(sponsorHoldText(me), 'bad'); return; } if (me.sponsorBlocked) { IAP.status(sponsorHoldText(me), 'bad'); return; }
IAP.status('Confirm the free activation in your wallet…'); IAP.status('Confirm the free activation in your wallet…');
const r = await IAPWallet.activate(me.sponsorId || 0); const r = await IAPWallet.activate(me.sponsorId || 0);
@@ -2448,7 +2469,7 @@
for (const p of SOCIALS) body.socials[p] = ($('soc-' + p) && $('soc-' + p).value.trim()) || ''; for (const p of SOCIALS) body.socials[p] = ($('soc-' + p) && $('soc-' + p).value.trim()) || '';
if (pfAvatar) body.avatarUrl = pfAvatar; if (pfAvatar) body.avatarUrl = pfAvatar;
const r = await api('/api/my/profile-details', body); const r = await api('/api/my/profile-details', body);
IAP.status('Profile saved.', 'ok'); IAP.status(r.notice ? 'Profile saved. ' + r.notice : 'Profile saved.', 'ok');
if (r.account) fillProfileDetails(r.account); if (r.account) fillProfileDetails(r.account);
})); }));
$('lbUploadBtn').addEventListener('click', () => $('lbFile').click()); $('lbUploadBtn').addEventListener('click', () => $('lbFile').click());
@@ -2692,7 +2713,7 @@
(function () { (function () {
const btn = document.getElementById('promoApply'), inp = document.getElementById('promoCode'), msg = document.getElementById('promoMsg'); const btn = document.getElementById('promoApply'), inp = document.getElementById('promoCode'), msg = document.getElementById('promoMsg');
if (!btn || !inp) return; if (!btn || !inp) return;
const say = (t, ok) => { msg.hidden = false; msg.textContent = t; msg.style.color = ok ? 'var(--mint)' : '#ff8a8a'; }; const say = (t, ok) => { msg.hidden = false; msg.textContent = t; msg.style.color = ok ? 'var(--mint)' : 'var(--bad)'; };
const go = async () => { const go = async () => {
const code = inp.value.trim(); if (!code) { say('Enter a promo code.', false); return; } const code = inp.value.trim(); if (!code) { say('Enter a promo code.', false); return; }
btn.disabled = true; btn.disabled = true;
+41
View File
@@ -0,0 +1,41 @@
// "Part of the network" footer line for pages that do not load common.js (Marty 2026-11-14 trust pack): company line + the network
// list from the hub (/api/network-sites, built-in copy if it does not answer). The current site comes from data-site on this tag.
(function () {
var me = (document.currentScript && document.currentScript.getAttribute('data-site')) || 'linkspin';
var FALLBACK = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(function (a) { return { id: a[0], name: a[1], url: a[2] }; });
// the links carry a referral username (Marty 2026-11-15): the signed-in member's own, else the referral this visitor came in on
// (?ref= here, remembered for the visit, then the iap.sponsor cookie; usernames only). Tracked links get it as s1 (LinkSpin sends it
// on as ?ref=), plain links as ?ref=; Earners Corner none.
function okRef(v) { return /^[A-Za-z0-9_.-]{1,40}$/.test(v) && !/^\d+$/.test(v) && !/^0x[0-9a-f]{40}$/i.test(v) && v !== 'company' && v !== 'top'; }
function arrivedRef() {
try { var q = String(new URLSearchParams(location.search).get('ref') || '').trim().toLowerCase(); if (okRef(q)) { try { sessionStorage.setItem('ls.netref', q); } catch (e) {} return q; } } catch (e) {}
try { var v = sessionStorage.getItem('ls.netref') || ''; if (okRef(v)) return v; } catch (e) {}
var m = document.cookie.match(/(?:^|;\s*)iap\.sponsor=([^;]*)/); try { var c = m ? decodeURIComponent(m[1]) : ''; return okRef(c) ? c : ''; } catch (e) { return ''; }
}
function withRef(s, ref) {
var href = s.go || s.url; if (!ref || s.id === 'earnerscorner') return href;
try { var u = new URL(href); u.searchParams.set(s.go ? 's1' : 'ref', ref); return u.toString(); } catch (e) { return href; }
}
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); }
function run() {
var f = document.querySelector('footer'); if (!f || f.querySelector('.netline')) return;
var host = f.querySelector('.wrap') || f;
var box = document.createElement('div'); box.className = 'netline';
box.style.cssText = 'flex-basis:100%;width:100%;margin-top:10px;display:flex;gap:6px 14px;flex-wrap:wrap;align-items:baseline;font-size:12.5px';
host.appendChild(box);
var list = FALLBACK, ref = arrivedRef();
var paint = function () {
box.innerHTML = '<span style="flex-basis:100%">© 2026 TrustClickz</span><b>Part of the network</b><span>One account across the network:</span>' + list.map(function (s) {
return s.id === me ? '<span aria-current="page" style="font-weight:700">' + esc(s.name) + ' (you are here)</span>' : '<a href="' + esc(withRef(s, ref)) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>';
}).join('');
};
paint();
fetch('/api/network-sites').then(function (r) { return r.json(); }).then(function (l) { if (Array.isArray(l) && l.length) { list = l; paint(); } }).catch(function () {});
fetch('/api/me', { credentials: 'same-origin' }).then(function (r) { return r.json(); }).then(function (m) { if (m && m.signedIn && m.username && okRef(m.username)) { ref = m.username; paint(); } }).catch(function () {});
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
})();
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub)
(function () { try { if (window.__nwRibbon || document.querySelector('script[src^="/assets/netweekend.js"]')) return; var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117a'; s.defer = true; s.setAttribute('data-site', 'linkspin'); (document.head || document.documentElement).appendChild(s); } catch (e) {} })();
+30
View File
@@ -0,0 +1,30 @@
// Network sign-in, the sign-in page side (2026-11-12). The SAME file ships in InstantAdPay and LinkSpin (see networksso.js).
// On a sign-in screen with no session: ask /api/sso/status once; { check: true } means bounce once through the other site,
// which signs the member in here if they are signed in there (the server allows one try per browser per 30 minutes and none
// after a sign-out). { hint } means they came from the other site but need the email code here the first time: fill it in.
(function () {
if (window.__netsso) return; window.__netsso = 1;
const BOXES = '#mcEmail,#jnEmail,#siEmail';
function fill(email, peer) {
let n = 0;
const t = setInterval(() => {
const el = document.querySelector(BOXES);
if (el && el.offsetParent !== null) {
clearInterval(t);
if (!el.value) el.value = email;
if (!document.getElementById('nssoNote')) {
const p = document.createElement('p'); p.id = 'nssoNote'; p.className = 'muted small'; p.setAttribute('role', 'note'); p.style.margin = '6px 0';
p.textContent = 'Welcome over from ' + peer + '. The first time here, send yourself a code with the same email to finish signing in. After that, ' + peer + ' signs you in here.';
(el.closest('label') || el).insertAdjacentElement('afterend', p);
}
try { el.focus(); } catch (e) {}
} else if (++n > 60) clearInterval(t);
}, 250);
}
fetch('/api/sso/status', { credentials: 'same-origin', headers: { Accept: 'application/json' }, cache: 'no-store' })
.then(r => r.json()).then(d => {
if (!d) return;
if (d.check) { location.replace('/sso/start?mode=check&to=' + encodeURIComponent(location.pathname + location.search + location.hash)); return; }
if (d.hint) fill(String(d.hint), String(d.peer || 'the other site'));
}).catch(() => {});
})();
+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
})();
+26
View File
@@ -88,6 +88,7 @@
// pasted provider forms: say at paste time which autoresponder the form posts to // pasted provider forms: say at paste time which autoresponder the form posts to
+ (k === 'formEmbed' ? '<div class="muted" id="providerNote" style="font-size:12px" hidden></div>' : '')).join(''); + (k === 'formEmbed' ? '<div class="muted" id="providerNote" style="font-size:12px" hidden></div>' : '')).join('');
if ($('imgUpload')) { $('imgUpload').addEventListener('click', () => $('imgFile').click()); $('imgFile').addEventListener('change', () => { uploadFile($('imgFile').files[0]); $('imgFile').value = ''; }); drawImages(); } if ($('imgUpload')) { $('imgUpload').addEventListener('click', () => $('imgFile').click()); $('imgFile').addEventListener('change', () => { uploadFile($('imgFile').files[0]); $('imgFile').value = ''; }); drawImages(); }
aiHeadline(p);
if ($('f-formEmbed')) { const fe = $('f-formEmbed'); const upd = () => providerNote(fe.value); fe.addEventListener('input', upd); fe.addEventListener('paste', () => setTimeout(upd, 0)); upd(); } if ($('f-formEmbed')) { const fe = $('f-formEmbed'); const upd = () => providerNote(fe.value); fe.addEventListener('input', upd); fe.addEventListener('paste', () => setTimeout(upd, 0)); upd(); }
// the Look panel: niche preset, design, colours, layout. Each change saves at once and the gallery/preview refresh. // the Look panel: niche preset, design, colours, layout. Each change saves at once and the gallery/preview refresh.
const d = p.design || {}; const setLook = async patch => { try { await api('/api/my/pages/' + p.id, patch); load(true); } catch (e) { toast(e.message, true); } }; const d = p.design || {}; const setLook = async patch => { try { await api('/api/my/pages/' + p.id, patch); load(true); } catch (e) { toast(e.message, true); } };
@@ -101,6 +102,31 @@
$('layouts').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setLook({ layout: b.dataset.l }))); $('layouts').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setLook({ layout: b.dataset.l })));
if (!quiet && window.matchMedia('(max-width:900px)').matches) $('side').scrollIntoView({ behavior: 'smooth' }); if (!quiet && window.matchMedia('(max-width:900px)').matches) $('side').scrollIntoView({ behavior: 'smooth' });
} }
// the AI ad writer on the headline (Marty 2026-11-17): the network hub reads the button link (or the scanned page) and suggests
// 3 headline + subhead pairs written only from it; picking one fills both fields to edit. Saved only with Save.
let AIW = null;
async function aiHeadline(p) {
const sub = $('f-sub'); if (!sub) return;
if (AIW === null) { try { const w = await CR.get('/api/my/adwriter'); AIW = !!(w && w.on); } catch (e) { AIW = false; } }
if (!AIW || !$('f-sub') || $('aiHead')) return;
const wrap = document.createElement('div'); wrap.id = 'aiHead'; wrap.style.margin = '0 0 10px';
wrap.innerHTML = '<button class="btn sm" type="button" id="aiHeadBtn">Write my headline from my link</button> <span class="muted" style="font-size:11px">Reads the Button link page and suggests 3 headlines with a subhead, using only what that page says.</span><div id="aiHeadList" hidden style="margin-top:8px"></div>';
$('f-sub').closest('label').after(wrap);
let opts = [];
$('aiHeadBtn').addEventListener('click', async () => {
const box = $('aiHeadList'); box.hidden = false;
const url = (($('f-ctaUrl') && $('f-ctaUrl').value) || (p.scan && p.scan.url) || '').trim();
if (!/^https?:\/\/\S+\.\S+/i.test(url)) { box.innerHTML = '<span class="muted">Put the offer link in the Button link field first (starting with https://), then tap the button again.</span>'; return; }
$('aiHeadBtn').disabled = true; box.innerHTML = '<span class="muted">Reading the page and writing 3 headlines. This takes a few seconds...</span>';
let r; try { r = await api('/api/my/adwriter', { url, kind: 'page' }); } catch (e) { r = { error: e.message || 'The ad writer did not answer. Try again in a minute.' }; }
$('aiHeadBtn').disabled = false;
if (r.error) { box.innerHTML = '<span class="bad">' + esc(r.error) + '</span>'; return; }
opts = r.options || [];
box.innerHTML = '<div class="muted" style="font-size:11px;margin-bottom:6px">Tap one to use it, then Save. Check every word is true for your offer.' + (typeof r.left === 'number' ? ' Writes left today: ' + r.left + '.' : '') + '</div>'
+ opts.map((o, i) => '<button type="button" class="btn ghost" data-ai="' + i + '" style="display:block;width:100%;text-align:left;margin:0 0 6px;white-space:normal;height:auto"><b>' + esc(o.headline) + '</b><br><span class="muted">' + esc(o.line || '') + '</span></button>').join('');
box.querySelectorAll('button[data-ai]').forEach(b => b.addEventListener('click', () => { const o = opts[Number(b.dataset.ai)]; $('f-headline').value = o.headline; if ($('f-sub')) $('f-sub').value = o.line || ''; box.hidden = true; toast('Filled in. Edit it as you like, then tap Save.'); }));
});
}
function collect(p) { const g = k => { const el = $('f-' + k); return el ? el.value : undefined; }; const c = {}; for (const [k] of F[p.type]) { if (k === 'ctaText' || k === 'ctaUrl') continue; c[k] = g(k); } c.cta = { text: g('ctaText'), url: g('ctaUrl') }; for (const k of ['bullets', 'pros', 'cons']) if (c[k] != null) c[k] = c[k].split('\n'); return c; } function collect(p) { const g = k => { const el = $('f-' + k); return el ? el.value : undefined; }; const c = {}; for (const [k] of F[p.type]) { if (k === 'ctaText' || k === 'ctaUrl') continue; c[k] = g(k); } c.cta = { text: g('ctaText'), url: g('ctaUrl') }; for (const k of ['bullets', 'pros', 'cons']) if (c[k] != null) c[k] = c[k].split('\n'); return c; }
$('edSave').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; try { await api('/api/my/pages/' + p.id, { content: collect(p), title: ($('f-headline').value || p.title).slice(0, 100) }); toast('Saved'); load(true); } catch (e) { toast(e.message, true); } }); $('edSave').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; try { await api('/api/my/pages/' + p.id, { content: collect(p), title: ($('f-headline').value || p.title).slice(0, 100) }); toast('Saved'); load(true); } catch (e) { toast(e.message, true); } });
$('edPublish').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; try { await api('/api/my/pages/' + p.id, { content: collect(p) }); const r = await api('/api/my/pages/' + p.id, { status: p.status === 'published' ? 'draft' : 'published' }); toast(r.page.status === 'published' ? 'Live at ' + pageUrl(r.page) : 'Unpublished'); load(true); } catch (e) { toast(e.message, true); } }); $('edPublish').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; try { await api('/api/my/pages/' + p.id, { content: collect(p) }); const r = await api('/api/my/pages/' + p.id, { status: p.status === 'published' ? 'draft' : 'published' }); toast(r.page.status === 'published' ? 'Live at ' + pageUrl(r.page) : 'Unpublished'); load(true); } catch (e) { toast(e.message, true); } });
+3
View File
@@ -8,6 +8,9 @@
var lsid = /^[a-z0-9]{6,20}$/i.test(P.lsid || '') ? P.lsid : ''; var lsid = /^[a-z0-9]{6,20}$/i.test(P.lsid || '') ? P.lsid : '';
document.querySelectorAll('a[data-cta]').forEach(function (a) { document.querySelectorAll('a[data-cta]').forEach(function (a) {
try { var u = new URL(a.href); for (var k in P) if (!u.searchParams.has(k)) u.searchParams.set(k, P[k]); a.href = u.toString(); } catch (e) {} try { var u = new URL(a.href); for (var k in P) if (!u.searchParams.has(k)) u.searchParams.set(k, P[k]); a.href = u.toString(); } catch (e) {}
// inside the ad viewer (a sandboxed frame with no top navigation) the button opens a new tab: an offer that refuses framing
// (X-Frame-Options: DENY) otherwise shows "refused to connect" in the frame (2026-11-23). Opened directly, the page is unchanged.
try { if (window.top !== window) { a.target = '_blank'; a.rel = 'noopener'; } } catch (e) { a.target = '_blank'; a.rel = 'noopener'; }
a.addEventListener('click', function () { try { navigator.sendBeacon('/api/p/' + slug + '/hit', new Blob([JSON.stringify({ k: 'cta' })], { type: 'application/json' })); } catch (e) {} }); a.addEventListener('click', function () { try { navigator.sendBeacon('/api/p/' + slug + '/hit', new Blob([JSON.stringify({ k: 'cta' })], { type: 'application/json' })); } catch (e) {} });
}); });
// the built-in form (.ls-form) usually arrives with the lsid filled by the server; this is the fallback. A pasted // the built-in form (.ls-form) usually arrives with the lsid filled by the server; this is the fallback. A pasted
+49 -23
View File
@@ -4,18 +4,37 @@
InstantAdPay clone (sapphire glow, mint, circuit texture) is in here. */ InstantAdPay clone (sapphire glow, mint, circuit texture) is in here. */
:root{ :root{
--bg:#E9EEF5; --panel:#FFFFFF; --panel-2:#F3F6FB; --line:#CDD7E5; --line-strong:#AEBED4; --bg:#E9EEF5; --panel:#FFFFFF; --panel-2:#F3F6FB; --line:#CDD7E5; --line-strong:#AEBED4;
--ink:#0F1B2E; --ink-2:#324361; --muted:#66768F; --ink:#0F1B2E; --ink-2:#324361; --muted:#596984;
--accent:#1F6FEB; --accent-hi:#0B4BB3; --accent-dim:#7CB2FF; --accent-soft:#E1ECFC; --accent:#1F6FEB; --accent-hi:#0B4BB3; --accent-ink:#FFFFFF; --accent-dim:#7CB2FF; --accent-soft:#E1ECFC;
--sig:#FF6A1A; --sig-2:#D9530A; --sig-soft:#FFE9DC; --sig:#FF6A1A; --sig-2:#B8420A; --sig-soft:#FFE9DC; --sig-ink:#0F1B2E; --sig-line:rgba(255,106,26,.45);
--ok:#0E8A5C; --ok-soft:#DDF4E8; --warn:#C2410C; --warn-soft:#FFE7D8; --bad:#B91C1C; --hi-row:#FFF3EA; --ok:#0B7A52; --ok-soft:#DDF4E8; --ok-ink:#FFFFFF; --ok-line:rgba(11,122,82,.4); --warn:#B23A0A; --warn-soft:#FFE7D8; --warn-line:rgba(178,58,10,.4);
--chrome:#0B1424; --chrome-2:#101D33; --chrome-ink:#EEF3FA; --chrome-sub:#8CA2C4; --chrome-line:#1E2E4A; --inset:#0F1B2E; --bad:#B91C1C; --bad-soft:#FBE0E0; --hi-row:#FFF3EA;
--chrome:#0B1424; --chrome-2:#101D33; --chrome-ink:#EEF3FA; --chrome-sub:#8CA2C4; --chrome-line:#1E2E4A; --chrome-hi:#8CC8FF; --chrome-warm:#FFB37D; --inset:#0F1B2E;
--on-ink:#FFFFFF; --field-bg:#FFFFFF; --btn-bg:linear-gradient(180deg,#FFFFFF,#F3F6FB); --btn-blue:linear-gradient(180deg,#2A74EC,#1559CC);
--panel-grad:linear-gradient(180deg,#FFFFFF,#F6F8FC); --panel-grad-hi:linear-gradient(180deg,#FFFFFF,#EEF4FE); --ph-a:#EEF2F9; --ph-b:#F5F7FC;
--hl:rgba(255,255,255,.9); --grid-dot:rgba(31,111,235,.20); --bg-glow:rgba(255,255,255,.6);
--sh:0 10px 24px -18px rgba(15,27,46,.45),0 1px 0 rgba(255,255,255,.9) inset; --sh:0 10px 24px -18px rgba(15,27,46,.45),0 1px 0 rgba(255,255,255,.9) inset;
--display:"Rajdhani","Segoe UI",system-ui,sans-serif; --body:"Manrope","Segoe UI",system-ui,sans-serif; --mono:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace; --display:"Rajdhani","Segoe UI",system-ui,sans-serif; --body:"Manrope","Segoe UI",system-ui,sans-serif; --mono:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;
color-scheme:light; color-scheme:light;
} }
/* dark variant (2026-11-01), same values as cr.css so the public pages and the Control Room match */
:root[data-theme="dark"]{
--bg:#0B1424; --panel:#142338; --panel-2:#1B2D47; --line:#273B5C; --line-strong:#3A5580;
--ink:#EEF3FA; --ink-2:#C5D2E6; --muted:#97A9C6;
--accent:#4D8DF7; --accent-hi:#8CC0FF; --accent-ink:#0B1424; --accent-dim:#3D6FC4; --accent-soft:#1B325A;
--sig:#FF7A32; --sig-2:#FFA06A; --sig-soft:#3B2416; --sig-ink:#0B1424; --sig-line:rgba(255,122,50,.45);
--ok:#3FCF92; --ok-soft:#12352A; --ok-ink:#0B1424; --ok-line:rgba(63,207,146,.4); --warn:#F7A35E; --warn-soft:#3D2716; --warn-line:rgba(247,163,94,.4);
--bad:#FF8080; --bad-soft:#44202A; --hi-row:#2B2119;
--inset:#06101E;
--on-ink:#0B1424; --field-bg:#0F1B2E; --btn-bg:linear-gradient(180deg,#1E3150,#172743); --btn-blue:linear-gradient(180deg,#8CC0FF,#5A96F5);
--panel-grad:linear-gradient(180deg,#162741,#122035); --panel-grad-hi:linear-gradient(180deg,#172A47,#15284A); --ph-a:#182A45; --ph-b:#1B2E4B;
--hl:rgba(255,255,255,.05); --grid-dot:rgba(140,192,255,.10); --bg-glow:rgba(31,111,235,.12);
--sh:0 10px 24px -18px rgba(0,0,0,.85),0 1px 0 rgba(255,255,255,.04) inset;
color-scheme:dark;
}
*{box-sizing:border-box} *{box-sizing:border-box}
html{scroll-behavior:smooth} html{scroll-behavior:smooth}
body{margin:0;min-height:100vh;display:flex;flex-direction:column;background:var(--bg);background-image:radial-gradient(circle,rgba(31,111,235,.20) 1px,transparent 1.3px),radial-gradient(120% 60% at 50% 0%,rgba(255,255,255,.6),transparent 60%);background-size:18px 18px,100% 100%;background-attachment:fixed;color:var(--ink);font:15px/1.5 var(--body)} body{margin:0;min-height:100vh;display:flex;flex-direction:column;background:var(--bg);background-image:radial-gradient(circle,var(--grid-dot) 1px,transparent 1.3px),radial-gradient(120% 60% at 50% 0%,var(--bg-glow),transparent 60%);background-size:18px 18px,100% 100%;background-attachment:fixed;color:var(--ink);font:15px/1.5 var(--body)}
a{color:var(--accent-hi)} a:hover{color:var(--accent)} a{color:var(--accent-hi)} a:hover{color:var(--accent)}
button,input,select,textarea{font:inherit;color:inherit} button,input,select,textarea{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--sig);outline-offset:2px} :focus-visible{outline:2px solid var(--sig);outline-offset:2px}
@@ -34,7 +53,7 @@ button,input,select,textarea{font:inherit;color:inherit}
.brand .mark{position:relative;width:26px;height:26px;border-radius:50%;border:3px solid var(--accent);border-right-color:transparent;display:inline-block;flex:none} .brand .mark{position:relative;width:26px;height:26px;border-radius:50%;border:3px solid var(--accent);border-right-color:transparent;display:inline-block;flex:none}
.brand .mark::after{content:"";position:absolute;right:-5px;top:-3px;width:8px;height:8px;border-radius:50%;background:var(--sig);box-shadow:0 0 0 3px rgba(255,106,26,.25)} .brand .mark::after{content:"";position:absolute;right:-5px;top:-3px;width:8px;height:8px;border-radius:50%;background:var(--sig);box-shadow:0 0 0 3px rgba(255,106,26,.25)}
.brand .word{font-family:var(--display);font-weight:700;font-size:22px;letter-spacing:.12em;text-transform:uppercase} .brand .word{font-family:var(--display);font-weight:700;font-size:22px;letter-spacing:.12em;text-transform:uppercase}
.brand .word b{color:#8CC8FF;font-weight:700} .brand .word b{color:var(--chrome-hi);font-weight:700}
.nav{display:flex;gap:18px;flex-wrap:wrap;margin-left:12px} .nav{display:flex;gap:18px;flex-wrap:wrap;margin-left:12px}
.nav a{color:var(--chrome-sub);text-decoration:none;font-weight:700;font-size:13px;padding:6px 0} .nav a{color:var(--chrome-sub);text-decoration:none;font-weight:700;font-size:13px;padding:6px 0}
.nav a:hover{color:var(--chrome-ink)} .nav a:hover{color:var(--chrome-ink)}
@@ -44,38 +63,38 @@ button,input,select,textarea{font:inherit;color:inherit}
.foot a{color:var(--chrome-sub);text-decoration:none} .foot a{color:var(--chrome-sub);text-decoration:none}
.foot a:hover{color:var(--chrome-ink)} .foot a:hover{color:var(--chrome-ink)}
.foot .word{font-family:var(--display);font-weight:700;font-size:16px;letter-spacing:.12em;text-transform:uppercase;color:var(--chrome-ink)} .foot .word{font-family:var(--display);font-weight:700;font-size:16px;letter-spacing:.12em;text-transform:uppercase;color:var(--chrome-ink)}
.foot .word b{color:#8CC8FF} .foot .word b{color:var(--chrome-hi)}
/* controls */ /* controls */
.btn{font:700 13px var(--body);letter-spacing:.04em;padding:10px 16px;border-radius:7px;border:1px solid var(--line-strong);background:linear-gradient(180deg,#FFFFFF,#F3F6FB);color:var(--ink);display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none;cursor:pointer;min-height:44px;box-shadow:0 1px 0 rgba(255,255,255,.9) inset,0 1px 2px rgba(15,27,46,.08);white-space:nowrap} .btn{font:700 13px var(--body);letter-spacing:.04em;padding:10px 16px;border-radius:7px;border:1px solid var(--line-strong);background:var(--btn-bg);color:var(--ink);display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none;cursor:pointer;min-height:44px;box-shadow:0 1px 0 var(--hl) inset,0 1px 2px rgba(15,27,46,.08);white-space:nowrap}
.btn:hover{border-color:var(--accent);color:var(--ink)} .btn:hover{border-color:var(--accent);color:var(--ink)}
.btn.pri{font-family:var(--display);font-size:16px;letter-spacing:.08em;text-transform:uppercase;background:linear-gradient(180deg,#FF7A32,var(--sig));border-color:var(--sig-2);color:#fff;box-shadow:0 8px 18px -10px rgba(255,106,26,.9),0 1px 0 rgba(255,255,255,.35) inset} .btn.pri{font-family:var(--display);font-size:16px;letter-spacing:.08em;text-transform:uppercase;background:linear-gradient(180deg,#FF7A32,var(--sig));border-color:var(--sig-2);color:var(--sig-ink);box-shadow:0 8px 18px -10px rgba(255,106,26,.9),0 1px 0 rgba(255,255,255,.35) inset}
.btn.pri:hover{background:linear-gradient(180deg,#FF8A48,var(--sig));color:#fff} .btn.pri:hover{background:linear-gradient(180deg,#FF8A48,var(--sig));color:var(--sig-ink)}
.btn.blue{background:linear-gradient(180deg,#3A83F0,var(--accent));border-color:var(--accent-hi);color:#fff;box-shadow:0 8px 18px -10px rgba(31,111,235,.9),0 1px 0 rgba(255,255,255,.3) inset} .btn.blue{background:var(--btn-blue);border-color:var(--accent-hi);color:var(--accent-ink);box-shadow:0 8px 18px -10px rgba(31,111,235,.9),0 1px 0 rgba(255,255,255,.3) inset}
.btn.blue:hover{color:#fff} .btn.blue:hover{color:var(--accent-ink)}
.btn.ghost{background:transparent;box-shadow:none;border-color:var(--chrome-line);color:var(--chrome-ink)} .btn.ghost{background:transparent;box-shadow:none;border-color:var(--chrome-line);color:var(--chrome-ink)}
.btn.ghost:hover{color:#fff;border-color:var(--chrome-sub)} .btn.ghost:hover{color:#fff;border-color:var(--chrome-sub)}
.btn[disabled]{opacity:.55;cursor:default} .btn[disabled]{opacity:.55;cursor:default}
.field{border:1px solid var(--line-strong);border-radius:6px;padding:10px 12px;background:#FFF;font:500 13px var(--mono);color:var(--ink);box-shadow:0 1px 2px rgba(15,27,46,.06) inset;width:100%;min-height:44px} .field{border:1px solid var(--line-strong);border-radius:6px;padding:10px 12px;background:var(--field-bg);font:500 13px var(--mono);color:var(--ink);box-shadow:0 1px 2px rgba(15,27,46,.06) inset;width:100%;min-height:44px}
.field:focus{border-color:var(--sig);outline:none;box-shadow:0 0 0 3px rgba(255,106,26,.18)} .field:focus{border-color:var(--sig);outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--sig) 18%,transparent)}
.lbl{display:grid;gap:5px;font:700 10.5px var(--body);letter-spacing:.08em;text-transform:uppercase;color:var(--muted)} .lbl{display:grid;gap:5px;font:700 10.5px var(--body);letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
.led{display:inline-flex;align-items:baseline;gap:10px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;padding:10px 14px;color:var(--chrome-sub);font:500 12px var(--mono);max-width:100%;overflow-wrap:anywhere} .led{display:inline-flex;align-items:baseline;gap:10px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;padding:10px 14px;color:var(--chrome-sub);font:500 12px var(--mono);max-width:100%;overflow-wrap:anywhere}
.led b{font-family:var(--display);font-size:22px;line-height:1;color:var(--sig);letter-spacing:.04em;font-weight:700} .led b{font-family:var(--display);font-size:22px;line-height:1;color:var(--sig);letter-spacing:.04em;font-weight:700}
.led .k{font-size:10px;letter-spacing:.1em;text-transform:uppercase} .led .k{font-size:10px;letter-spacing:.1em;text-transform:uppercase}
.tag{display:inline-flex;align-items:center;gap:5px;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 8px;border-radius:4px;border:1px solid var(--line-strong);color:var(--ink-2);background:var(--panel-2)} .tag{display:inline-flex;align-items:center;gap:5px;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 8px;border-radius:4px;border:1px solid var(--line-strong);color:var(--ink-2);background:var(--panel-2)}
.tag.ok{border-color:rgba(14,138,92,.4);color:var(--ok);background:var(--ok-soft)} .tag.ok{border-color:var(--ok-line);color:var(--ok);background:var(--ok-soft)}
.tag.warn{border-color:rgba(194,65,12,.4);color:var(--warn);background:var(--warn-soft)} .tag.warn{border-color:var(--warn-line);color:var(--warn);background:var(--warn-soft)}
.tag.t{border-color:var(--accent-soft);background:var(--accent-soft);color:var(--accent-hi)} .tag.t{border-color:var(--accent-soft);background:var(--accent-soft);color:var(--accent-hi)}
.note{font-size:12px;color:var(--muted);line-height:1.5} .note{font-size:12px;color:var(--muted);line-height:1.5}
.err{font-size:13px;color:var(--bad);font-weight:700} .err{font-size:13px;color:var(--bad);font-weight:700}
/* surfaces */ /* surfaces */
.tile,.panel{position:relative;background:linear-gradient(180deg,#FFFFFF,#F6F8FC);border:1px solid var(--line);border-radius:8px;box-shadow:var(--sh);min-width:0} .tile,.panel{position:relative;background:var(--panel-grad);border:1px solid var(--line);border-radius:8px;box-shadow:var(--sh);min-width:0}
.panel{background:var(--panel)} .panel{background:var(--panel)}
.tile::before,.tile::after{content:"";position:absolute;width:11px;height:11px;border:1.5px solid var(--line-strong);pointer-events:none} .tile::before,.tile::after{content:"";position:absolute;width:11px;height:11px;border:1.5px solid var(--line-strong);pointer-events:none}
.tile::before{top:5px;left:5px;border-right:0;border-bottom:0}.tile::after{bottom:5px;right:5px;border-left:0;border-top:0} .tile::before{top:5px;left:5px;border-right:0;border-bottom:0}.tile::after{bottom:5px;right:5px;border-left:0;border-top:0}
.tile.hi{background:linear-gradient(180deg,#FFFFFF,#EEF4FE)}.tile.hi::before,.tile.hi::after{border-color:var(--sig)} .tile.hi{background:var(--panel-grad-hi)}.tile.hi::before,.tile.hi::after{border-color:var(--sig)}
.ph{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 14px;border-bottom:1px solid var(--line);background:repeating-linear-gradient(135deg,#EEF2F9 0 6px,#F5F7FC 6px 12px);border-radius:8px 8px 0 0} .ph{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 14px;border-bottom:1px solid var(--line);background:repeating-linear-gradient(135deg,var(--ph-a) 0 6px,var(--ph-b) 6px 12px);border-radius:8px 8px 0 0}
.ph h3,.ph h2{font-family:var(--display);font-weight:700;font-size:14px;letter-spacing:.1em;text-transform:uppercase;margin:0;display:flex;align-items:center;gap:8px} .ph h3,.ph h2{font-family:var(--display);font-weight:700;font-size:14px;letter-spacing:.1em;text-transform:uppercase;margin:0;display:flex;align-items:center;gap:8px}
.ph h3::before,.ph h2::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block;flex:none} .ph h3::before,.ph h2::before{content:"";width:8px;height:8px;background:var(--sig);transform:rotate(45deg);display:inline-block;flex:none}
.ph .meta{font:500 10.5px var(--mono);color:var(--muted);letter-spacing:.04em} .ph .meta{font:500 10.5px var(--mono);color:var(--muted);letter-spacing:.04em}
@@ -84,9 +103,9 @@ button,input,select,textarea{font:inherit;color:inherit}
.split{display:flex;height:14px;border-radius:4px;overflow:hidden;background:var(--line)}.split i{display:block;height:100%} .split{display:flex;height:14px;border-radius:4px;overflow:hidden;background:var(--line)}.split i{display:block;height:100%}
.ico{width:22px;height:22px;stroke:var(--accent);fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex:none} .ico{width:22px;height:22px;stroke:var(--accent);fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex:none}
.check{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--ink-2)} .check{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--ink-2)}
.dot{width:7px;height:7px;border-radius:50%;background:var(--ok);display:inline-block;margin-right:8px;box-shadow:0 0 0 3px rgba(14,138,92,.22);animation:pulse 2.4s ease-in-out infinite} .dot{width:7px;height:7px;border-radius:50%;background:var(--ok);display:inline-block;margin-right:8px;box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 22%,transparent);animation:pulse 2.4s ease-in-out infinite}
.dot.off{background:var(--muted);animation:none;box-shadow:none} .dot.off{background:var(--muted);animation:none;box-shadow:none}
@keyframes pulse{0%,100%{box-shadow:0 0 0 3px rgba(14,138,92,.22)}50%{box-shadow:0 0 0 5px rgba(14,138,92,.08)}} @keyframes pulse{0%,100%{box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 22%,transparent)}50%{box-shadow:0 0 0 5px color-mix(in srgb,var(--ok) 8%,transparent)}}
@media (prefers-reduced-motion:reduce){.dot{animation:none}} @media (prefers-reduced-motion:reduce){.dot{animation:none}}
/* page sections */ /* page sections */
@@ -126,7 +145,7 @@ button,input,select,textarea{font:inherit;color:inherit}
.pkg.hi .price{color:var(--accent-hi)} .pkg.hi .price{color:var(--accent-hi)}
.pkg .cr{font-size:12px;color:var(--ink-2)} .pkg .cr{font-size:12px;color:var(--ink-2)}
.ledger{background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;color:var(--chrome-sub);font:500 11px var(--mono);padding:10px 12px;line-height:1.6;overflow-x:auto} .ledger{background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;color:var(--chrome-sub);font:500 11px var(--mono);padding:10px 12px;line-height:1.6;overflow-x:auto}
.ledger .b{color:#8CC8FF}.ledger .s{color:var(--sig)} .ledger .b{color:var(--chrome-hi)}.ledger .s{color:var(--sig)}
.amts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:6px} .amts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:6px}
.amts div{display:flex;gap:10px;align-items:baseline} .amts div{display:flex;gap:10px;align-items:baseline}
.amts .n{font:700 22px var(--mono)} .amts .n{font:700 22px var(--mono)}
@@ -178,3 +197,10 @@ button,input,select,textarea{font:inherit;color:inherit}
/* JetBrains Mono joins "//" into a ligature that reads as a missing slash in URLs (Marty 2026-10-07): no ligatures anywhere */ /* JetBrains Mono joins "//" into a ligature that reads as a missing slash in URLs (Marty 2026-10-07): no ligatures anywhere */
body,input,textarea,button,code,.mono{font-variant-ligatures:none;font-feature-settings:"liga" 0,"calt" 0} body,input,textarea,button,code,.mono{font-variant-ligatures:none;font-feature-settings:"liga" 0,"calt" 0}
/* how-it-works walkthrough link + player (2026-11-18) */
.watchp{margin:12px 0 0}
.watchlink{display:inline-flex;align-items:center;gap:8px;font-weight:700;font-size:14.5px;color:var(--accent);text-decoration:underline;text-underline-offset:3px}
.watchlink svg{flex:none}
.howvid{max-width:980px;width:100%}
.howvid video{display:block;width:100%;height:auto;aspect-ratio:16/9;border-radius:8px;border:1px solid var(--line);background:#0B1424}
.howvid .note{margin:10px 0 0}
+15
View File
@@ -0,0 +1,15 @@
// Fuel Your Offers guide page (/refuel, 2026-10-24). Inside a traffic-exchange frame the session and sponsor cookies are
// dropped, so sign-in, join, member screens and off-site links open in a new tab, and /join carries the ?ref= this page
// was opened with.
(function () {
var framed = false; try { framed = window.top !== window.self; } catch (e) { framed = true; }
if (!framed) return;
var ref = ''; try { ref = new URLSearchParams(location.search).get('ref') || ''; } catch (e) {}
ref = String(ref).toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 40);
document.querySelectorAll('a[href]').forEach(function (a) {
var h = a.getAttribute('href') || ''; if (h.charAt(0) === '#') return;
var member = a.host === location.host && /^\/(join|credits|ads|links|signin|login)(\/|$)/.test(a.pathname);
if (member && ref && a.pathname === '/join' && !/[?&]ref=/.test(a.search)) a.search = (a.search ? a.search + '&' : '?') + 'ref=' + ref;
if (member || a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; }
});
})();
+4 -1
View File
@@ -20,6 +20,7 @@
CR.tile({ k: 'Bots dropped', v: fmt(t.bots), series: sb, delta: CR.delta(b1, b0, 'vs prior'), note: t.served ? Math.round(t.bots / (t.served + t.bots) * 100) + '% of hits' : '' }), CR.tile({ k: 'Bots dropped', v: fmt(t.bots), series: sb, delta: CR.delta(b1, b0, 'vs prior'), note: t.served ? Math.round(t.bots / (t.served + t.bots) * 100) + '% of hits' : '' }),
CR.tile({ k: 'Joins', v: fmt(t.joins), note: t.unique ? (t.joins / t.unique * 100).toFixed(1) + '% of unique' : '' }), CR.tile({ k: 'Joins', v: fmt(t.joins), note: t.unique ? (t.joins / t.unique * 100).toFixed(1) + '% of unique' : '' }),
CR.tile({ k: 'Buyers', v: fmt(t.purchases), hi: true, note: t.joins ? Math.round(t.purchases / t.joins * 100) + '% of joins' : '' }), CR.tile({ k: 'Buyers', v: fmt(t.purchases), hi: true, note: t.joins ? Math.round(t.purchases / t.joins * 100) + '% of joins' : '' }),
CR.tile({ k: 'Goals', v: fmt(t.goals) }),
CR.tile({ k: 'Partner conversions', v: fmt(t.external) }), CR.tile({ k: 'Partner conversions', v: fmt(t.external) }),
// Banner Spin totals beside spin links (2026-10-20) // Banner Spin totals beside spin links (2026-10-20)
CR.tile({ k: 'Banner views', v: fmt(((s.bannerSpins || {}).totals || {}).imps), note: ((s.bannerSpins || {}).count || 0) + ' Banner Spin' + (((s.bannerSpins || {}).count || 0) === 1 ? '' : 's') }), CR.tile({ k: 'Banner views', v: fmt(((s.bannerSpins || {}).totals || {}).imps), note: ((s.bannerSpins || {}).count || 0) + ' Banner Spin' + (((s.bannerSpins || {}).count || 0) === 1 ? '' : 's') }),
@@ -34,7 +35,9 @@
const hmax = Math.max(1, ...(s.hours || [])); $('hourBars').innerHTML = (s.hours || []).map((n, i) => '<i class="' + (n >= hmax * 0.6 ? '' : 'dim') + '" style="height:' + Math.round(n / hmax * 100) + '%" title="' + i + ':00 UTC · ' + n + '"></i>').join(''); const hmax = Math.max(1, ...(s.hours || [])); $('hourBars').innerHTML = (s.hours || []).map((n, i) => '<i class="' + (n >= hmax * 0.6 ? '' : 'dim') + '" style="height:' + Math.round(n / hmax * 100) + '%" title="' + i + ':00 UTC · ' + n + '"></i>').join('');
const best = (s.hours || []).map((n, i) => [n, i]).sort((a, b) => b[0] - a[0]).slice(0, 3).filter(x => x[0]).map(x => x[1] + ':00'); const best = (s.hours || []).map((n, i) => [n, i]).sort((a, b) => b[0] - a[0]).slice(0, 3).filter(x => x[0]).map(x => x[1] + ':00');
$('hourNote').textContent = best.length ? 'Busiest hours (UTC): ' + best.join(', ') + '. Hour rules per link come next.' : 'No clicks yet.'; $('hourNote').textContent = best.length ? 'Busiest hours (UTC): ' + best.join(', ') + '. Hour rules per link come next.' : 'No clicks yet.';
$('convRows').innerHTML = kv(s.conversions || [], 0); // one list (2026-11-07): site and network events first, then goals, a value beside anything that has one
const CONV_NAME = { join: 'Joins', lead: 'Leads', wallet: 'Wallets', purchase: 'Purchases', external: 'Partner postbacks' };
$('convRows').innerHTML = kv((s.conversions || []).map(x => ({ k: (CONV_NAME[x.k] || String(x.k).replace(/^goal:\s*/, 'Goal: ')) + (x.value ? ' \u00b7 $' + Number(x.value).toFixed(2) : ''), n: x.n })), 0);
// -- Pages and Zones (2026-10-10): one bar per Central day in the range (empty days are zero), totals, per-item table // -- Pages and Zones (2026-10-10): one bar per Central day in the range (empty days are zero), totals, per-item table
const dayBars = (barsId, axisId, rows, f, g, empty) => { const dayBars = (barsId, axisId, rows, f, g, empty) => {
const map = {}; (rows || []).forEach(r => { map[r.day] = r; }); const map = {}; (rows || []).forEach(r => { map[r.day] = r; });
+169 -108
View File
@@ -26,7 +26,7 @@ a:hover{text-decoration:underline}
.wrap{max-width:1100px;margin:0 auto;padding:0 22px} .wrap{max-width:1100px;margin:0 auto;padding:0 22px}
h1,h2,h3{font-family:var(--disp);letter-spacing:-.015em} h1,h2,h3{font-family:var(--disp);letter-spacing:-.015em}
/* ── nav: capsule pill ─────────────────────────────── */ /* ── nav: capsule pill ─────────────────────────────── */
nav{position:sticky;top:0;z-index:10;background:rgba(4,8,7,.7);backdrop-filter:blur(16px); nav{position:sticky;top:0;z-index:10;background:var(--nav-bg);backdrop-filter:blur(16px);
-webkit-backdrop-filter:blur(16px);border-bottom:1px solid var(--line)} -webkit-backdrop-filter:blur(16px);border-bottom:1px solid var(--line)}
nav .wrap{display:flex;align-items:center;gap:20px;min-height:66px;flex-wrap:wrap;padding-top:8px;padding-bottom:8px} nav .wrap{display:flex;align-items:center;gap:20px;min-height:66px;flex-wrap:wrap;padding-top:8px;padding-bottom:8px}
.logo{font-family:var(--disp);font-weight:800;font-size:20px;color:var(--ink)} .logo{font-family:var(--disp);font-weight:800;font-size:20px;color:var(--ink)}
@@ -36,13 +36,13 @@ nav .wrap{display:flex;align-items:center;gap:20px;min-height:66px;flex-wrap:wra
.byline b{color:var(--ink);font-weight:600} .byline b{color:var(--ink);font-weight:600}
.bo-side .byline{padding:4px 8px 10px;white-space:normal} .bo-side .byline{padding:4px 8px 10px;white-space:normal}
@media (max-width:560px){nav .byline{font-size:9.5px}} @media (max-width:560px){nav .byline{font-size:9.5px}}
nav .links{display:flex;gap:4px;flex:1;flex-wrap:wrap;background:rgba(16,28,24,.7);border:1px solid var(--line); nav .links{display:flex;gap:4px;flex:1;flex-wrap:wrap;background:var(--pill-bg);border:1px solid var(--line);
border-radius:999px;padding:5px 8px;width:fit-content;flex:0 1 auto;margin:0 auto} border-radius:999px;padding:5px 8px;width:fit-content;flex:0 1 auto;margin:0 auto}
nav .links a{color:var(--muted);font-size:13.5px;font-weight:600;padding:7px 14px;border-radius:999px} nav .links a{color:var(--muted);font-size:13.5px;font-weight:600;padding:7px 14px;border-radius:999px}
nav .links a:hover{color:var(--ink);text-decoration:none} nav .links a:hover{color:var(--ink);text-decoration:none}
nav .links a.active{color:var(--mint);background:rgba(59,157,255,.1)} nav .links a.active{color:var(--mint);background:var(--mint-soft)}
#navWallet{font-size:13px;margin-left:auto} #navWallet{font-size:13px;margin-left:auto}
.rehearsal{background:rgba(59,157,255,.07);border-bottom:1px solid var(--line);color:var(--muted); .rehearsal{background:var(--mint-faint);border-bottom:1px solid var(--line);color:var(--muted);
text-align:center;font-size:12.5px;padding:7px 12px} text-align:center;font-size:12.5px;padding:7px 12px}
.rehearsal b{color:var(--mint)} .rehearsal b{color:var(--mint)}
/* ── buttons ───────────────────────────────────────── */ /* ── buttons ───────────────────────────────────────── */
@@ -50,8 +50,8 @@ nav .links a.active{color:var(--mint);background:rgba(59,157,255,.1)}
padding:13px 26px;font-weight:700;font-size:15px;cursor:pointer;font-family:var(--disp); padding:13px 26px;font-weight:700;font-size:15px;cursor:pointer;font-family:var(--disp);
box-shadow:0 4px 30px rgba(59,157,255,.35);transition:transform .16s ease,box-shadow .16s ease,background .16s ease} box-shadow:0 4px 30px rgba(59,157,255,.35);transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
.btn:hover{transform:translateY(-2px);background:var(--mint-hi);box-shadow:0 8px 44px rgba(59,157,255,.5);text-decoration:none} .btn:hover{transform:translateY(-2px);background:var(--mint-hi);box-shadow:0 8px 44px rgba(59,157,255,.5);text-decoration:none}
.btn.sec{background:transparent;color:var(--mint);border:1px solid rgba(59,157,255,.6);box-shadow:none} .btn.sec{background:transparent;color:var(--mint);border:1px solid var(--mint-line-2);box-shadow:none}
.btn.sec:hover{background:rgba(59,157,255,.08);box-shadow:0 4px 26px rgba(59,157,255,.2)} .btn.sec:hover{background:var(--mint-faint);box-shadow:0 4px 26px rgba(59,157,255,.2)}
.btn.small{padding:8px 17px;font-size:13px} .btn.small{padding:8px 17px;font-size:13px}
.btn:disabled{opacity:.45;cursor:default;transform:none;box-shadow:none} .btn:disabled{opacity:.45;cursor:default;transform:none;box-shadow:none}
/* ── hero: centered, light-trail set-piece ─────────── */ /* ── hero: centered, light-trail set-piece ─────────── */
@@ -68,7 +68,7 @@ nav .links a.active{color:var(--mint);background:rgba(59,157,255,.1)}
.arc2{fill:none;stroke:url(#arcGrad);stroke-width:3;stroke-linecap:round;filter:url(#arcGlow);opacity:.8} .arc2{fill:none;stroke:url(#arcGrad);stroke-width:3;stroke-linecap:round;filter:url(#arcGlow);opacity:.8}
/* falling glow streaks */ /* falling glow streaks */
.streak{position:absolute;top:-140px;width:1.5px;height:110px;pointer-events:none; .streak{position:absolute;top:-140px;width:1.5px;height:110px;pointer-events:none;
background:linear-gradient(180deg,transparent,rgba(143,251,227,.8));border-radius:2px;opacity:0} background:linear-gradient(180deg,transparent,var(--mint-hi));border-radius:2px;opacity:0}
@media(prefers-reduced-motion:no-preference){ @media(prefers-reduced-motion:no-preference){
.streak{animation:fall 7s linear infinite} .streak{animation:fall 7s linear infinite}
@keyframes fall{0%{transform:translateY(0);opacity:0}12%{opacity:.7}55%{opacity:.5}75%{transform:translateY(72vh);opacity:0}100%{transform:translateY(72vh);opacity:0}} @keyframes fall{0%{transform:translateY(0);opacity:0}12%{opacity:.7}55%{opacity:.5}75%{transform:translateY(72vh);opacity:0}100%{transform:translateY(72vh);opacity:0}}
@@ -85,7 +85,7 @@ section{padding:64px 0 8px}
.cmp{width:100%;border-collapse:separate;border-spacing:0;font-size:15px;background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden} .cmp{width:100%;border-collapse:separate;border-spacing:0;font-size:15px;background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.cmp th,.cmp td{padding:13px 16px;border-bottom:1px solid var(--line);vertical-align:top;text-align:left} .cmp th,.cmp td{padding:13px 16px;border-bottom:1px solid var(--line);vertical-align:top;text-align:left}
.cmp th{font-family:var(--disp);font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)} .cmp th{font-family:var(--disp);font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.cmp th:last-child,.cmp td:last-child{color:var(--ink);background:rgba(59,157,255,.06)} .cmp th:last-child,.cmp td:last-child{color:var(--ink);background:var(--mint-faint)}
.cmp td:first-child{font-weight:700;white-space:nowrap} .cmp td:first-child{font-weight:700;white-space:nowrap}
.cmp td:nth-child(2){color:var(--muted)} .cmp td:nth-child(2){color:var(--muted)}
.cmp tr:last-child td{border-bottom:0} .cmp tr:last-child td{border-bottom:0}
@@ -99,11 +99,11 @@ h3{font-size:16.5px;margin:0 0 8px;font-weight:700}
/* icon-plate feature cards */ /* icon-plate feature cards */
.plates{display:grid;gap:16px;grid-template-columns:1fr} .plates{display:grid;gap:16px;grid-template-columns:1fr}
@media(min-width:760px){.plates{grid-template-columns:1fr 1fr 1fr}} @media(min-width:760px){.plates{grid-template-columns:1fr 1fr 1fr}}
.platecard{background:linear-gradient(170deg,rgba(22,38,32,.6),rgba(10,18,15,.7));border:1px solid var(--line); .platecard{background:var(--panel-grad);border:1px solid var(--line);
border-radius:var(--radius);padding:26px 22px;text-align:center;transition:border-color .2s ease,transform .2s ease} border-radius:var(--radius);padding:26px 22px;text-align:center;transition:border-color .2s ease,transform .2s ease}
.platecard:hover{border-color:var(--line-strong);transform:translateY(-4px)} .platecard:hover{border-color:var(--line-strong);transform:translateY(-4px)}
.plate{width:88px;height:88px;margin:0 auto 18px;border-radius:22px;display:grid;place-items:center; .plate{width:88px;height:88px;margin:0 auto 18px;border-radius:22px;display:grid;place-items:center;
background:linear-gradient(160deg,#12241e,#0a1411);border:1px solid var(--line-strong); background:var(--panel-grad-deep);border:1px solid var(--line-strong);
box-shadow:0 0 34px rgba(59,157,255,.15),inset 0 1px 0 rgba(143,251,227,.15)} box-shadow:0 0 34px rgba(59,157,255,.15),inset 0 1px 0 rgba(143,251,227,.15)}
.plate svg{width:38px;height:38px;stroke:var(--mint);fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round} .plate svg{width:38px;height:38px;stroke:var(--mint);fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.platecard p{color:var(--muted);font-size:14px;margin:0} .platecard p{color:var(--muted);font-size:14px;margin:0}
@@ -115,15 +115,15 @@ h3{font-size:16.5px;margin:0 0 8px;font-weight:700}
.flankitem .plate svg{width:24px;height:24px} .flankitem .plate svg{width:24px;height:24px}
.flankitem p{color:var(--muted);font-size:13.5px;margin:0} .flankitem p{color:var(--muted);font-size:13.5px;margin:0}
/* ledger mockup frame */ /* ledger mockup frame */
.mockup{background:linear-gradient(170deg,#0e1c17,#080f0c);border:1px solid var(--line-strong);border-radius:20px; .mockup{background:var(--panel-grad-deep);border:1px solid var(--line-strong);border-radius:20px;
box-shadow:0 30px 80px rgba(0,0,0,.6),0 0 60px rgba(59,157,255,.08);overflow:hidden} box-shadow:0 30px 80px rgba(0,0,0,.6),0 0 60px rgba(59,157,255,.08);overflow:hidden}
.mockup .bar{display:flex;gap:6px;align-items:center;padding:11px 14px;border-bottom:1px solid var(--line)} .mockup .bar{display:flex;gap:6px;align-items:center;padding:11px 14px;border-bottom:1px solid var(--line)}
.mockup .bar i{width:9px;height:9px;border-radius:50%;background:#1e3a31;display:inline-block} .mockup .bar i{width:9px;height:9px;border-radius:50%;background:var(--line-strong);display:inline-block}
.mockup .bar .addr{font-family:var(--mono);font-size:11px;color:var(--muted);margin-left:8px;background:rgba(4,8,7,.6); .mockup .bar .addr{font-family:var(--mono);font-size:11px;color:var(--muted);margin-left:8px;background:var(--ground-soft);
border-radius:999px;padding:3px 12px} border-radius:999px;padding:3px 12px}
.mockup .body{padding:6px 0} .mockup .body{padding:6px 0}
.mockup .mrow{display:flex;justify-content:space-between;gap:10px;padding:9px 16px;font-family:var(--mono); .mockup .mrow{display:flex;justify-content:space-between;gap:10px;padding:9px 16px;font-family:var(--mono);
font-size:12px;border-bottom:1px solid rgba(84,150,128,.08)} font-size:12px;border-bottom:1px solid var(--line)}
.mockup .mrow span:last-child{color:var(--mint)} .mockup .mrow span:last-child{color:var(--mint)}
.mockup .mrow.dim span:last-child{color:var(--muted)} .mockup .mrow.dim span:last-child{color:var(--muted)}
/* 2-col story block: iso illustration + checklist */ /* 2-col story block: iso illustration + checklist */
@@ -133,24 +133,24 @@ h3{font-size:16.5px;margin:0 0 8px;font-weight:700}
.checks li{padding:7px 0 7px 30px;position:relative;color:var(--muted);font-size:14.5px} .checks li{padding:7px 0 7px 30px;position:relative;color:var(--muted);font-size:14.5px}
.checks li::before{content:"✓";position:absolute;left:0;top:6px;width:20px;height:20px;border-radius:50%; .checks li::before{content:"✓";position:absolute;left:0;top:6px;width:20px;height:20px;border-radius:50%;
background:var(--mint-soft);color:var(--mint);font-size:12px;font-weight:700;display:grid;place-items:center; background:var(--mint-soft);color:var(--mint);font-size:12px;font-weight:700;display:grid;place-items:center;
border:1px solid rgba(59,157,255,.35)} border:1px solid var(--mint-line)}
.chips{display:flex;gap:8px;margin:14px 0 4px;flex-wrap:wrap} .chips{display:flex;gap:8px;margin:14px 0 4px;flex-wrap:wrap}
.chip-t{border:1px solid var(--line-strong);border-radius:999px;padding:5px 16px;font-size:12.5px;color:var(--muted);font-family:var(--disp);font-weight:600} .chip-t{border:1px solid var(--line-strong);border-radius:999px;padding:5px 16px;font-size:12.5px;color:var(--muted);font-family:var(--disp);font-weight:600}
.chip-t.on{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)} .chip-t.on{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)}
.iso{filter:drop-shadow(0 24px 50px rgba(0,0,0,.5))} .iso{filter:drop-shadow(0 24px 50px rgba(0,0,0,.5))}
/* level cycler: light the paying generation */ /* level cycler: light the paying generation */
#genViz .edge path{stroke:#22523f;transition:stroke .5s ease} #genViz .edge path{stroke:var(--line-strong);transition:stroke .5s ease}
#genViz .node-o{fill:#122e25;stroke:#2f6b55;stroke-width:1.3;transition:stroke .5s ease,fill .5s ease} #genViz .node-o{fill:var(--panel-solid);stroke:var(--line-strong);stroke-width:1.3;transition:stroke .5s ease,fill .5s ease}
#genViz .node-d{fill:#3f8f74;transition:fill .5s ease} #genViz .node-d{fill:var(--muted);transition:fill .5s ease}
#genViz[data-lvl="1"] .e1 path,#genViz[data-lvl="2"] .e2 path,#genViz[data-lvl="3"] .e3 path{stroke:#3b9dff} #genViz[data-lvl="1"] .e1 path,#genViz[data-lvl="2"] .e2 path,#genViz[data-lvl="3"] .e3 path{stroke:var(--mint)}
#genViz[data-lvl="1"] .g1 .node-o,#genViz[data-lvl="2"] .g2 .node-o,#genViz[data-lvl="3"] .g3 .node-o{stroke:#3b9dff;fill:#11362b} #genViz[data-lvl="1"] .g1 .node-o,#genViz[data-lvl="2"] .g2 .node-o,#genViz[data-lvl="3"] .g3 .node-o{stroke:var(--mint);fill:var(--mint-soft-2)}
#genViz[data-lvl="1"] .g1 .node-d,#genViz[data-lvl="2"] .g2 .node-d,#genViz[data-lvl="3"] .g3 .node-d{fill:#3b9dff} #genViz[data-lvl="1"] .g1 .node-d,#genViz[data-lvl="2"] .g2 .node-d,#genViz[data-lvl="3"] .g3 .node-d{fill:var(--mint)}
.chips button{cursor:pointer;background:transparent;font:inherit} .chips button{cursor:pointer;background:transparent;font:inherit}
.chips button.chip-t{border:1px solid var(--line-strong);color:var(--muted)} .chips button.chip-t{border:1px solid var(--line-strong);color:var(--muted)}
.chips button.chip-t.on{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)} .chips button.chip-t.on{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)}
/* pricing tiles: mint discipline */ /* pricing tiles: mint discipline */
.tiles{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));align-items:stretch} .tiles{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));align-items:stretch}
.tile{position:relative;background:linear-gradient(170deg,rgba(22,38,32,.55),rgba(10,18,15,.65));border:1px solid var(--line); .tile{position:relative;background:var(--panel-grad);border:1px solid var(--line);
border-radius:var(--radius);padding:26px 18px;text-align:center;display:flex;flex-direction:column;gap:6px; border-radius:var(--radius);padding:26px 18px;text-align:center;display:flex;flex-direction:column;gap:6px;
transition:transform .2s ease,border-color .2s ease} transition:transform .2s ease,border-color .2s ease}
.tile:hover{transform:translateY(-5px);border-color:var(--line-strong)} .tile:hover{transform:translateY(-5px);border-color:var(--line-strong)}
@@ -159,7 +159,7 @@ h3{font-size:16.5px;margin:0 0 8px;font-weight:700}
.tile .cr{color:var(--mint);font-weight:700;font-size:14.5px} .tile .cr{color:var(--mint);font-weight:700;font-size:14.5px}
.tile .bonus{font-size:12px;color:var(--mint-hi)} .tile .bonus{font-size:12px;color:var(--mint-hi)}
.tile .pol{font-family:var(--mono);font-size:12px;color:var(--muted);flex:1} .tile .pol{font-family:var(--mono);font-size:12px;color:var(--muted);flex:1}
.tile.hot{border:1px solid rgba(59,157,255,.65);box-shadow:0 0 44px rgba(59,157,255,.14)} .tile.hot{border:1px solid var(--mint-line-2);box-shadow:0 0 44px rgba(59,157,255,.14)}
.tile.hot::before{content:"MOST POPULAR";position:absolute;top:-11px;left:50%;transform:translateX(-50%); .tile.hot::before{content:"MOST POPULAR";position:absolute;top:-11px;left:50%;transform:translateX(-50%);
background:var(--mint);color:var(--mint-ink);font-family:var(--disp);font-size:10px;font-weight:800; background:var(--mint);color:var(--mint-ink);font-family:var(--disp);font-size:10px;font-weight:800;
letter-spacing:.12em;border-radius:999px;padding:4px 14px} letter-spacing:.12em;border-radius:999px;padding:4px 14px}
@@ -167,14 +167,14 @@ h3{font-size:16.5px;margin:0 0 8px;font-weight:700}
.split{display:flex;gap:8px;margin:18px 0} .split{display:flex;gap:8px;margin:18px 0}
.split div{border-radius:12px;padding:16px 6px;text-align:center;font-size:13px;font-weight:700;font-family:var(--disp); .split div{border-radius:12px;padding:16px 6px;text-align:center;font-size:13px;font-weight:700;font-family:var(--disp);
border:1px solid var(--line-strong);color:var(--mint)} border:1px solid var(--line-strong);color:var(--mint)}
.split .s50{flex:5;background:rgba(59,157,255,.16);box-shadow:0 0 30px rgba(59,157,255,.12)} .split .s50{flex:5;background:var(--mint-soft-2);box-shadow:0 0 30px rgba(59,157,255,.12)}
.split .s20{flex:2;background:rgba(59,157,255,.09)} .split .s20{flex:2;background:var(--mint-soft)}
.split .s10{flex:1;background:rgba(59,157,255,.05)} .split .s10{flex:1;background:var(--mint-faint)}
.split .sa{flex:2;background:rgba(139,166,156,.08);color:var(--muted)} .split .sa{flex:2;background:var(--muted-soft);color:var(--muted)}
section[id]{scroll-margin-top:84px} /* anchored menu targets clear the sticky nav */ section[id]{scroll-margin-top:84px} /* anchored menu targets clear the sticky nav */
/* ticker */ /* ticker */
.ticker{overflow:hidden;contain:layout paint;border-top:1px solid var(--line);border-bottom:1px solid var(--line); .ticker{overflow:hidden;contain:layout paint;border-top:1px solid var(--line);border-bottom:1px solid var(--line);
background:rgba(59,157,255,.04);white-space:nowrap;padding:10px 0; background:var(--mint-faint);white-space:nowrap;padding:10px 0;
-webkit-mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent); -webkit-mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent);
mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent)} mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent)}
.ticker .inner{display:inline-block;font-family:var(--mono);font-size:12.5px;padding-left:100%;animation:tick 120s linear infinite} .ticker .inner{display:inline-block;font-family:var(--mono);font-size:12.5px;padding-left:100%;animation:tick 120s linear infinite}
@@ -202,32 +202,32 @@ tr:last-child td{border-bottom:0}
.feed .t-TierPaid{color:var(--mint)} .feed .t-TierPaid{color:var(--mint)}
.feed .t-AdminPaid{color:var(--muted)} .feed .t-AdminPaid{color:var(--muted)}
.feed .tx a{color:var(--muted);font-size:12px} .feed .tx a{color:var(--muted);font-size:12px}
.badge{display:inline-block;background:var(--mint-soft);color:var(--mint);border:1px solid rgba(59,157,255,.35); .badge{display:inline-block;background:var(--mint-soft);color:var(--mint);border:1px solid var(--mint-line);
border-radius:999px;padding:3px 13px;font-size:12px;font-weight:700} border-radius:999px;padding:3px 13px;font-size:12px;font-weight:700}
.spend-banner{background:linear-gradient(160deg,rgba(242,201,76,.14),rgba(242,201,76,.04));border-color:rgba(242,201,76,.55);text-align:center;padding:22px 20px} .spend-banner{background:linear-gradient(160deg,var(--gold-soft),var(--gold-faint));border-color:var(--gold-line);text-align:center;padding:22px 20px}
.spend-banner .lbl{font-family:var(--disp);font-size:13px;letter-spacing:.14em;text-transform:uppercase;color:#f2c94c} .spend-banner .lbl{font-family:var(--disp);font-size:13px;letter-spacing:.14em;text-transform:uppercase;color:var(--gold-2)}
.spend-banner .big{font-family:var(--disp);font-size:clamp(40px,6vw,64px);font-weight:800;color:#f2c94c;line-height:1.05;margin:6px 0 4px;font-variant-numeric:tabular-nums} .spend-banner .big{font-family:var(--disp);font-size:clamp(40px,6vw,64px);font-weight:800;color:var(--gold-2);line-height:1.05;margin:6px 0 4px;font-variant-numeric:tabular-nums}
.spend-banner .big .unit{font-size:20px;font-weight:700;color:var(--ink)} .spend-banner .big .unit{font-size:20px;font-weight:700;color:var(--ink)}
.spend-banner .sub{color:var(--ink);font-size:15px} .spend-banner .sub{color:var(--ink);font-size:15px}
.spend-banner .rates{display:flex;gap:8px 18px;flex-wrap:wrap;justify-content:center;margin-top:12px;font-size:12.5px;color:var(--muted)} .spend-banner .rates{display:flex;gap:8px 18px;flex-wrap:wrap;justify-content:center;margin-top:12px;font-size:12.5px;color:var(--muted)}
.spend-banner .rates b{color:var(--ink)} .spend-banner .rates b{color:var(--ink)}
.boot-spin{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;min-height:60vh} .boot-spin{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;min-height:60vh}
.boot-spin .ring{width:46px;height:46px;border-radius:50%;border:4px solid rgba(59,157,255,.18);border-top-color:var(--mint);animation:bootspin .9s linear infinite} .boot-spin .ring{width:46px;height:46px;border-radius:50%;border:4px solid var(--mint-soft-2);border-top-color:var(--mint);animation:bootspin .9s linear infinite}
@keyframes bootspin{to{transform:rotate(360deg)}} @keyframes bootspin{to{transform:rotate(360deg)}}
.bo-top{flex-wrap:wrap} .bo-top{flex-wrap:wrap}
.ad-strip{flex:1 1 100%;font-size:13.5px;padding:8px 0 2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .ad-strip{flex:1 1 100%;font-size:13.5px;padding:8px 0 2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ad-strip a{color:var(--ink)} .ad-strip a{color:var(--ink)}
.ad-strip b{color:var(--mint)} .ad-strip b{color:var(--mint)}
.ad-foot{text-align:center} .ad-foot{text-align:center}
.pv{border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:0 0 16px;background:rgba(4,8,7,.35)} .pv{border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:0 0 16px;background:var(--ground-soft)}
.pv-head b{display:block;font-size:18px;margin:4px 0 2px} .pv-head b{display:block;font-size:18px;margin:4px 0 2px}
.done-big{display:flex;flex-direction:column;align-items:center;gap:6px;padding:26px 16px;text-align:center} .done-big{display:flex;flex-direction:column;align-items:center;gap:6px;padding:26px 16px;text-align:center}
.done-big .tick{width:84px;height:84px;border-radius:50%;display:grid;place-items:center;font-size:48px;font-weight:800;color:var(--mint-ink);background:var(--mint);box-shadow:0 0 0 10px rgba(59,157,255,.15),0 10px 30px rgba(59,157,255,.35)} .done-big .tick{width:84px;height:84px;border-radius:50%;display:grid;place-items:center;font-size:48px;font-weight:800;color:var(--mint-ink);background:var(--mint);box-shadow:0 0 0 10px rgba(59,157,255,.15),0 10px 30px rgba(59,157,255,.35)}
.done-big b{font-family:var(--disp);font-size:22px;margin-top:8px} .done-big b{font-family:var(--disp);font-size:22px;margin-top:8px}
.badge.amber{background:rgba(139,166,156,.1);border-color:rgba(139,166,156,.4);color:var(--muted)} .badge.amber{background:var(--muted-soft);border-color:var(--line-strong);color:var(--muted)}
/* faq */ /* faq */
details{border:1px solid var(--line);border-radius:14px;margin:0 0 10px;background:var(--panel)} details{border:1px solid var(--line);border-radius:14px;margin:0 0 10px;background:var(--panel)}
details[open]{border-color:rgba(59,157,255,.45)} details[open]{border-color:var(--mint-line)}
summary{cursor:pointer;padding:16px 20px;font-weight:700;font-family:var(--disp);font-size:15px;list-style:none} summary{cursor:pointer;padding:16px 20px;font-weight:700;font-family:var(--disp);font-size:15px;list-style:none}
summary::before{content:"+";color:var(--mint);font-weight:800;margin-right:12px} summary::before{content:"+";color:var(--mint);font-weight:800;margin-right:12px}
details[open] summary::before{content:"−"} details[open] summary::before{content:"−"}
@@ -235,16 +235,16 @@ details p{margin:0;padding:0 20px 18px 42px;color:var(--muted);font-size:14.5px}
/* closing cta card */ /* closing cta card */
.closer{position:relative;display:grid;gap:26px;align-items:center;grid-template-columns:1fr; .closer{position:relative;display:grid;gap:26px;align-items:center;grid-template-columns:1fr;
padding:44px 36px;border-radius:24px;overflow:hidden;margin:80px 0 0; padding:44px 36px;border-radius:24px;overflow:hidden;margin:80px 0 0;
background:linear-gradient(160deg,#0d1d17,#060c0a);border:1px solid var(--line-strong)} background:var(--panel-grad-deep);border:1px solid var(--line-strong)}
@media(min-width:880px){.closer{grid-template-columns:1.2fr .8fr}} @media(min-width:880px){.closer{grid-template-columns:1.2fr .8fr}}
.closer::before{content:"";position:absolute;width:460px;height:460px;right:-140px;top:-260px;border-radius:50%; .closer::before{content:"";position:absolute;width:460px;height:460px;right:-140px;top:-260px;border-radius:50%;
background:radial-gradient(circle,rgba(59,157,255,.2),transparent 65%);pointer-events:none} background:radial-gradient(circle,var(--mint-soft-2),transparent 65%);pointer-events:none}
.closer h2{margin:0 0 12px} .closer h2{margin:0 0 12px}
/* footer + ghost wordmark */ /* footer + ghost wordmark */
footer{border-top:1px solid var(--line);margin-top:90px;padding:34px 0 0;color:var(--muted);font-size:13.5px;overflow:hidden} footer{border-top:1px solid var(--line);margin-top:90px;padding:34px 0 0;color:var(--muted);font-size:13.5px;overflow:hidden}
.ghost{font-family:var(--disp);font-weight:800;font-size:clamp(64px,13vw,170px);line-height:.9;text-align:center; .ghost{font-family:var(--disp);font-weight:800;font-size:clamp(64px,13vw,170px);line-height:.9;text-align:center;
margin:34px 0 -20px;letter-spacing:-.02em;user-select:none; margin:34px 0 -20px;letter-spacing:-.02em;user-select:none;
background:linear-gradient(180deg,rgba(59,157,255,.14),transparent 78%); background:linear-gradient(180deg,var(--mint-soft-2),transparent 78%);
-webkit-background-clip:text;background-clip:text;color:transparent;white-space:nowrap} -webkit-background-clip:text;background-clip:text;color:transparent;white-space:nowrap}
/* misc */ /* misc */
#status{position:fixed;left:50%;transform:translateX(-50%);bottom:22px;background:var(--panel-solid); #status{position:fixed;left:50%;transform:translateX(-50%);bottom:22px;background:var(--panel-solid);
@@ -252,7 +252,7 @@ footer{border-top:1px solid var(--line);margin-top:90px;padding:34px 0 0;color:v
box-shadow:0 12px 40px rgba(0,0,0,.55)} box-shadow:0 12px 40px rgba(0,0,0,.55)}
#status.ok{border-color:var(--mint)} #status.ok{border-color:var(--mint)}
#status.bad{border-color:var(--bad)} #status.bad{border-color:var(--bad)}
input,select,textarea{background:rgba(4,8,7,.65);border:1px solid var(--line-strong);color:var(--ink);border-radius:11px; input,select,textarea{background:var(--field-bg);border:1px solid var(--line-strong);color:var(--ink);border-radius:11px;
padding:11px 14px;font-size:14.5px;font-family:inherit} padding:11px 14px;font-size:14.5px;font-family:inherit}
input[type=range]{padding:0;border:0;background:transparent;accent-color:var(--mint);height:28px;vertical-align:middle} input[type=range]{padding:0;border:0;background:transparent;accent-color:var(--mint);height:28px;vertical-align:middle}
input:focus,select:focus,textarea:focus{border-color:var(--mint)} input:focus,select:focus,textarea:focus{border-color:var(--mint)}
@@ -263,15 +263,15 @@ textarea{resize:vertical;font:inherit}
.bo-body{background:var(--ground)} .bo-body{background:var(--ground)}
.bo{display:grid;grid-template-columns:236px 1fr;min-height:100vh} .bo{display:grid;grid-template-columns:236px 1fr;min-height:100vh}
.bo-side{position:sticky;top:0;height:100vh;overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none;display:flex;flex-direction:column;gap:22px; .bo-side{position:sticky;top:0;height:100vh;overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none;display:flex;flex-direction:column;gap:22px;
padding:22px 16px;background:rgba(10,18,15,.92);border-right:1px solid var(--line)} padding:22px 16px;background:var(--side-bg);border-right:1px solid var(--line)}
.bo-side .logo{font-size:19px;padding:0 8px} .bo-side .logo{font-size:19px;padding:0 8px}
.bo-menu{display:flex;flex-direction:column;gap:4px} .bo-menu{display:flex;flex-direction:column;gap:4px}
.bo-menu button{display:flex;align-items:center;gap:11px;background:transparent;border:0;color:var(--muted); .bo-menu button{display:flex;align-items:center;gap:11px;background:transparent;border:0;color:var(--muted);
font:600 14px var(--disp);padding:11px 12px;border-radius:11px;cursor:pointer;text-align:left; font:600 14px var(--disp);padding:11px 12px;border-radius:11px;cursor:pointer;text-align:left;
border-left:3px solid transparent} border-left:3px solid transparent}
.bo-menu button svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto} .bo-menu button svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}
.bo-menu button:hover{color:var(--ink);background:rgba(59,157,255,.05)} .bo-menu button:hover{color:var(--ink);background:var(--mint-faint)}
.bo-menu button.on{color:var(--mint);background:rgba(59,157,255,.09);border-left-color:var(--mint)} .bo-menu button.on{color:var(--mint);background:var(--mint-soft);border-left-color:var(--mint)}
.bo-links{display:flex;flex-direction:column;gap:2px;padding:14px 12px;border-top:1px solid var(--line)} .bo-links{display:flex;flex-direction:column;gap:2px;padding:14px 12px;border-top:1px solid var(--line)}
.bo-cap{font-family:var(--mono);font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--muted);margin-bottom:6px} .bo-cap{font-family:var(--mono);font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--muted);margin-bottom:6px}
.bo-links a{color:var(--muted);font-size:13.5px;padding:5px 0} .bo-links a{color:var(--muted);font-size:13.5px;padding:5px 0}
@@ -283,7 +283,7 @@ textarea{resize:vertical;font:inherit}
.bo-pagefoot a{color:var(--muted)} .bo-pagefoot a{color:var(--muted)}
.bo-pagefoot a:hover{color:var(--ink);text-decoration:none} .bo-pagefoot a:hover{color:var(--ink);text-decoration:none}
.bo-top{display:flex;align-items:center;gap:16px;padding:16px 26px;border-bottom:1px solid var(--line); .bo-top{display:flex;align-items:center;gap:16px;padding:16px 26px;border-bottom:1px solid var(--line);
background:rgba(6,10,8,.75);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);position:sticky;top:0;z-index:5} background:var(--nav-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);position:sticky;top:0;z-index:5}
.bo-top h2{font-size:20px} .bo-top h2{font-size:20px}
#boBurger{display:none;background:transparent;border:1px solid var(--line-strong);color:var(--ink); #boBurger{display:none;background:transparent;border:1px solid var(--line-strong);color:var(--ink);
border-radius:9px;font-size:17px;padding:5px 11px;cursor:pointer} border-radius:9px;font-size:17px;padding:5px 11px;cursor:pointer}
@@ -320,11 +320,11 @@ textarea{resize:vertical;font:inherit}
.feat-day .fd-occ{font-family:var(--mono);font-size:11px;color:var(--muted)} .feat-day .fd-occ{font-family:var(--mono);font-size:11px;color:var(--muted)}
.feat-day.open2 .fd-occ{color:var(--mint)} .feat-day.open2 .fd-occ{color:var(--mint)}
/* ── featured rotation strip ── */ /* ── featured rotation strip ── */
.feat-top{max-width:760px;margin:16px auto;border:1px solid rgba(255,177,56,.5)} .feat-top{max-width:760px;margin:16px auto;border:1px solid var(--amber-line)}
.feat-strip{display:flex;justify-content:center;margin-top:10px} .feat-strip{display:flex;justify-content:center;margin-top:10px}
.feat-strip a{max-width:728px;width:100%;display:flex;justify-content:space-between;gap:10px;padding:11px 14px;border-radius:10px; .feat-strip a{max-width:728px;width:100%;display:flex;justify-content:space-between;gap:10px;padding:11px 14px;border-radius:10px;
background:var(--panel);border:1px solid #ffb238;color:var(--ink);text-decoration:none;font-weight:600} background:var(--panel);border:1px solid var(--amber);color:var(--ink);text-decoration:none;font-weight:600}
.feat-strip a:hover{border-color:#ffd15c;box-shadow:0 0 0 1px rgba(255,177,56,.4)} .feat-strip a:hover{border-color:var(--gold);box-shadow:0 0 0 1px var(--amber-line)}
.feat-strip .by{font-size:12px;color:var(--muted);font-weight:500;white-space:nowrap} .feat-strip .by{font-size:12px;color:var(--muted);font-weight:500;white-space:nowrap}
.feat-strip .by{font-size:12px;color:var(--muted);font-weight:500;white-space:nowrap} .feat-strip .by{font-size:12px;color:var(--muted);font-weight:500;white-space:nowrap}
/* ── achievement badges ── */ /* ── achievement badges ── */
@@ -333,22 +333,22 @@ textarea{resize:vertical;font:inherit}
.badge-a .badge-img{width:150px;height:150px;border-radius:14px;object-fit:cover;border:1px solid var(--line-strong)} .badge-a .badge-img{width:150px;height:150px;border-radius:14px;object-fit:cover;border:1px solid var(--line-strong)}
.badge-a.locked .badge-img{filter:grayscale(.85) brightness(.5);opacity:.7} .badge-a.locked .badge-img{filter:grayscale(.85) brightness(.5);opacity:.7}
.badge-a .medal{width:76px;height:76px;border-radius:50%;display:grid;place-items:center;position:relative; .badge-a .medal{width:76px;height:76px;border-radius:50%;display:grid;place-items:center;position:relative;
background:radial-gradient(circle at 50% 35%,rgba(59,157,255,.28),rgba(9,26,19,.9)); background:radial-gradient(circle at 50% 35%,var(--mint-soft-2),var(--panel-solid));
border:2px solid var(--mint);box-shadow:0 0 18px rgba(59,157,255,.3)} border:2px solid var(--mint);box-shadow:0 0 18px rgba(59,157,255,.3)}
.badge-a.locked .medal{background:rgba(139,166,156,.08);border-color:var(--line-strong);box-shadow:none;filter:grayscale(1);opacity:.5} .badge-a.locked .medal{background:var(--muted-soft);border-color:var(--line-strong);box-shadow:none;filter:grayscale(1);opacity:.5}
.badge-a .medal svg{width:38px;height:38px;stroke:var(--mint);fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round} .badge-a .medal svg{width:38px;height:38px;stroke:var(--mint);fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.badge-a.locked .medal svg{stroke:var(--muted)} .badge-a.locked .medal svg{stroke:var(--muted)}
.badge-a .bl{font-size:12px;font-weight:700;line-height:1.2} .badge-a .bl{font-size:12px;font-weight:700;line-height:1.2}
.badge-a .bs{font-size:10.5px;color:var(--muted)} .badge-a .bs{font-size:10.5px;color:var(--muted)}
.badge-a .share{font-size:11px;color:var(--mint);cursor:pointer;background:none;border:0;padding:0;text-decoration:underline} .badge-a .share{font-size:11px;color:var(--mint);cursor:pointer;background:none;border:0;padding:0;text-decoration:underline}
/* ── "Your next move": milestone stepper card ── */ /* ── "Your next move": milestone stepper card ── */
.next-card{position:relative;overflow:hidden;border-color:rgba(59,157,255,.28)} .next-card{position:relative;overflow:hidden;border-color:var(--mint-line)}
.next-card::before{content:"";position:absolute;inset:0;pointer-events:none;background: .next-card::before{content:"";position:absolute;inset:0;pointer-events:none;background:
radial-gradient(420px 150px at 10% 0%,rgba(59,157,255,.12),transparent 70%), radial-gradient(420px 150px at 10% 0%,var(--mint-soft),transparent 70%),
radial-gradient(360px 130px at 90% 100%,rgba(157,125,255,.09),transparent 70%)} radial-gradient(360px 130px at 90% 100%,var(--violet-soft),transparent 70%)}
.nc-head{display:flex;gap:14px;align-items:flex-start;position:relative} .nc-head{display:flex;gap:14px;align-items:flex-start;position:relative}
.nc-head .pl{flex:0 0 auto;width:44px;height:44px;border-radius:12px;display:grid;place-items:center; .nc-head .pl{flex:0 0 auto;width:44px;height:44px;border-radius:12px;display:grid;place-items:center;
background:rgba(59,157,255,.12);border:1px solid rgba(59,157,255,.35)} background:var(--mint-soft);border:1px solid var(--mint-line)}
.nc-head .pl svg{width:20px;height:20px;stroke:var(--mint);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round} .nc-head .pl svg{width:20px;height:20px;stroke:var(--mint);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.nc-steps{display:flex;margin-top:20px;position:relative;flex-wrap:wrap;row-gap:14px} .nc-steps{display:flex;margin-top:20px;position:relative;flex-wrap:wrap;row-gap:14px}
.nc-step{flex:1;min-width:88px;display:flex;flex-direction:column;align-items:center;gap:7px; .nc-step{flex:1;min-width:88px;display:flex;flex-direction:column;align-items:center;gap:7px;
@@ -369,31 +369,31 @@ textarea{resize:vertical;font:inherit}
.statx{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line); .statx{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);
border-radius:var(--radius);padding:18px;position:relative;overflow:hidden} border-radius:var(--radius);padding:18px;position:relative;overflow:hidden}
.statx .pl{flex:0 0 auto;width:46px;height:46px;border-radius:13px;display:grid;place-items:center; .statx .pl{flex:0 0 auto;width:46px;height:46px;border-radius:13px;display:grid;place-items:center;
background:rgba(59,157,255,.1);border:1px solid rgba(59,157,255,.3)} background:var(--mint-soft);border:1px solid var(--mint-line)}
.statx .pl svg{width:22px;height:22px;stroke:var(--mint);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round} .statx .pl svg{width:22px;height:22px;stroke:var(--mint);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.statx.c-cyan .pl{background:rgba(84,204,255,.1);border-color:rgba(84,204,255,.3)} .statx.c-cyan .pl{background:var(--cyan-soft);border-color:var(--cyan-line)}
.statx.c-cyan .pl svg{stroke:var(--cyan)} .statx.c-cyan .pl svg{stroke:var(--cyan)}
.statx.c-violet .pl{background:rgba(157,125,255,.12);border-color:rgba(157,125,255,.32)} .statx.c-violet .pl{background:var(--violet-soft);border-color:var(--violet-line)}
.statx.c-violet .pl svg{stroke:var(--violet)} .statx.c-violet .pl svg{stroke:var(--violet)}
.statx.c-amber .pl{background:rgba(255,178,56,.1);border-color:rgba(255,178,56,.3)} .statx.c-amber .pl{background:var(--amber-soft);border-color:var(--amber-line)}
.statx.c-amber .pl svg{stroke:var(--amber)} .statx.c-amber .pl svg{stroke:var(--amber)}
.statx .nv{font-family:var(--disp);font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1} .statx .nv{font-family:var(--disp);font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1}
.statx .lb{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;margin-top:2px} .statx .lb{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;margin-top:2px}
.chip{display:inline-block;margin-top:7px;font-size:11.5px;font-weight:700;border-radius:999px;padding:2px 10px; .chip{display:inline-block;margin-top:7px;font-size:11.5px;font-weight:700;border-radius:999px;padding:2px 10px;
background:rgba(59,157,255,.1);color:var(--mint)} background:var(--mint-soft);color:var(--mint)}
.chip.flat{background:rgba(139,166,156,.12);color:var(--muted)} .chip.flat{background:var(--muted-soft);color:var(--muted)}
.chip.warm{background:rgba(255,178,56,.12);color:var(--amber)} .chip.warm{background:var(--amber-soft);color:var(--amber)}
.card-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px} .card-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
.card-head .sub{font-size:12px;color:var(--muted)} .card-head .sub{font-size:12px;color:var(--muted)}
/* bar chart (divs, real data) */ /* bar chart (divs, real data) */
.barchart{display:flex;align-items:flex-end;gap:6px;height:120px;margin-top:14px} .barchart{display:flex;align-items:flex-end;gap:6px;height:120px;margin-top:14px}
.barchart .bar{flex:1;min-width:6px;background:linear-gradient(180deg,var(--mint),rgba(59,157,255,.25)); .barchart .bar{flex:1;min-width:6px;background:linear-gradient(180deg,var(--mint),var(--mint-soft-2));
border-radius:5px 5px 2px 2px;position:relative;transition:height .5s ease} border-radius:5px 5px 2px 2px;position:relative;transition:height .5s ease}
.barchart .bar.alt{background:linear-gradient(180deg,var(--violet),rgba(157,125,255,.25))} .barchart .bar.alt{background:linear-gradient(180deg,var(--violet),var(--violet-soft))}
.barchart .bar:hover::after{content:attr(data-v);position:absolute;bottom:calc(100% + 4px);left:50%; .barchart .bar:hover::after{content:attr(data-v);position:absolute;bottom:calc(100% + 4px);left:50%;
transform:translateX(-50%);background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:7px; transform:translateX(-50%);background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:7px;
padding:2px 8px;font-family:var(--mono);font-size:11px;white-space:nowrap;z-index:3} padding:2px 8px;font-family:var(--mono);font-size:11px;white-space:nowrap;z-index:3}
.barchart .bar.empty{background:rgba(139,166,156,.15);height:4px!important} .barchart .bar.empty{background:var(--muted-soft);height:4px!important}
.chart-x{display:flex;gap:6px;margin-top:6px} .chart-x{display:flex;gap:6px;margin-top:6px}
.chart-x span{flex:1;text-align:center;font-family:var(--mono);font-size:10px;color:var(--muted);overflow:hidden;white-space:nowrap} .chart-x span{flex:1;text-align:center;font-family:var(--mono);font-size:10px;color:var(--muted);overflow:hidden;white-space:nowrap}
/* donut + ring (SVG) */ /* donut + ring (SVG) */
@@ -434,7 +434,7 @@ textarea{resize:vertical;font:inherit}
.bio-socials a svg{flex:0 0 auto} .bio-socials a svg{flex:0 0 auto}
.bio-socials a:hover{border-color:var(--mint)} .bio-socials a:hover{border-color:var(--mint)}
.bio-qr{flex:0 0 auto;background:var(--panel);border:1px solid var(--line-strong);border-radius:14px;padding:10px} .bio-qr{flex:0 0 auto;background:var(--panel);border:1px solid var(--line-strong);border-radius:14px;padding:10px}
.bio-qr img{display:block;border-radius:8px;background:#eef7f3} .bio-qr img{display:block;border-radius:8px;background:#fff} /* a QR code stays on white in both themes so it scans */
/* ── wall page ── */ /* ── wall page ── */
.wall-card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:16px;text-align:center} .wall-card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:16px;text-align:center}
.wall-card img{max-width:100%;border-radius:10px;border:1px solid var(--line-strong)} .wall-card img{max-width:100%;border-radius:10px;border:1px solid var(--line-strong)}
@@ -461,9 +461,9 @@ textarea{resize:vertical;font:inherit}
.lin-row .dt{font-size:12px;color:var(--muted);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap} .lin-row .dt{font-size:12px;color:var(--muted);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.lin-row .chat-msg-btn{justify-self:end} .lin-row .chat-msg-btn{justify-self:end}
.lin-row .lin-act-btn{justify-self:end;white-space:nowrap} .lin-row .lin-act-btn{justify-self:end;white-space:nowrap}
.lin-act{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:8px 10px 10px;margin:-1px 0 6px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.025);border-radius:0 0 10px 10px} .lin-act{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:8px 10px 10px;margin:-1px 0 6px;border-bottom:1px solid var(--line);background:var(--ink-faint);border-radius:0 0 10px 10px}
.lin-chip{font-size:12px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:3px 10px;white-space:nowrap} .lin-chip b{font-weight:600;color:var(--ink);margin-right:5px} .lin-chip.on{border-color:rgba(59,157,255,.45);color:var(--ink)} .lin-chip.warn{border-color:rgba(255,209,92,.5)} .lin-chip{font-size:12px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:3px 10px;white-space:nowrap} .lin-chip b{font-weight:600;color:var(--ink);margin-right:5px} .lin-chip.on{border-color:var(--mint-line);color:var(--ink)} .lin-chip.warn{border-color:var(--gold-line)}
.lin-verdict{margin-left:auto;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:#ffd15c} .lin-verdict.on{color:var(--mint)} .lin-verdict{margin-left:auto;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--gold)} .lin-verdict.on{color:var(--mint)}
@media (max-width:560px){.lin-chip{white-space:normal}.lin-act{padding:8px 4px 10px}} @media (max-width:560px){.lin-chip{white-space:normal}.lin-act{padding:8px 4px 10px}}
@media (max-width:560px){.lin-row{grid-template-columns:1fr auto;gap:2px 10px} @media (max-width:560px){.lin-row{grid-template-columns:1fr auto;gap:2px 10px}
.lin-row .em{grid-column:1/2}.lin-row .dt{grid-column:1/2;text-align:left}.lin-row .chat-msg-btn{grid-row:1/3;grid-column:2} .lin-row .em{grid-column:1/2}.lin-row .dt{grid-column:1/2;text-align:left}.lin-row .chat-msg-btn{grid-row:1/3;grid-column:2}
@@ -473,7 +473,7 @@ textarea{resize:vertical;font:inherit}
.ed-bar button{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px; .ed-bar button{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;
padding:5px 11px;font-size:12.5px;cursor:pointer} padding:5px 11px;font-size:12.5px;cursor:pointer}
.ed-bar button:hover,.ed-bar button:focus-visible{border-color:var(--mint);outline:none} .ed-bar button:hover,.ed-bar button:focus-visible{border-color:var(--mint);outline:none}
.ed-body{background:rgba(4,8,7,.65);border:1px solid var(--line-strong);border-radius:11px; .ed-body{background:var(--field-bg);border:1px solid var(--line-strong);border-radius:11px;
min-height:180px;padding:12px 14px;outline:none;overflow-wrap:anywhere} min-height:180px;padding:12px 14px;outline:none;overflow-wrap:anywhere}
.ed-body:focus{border-color:var(--mint)} .ed-body:focus{border-color:var(--mint)}
.ed-body:empty::before{content:attr(data-ph);color:var(--muted)} .ed-body:empty::before{content:attr(data-ph);color:var(--muted)}
@@ -493,11 +493,11 @@ textarea.ed-body{width:100%;min-height:180px;resize:vertical}
.subtab.on{color:var(--mint);border-bottom-color:var(--mint)} .subtab.on{color:var(--mint);border-bottom-color:var(--mint)}
.subtab .pill{position:static} .subtab .pill{position:static}
/* ── solo-ads inbox ── */ /* ── solo-ads inbox ── */
.bo-menu .pill{margin-left:auto;background:var(--amber);color:#1a1206;font-size:11px;font-weight:800; .bo-menu .pill{margin-left:auto;background:var(--amber);color:var(--amber-ink);font-size:11px;font-weight:800;
border-radius:999px;padding:1px 8px;line-height:1.5} border-radius:999px;padding:1px 8px;line-height:1.5}
.ib-row{display:flex;gap:10px;align-items:baseline;padding:11px 6px;border-bottom:1px solid var(--line); .ib-row{display:flex;gap:10px;align-items:baseline;padding:11px 6px;border-bottom:1px solid var(--line);
cursor:pointer;flex-wrap:wrap} cursor:pointer;flex-wrap:wrap}
.ib-row:hover{background:rgba(59,157,255,.05)} .ib-row:hover{background:var(--mint-faint)}
.ib-row .sub{font-weight:700;flex:1;min-width:160px;overflow-wrap:anywhere} .ib-row .sub{font-weight:700;flex:1;min-width:160px;overflow-wrap:anywhere}
.ib-row.unread .sub{color:var(--mint)} .ib-row.unread .sub{color:var(--mint)}
.ib-row .from,.ib-row .when{font-size:12px;color:var(--muted);white-space:nowrap} .ib-row .from,.ib-row .when{font-size:12px;color:var(--muted);white-space:nowrap}
@@ -518,9 +518,9 @@ textarea.ed-body{width:100%;min-height:180px;resize:vertical}
#pane-earn .card h3::before,#pane-earnings .card h3::before{background:var(--violet)} #pane-earn .card h3::before,#pane-earnings .card h3::before{background:var(--violet)}
#pane-promo .card h3::before{background:var(--cyan)} #pane-promo .card h3::before{background:var(--cyan)}
#pane-wallet .card h3::before,#pane-profile .card h3::before{background:var(--mint)} #pane-wallet .card h3::before,#pane-profile .card h3::before{background:var(--mint)}
.bo .card{background:linear-gradient(165deg,rgba(24,36,31,.6),rgba(13,19,17,.66))} .bo .card{background:var(--panel-grad)}
#pane-line .qualbar,#nextCard{border-left:3px solid rgba(59,157,255,.4)} #pane-line .qualbar,#nextCard{border-left:3px solid var(--mint-line)}
.promo-block{background:rgba(4,8,7,.55);border:1px solid var(--line);border-radius:12px; .promo-block{background:var(--ground-soft);border:1px solid var(--line);border-radius:12px;
padding:14px 16px;margin:0 0 12px;font-size:13.5px;line-height:1.6;white-space:pre-wrap} padding:14px 16px;margin:0 0 12px;font-size:13.5px;line-height:1.6;white-space:pre-wrap}
.promo-block .btn{margin-top:10px} .promo-block .btn{margin-top:10px}
/* back-office polish: pane transitions, quick actions */ /* back-office polish: pane transitions, quick actions */
@@ -529,19 +529,19 @@ textarea.ed-body{width:100%;min-height:180px;resize:vertical}
@keyframes panein{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}} @keyframes panein{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
} }
.qa{display:flex;flex-direction:column;gap:8px} .qa{display:flex;flex-direction:column;gap:8px}
.qa button{display:flex;align-items:center;gap:10px;background:rgba(59,157,255,.05);border:1px solid var(--line); .qa button{display:flex;align-items:center;gap:10px;background:var(--mint-faint);border:1px solid var(--line);
color:var(--ink);font:600 14px var(--disp);padding:11px 14px;border-radius:11px;cursor:pointer;text-align:left; color:var(--ink);font:600 14px var(--disp);padding:11px 14px;border-radius:11px;cursor:pointer;text-align:left;
transition:border-color .15s ease,background .15s ease} transition:border-color .15s ease,background .15s ease}
.qa button:hover{border-color:var(--mint);background:rgba(59,157,255,.1)} .qa button:hover{border-color:var(--mint);background:var(--mint-soft)}
/* member sub-navigation */ /* member sub-navigation */
.subnav{display:flex;gap:6px;flex-wrap:wrap;background:rgba(16,28,24,.7);border:1px solid var(--line); .subnav{display:flex;gap:6px;flex-wrap:wrap;background:var(--pill-bg);border:1px solid var(--line);
border-radius:999px;padding:6px 8px;width:fit-content;margin:0 0 22px} border-radius:999px;padding:6px 8px;width:fit-content;margin:0 0 22px}
.subnav button{background:transparent;border:0;color:var(--muted);font:600 13.5px var(--disp); .subnav button{background:transparent;border:0;color:var(--muted);font:600 13.5px var(--disp);
padding:8px 16px;border-radius:999px;cursor:pointer} padding:8px 16px;border-radius:999px;cursor:pointer}
.subnav button:hover{color:var(--ink)} .subnav button:hover{color:var(--ink)}
.subnav button.on{color:var(--mint-ink);background:var(--mint)} .subnav button.on{color:var(--mint-ink);background:var(--mint)}
/* member dashboard: qualification progress + roster */ /* member dashboard: qualification progress + roster */
.qualbar{position:relative;height:12px;border-radius:999px;background:rgba(4,8,7,.7);border:1px solid var(--line-strong); .qualbar{position:relative;height:12px;border-radius:999px;background:var(--ground-soft);border:1px solid var(--line-strong);
margin:26px 0 30px;max-width:520px} margin:26px 0 30px;max-width:520px}
.qualbar #qualFill{height:100%;border-radius:999px;background:linear-gradient(90deg,var(--mint),var(--mint-hi)); .qualbar #qualFill{height:100%;border-radius:999px;background:linear-gradient(90deg,var(--mint),var(--mint-hi));
box-shadow:0 0 18px rgba(59,157,255,.4);width:0;transition:width .6s ease} box-shadow:0 0 18px rgba(59,157,255,.4);width:0;transition:width .6s ease}
@@ -567,8 +567,8 @@ img{max-width:100%}
font-size:22px;cursor:pointer;line-height:1} font-size:22px;cursor:pointer;line-height:1}
.ch-msgs{padding:14px;overflow-y:auto;max-height:340px;display:flex;flex-direction:column;gap:10px} .ch-msgs{padding:14px;overflow-y:auto;max-height:340px;display:flex;flex-direction:column;gap:10px}
.ch-m{border-radius:12px;padding:9px 13px;font-size:13.5px;line-height:1.5;max-width:86%} .ch-m{border-radius:12px;padding:9px 13px;font-size:13.5px;line-height:1.5;max-width:86%}
.ch-m.bot{background:rgba(59,157,255,.08);border:1px solid rgba(59,157,255,.2);align-self:flex-start} .ch-m.bot{background:var(--mint-faint);border:1px solid var(--mint-line);align-self:flex-start}
.ch-m.me{background:rgba(130,148,196,.12);border:1px solid var(--line);align-self:flex-end} .ch-m.me{background:var(--muted-soft);border:1px solid var(--line);align-self:flex-end}
.ch-m a{word-break:break-all} .ch-m a{word-break:break-all}
.ch-input{display:flex;gap:8px;padding:11px;border-top:1px solid var(--line)} .ch-input{display:flex;gap:8px;padding:11px;border-top:1px solid var(--line)}
.ch-input input{flex:1;min-width:0} .ch-input input{flex:1;min-width:0}
@@ -576,7 +576,7 @@ img{max-width:100%}
font-weight:700;cursor:pointer;font-family:var(--disp)} font-weight:700;cursor:pointer;font-family:var(--disp)}
@media(prefers-reduced-motion:no-preference){ @media(prefers-reduced-motion:no-preference){
.feed .row:first-child{animation:landed .9s ease} .feed .row:first-child{animation:landed .9s ease}
@keyframes landed{from{background:rgba(59,157,255,.3)}to{background:var(--mint-soft)}} @keyframes landed{from{background:var(--mint-soft-2)}to{background:var(--mint-soft)}}
} }
/* ── Sponsor chat: FAB, slide-in drawer, threads, bubbles, presence ── */ /* ── Sponsor chat: FAB, slide-in drawer, threads, bubbles, presence ── */
@@ -630,12 +630,12 @@ img{max-width:100%}
.lt-nodes{display:flex;gap:8px;flex-wrap:wrap} .lt-nodes{display:flex;gap:8px;flex-wrap:wrap}
.lt-node{background:var(--panel);border:1px solid var(--line-strong);border-radius:10px;padding:6px 12px;font-size:13px;font-weight:600;white-space:nowrap} .lt-node{background:var(--panel);border:1px solid var(--line-strong);border-radius:10px;padding:6px 12px;font-size:13px;font-weight:600;white-space:nowrap}
.lt-node.deep{color:var(--muted)} .lt-node.deep{color:var(--muted)}
.lt-node.qualified{border-color:#ffb238;color:#ffd15c;box-shadow:0 0 0 1px rgba(255,177,56,.35)} .lt-node.qualified{border-color:var(--amber);color:var(--gold);box-shadow:0 0 0 1px var(--amber-line)}
.lt-node.open{border-style:dashed;color:var(--muted);background:transparent} .lt-node.open{border-style:dashed;color:var(--muted);background:transparent}
.lt-node .lt-n{display:inline-block;font-style:normal;font-size:10px;line-height:16px;min-width:16px;text-align:center;border-radius:8px;background:rgba(255,177,56,.18);color:#ffd15c;margin-left:6px;padding:0 4px;font-variant-numeric:tabular-nums} .lt-node .lt-n{display:inline-block;font-style:normal;font-size:10px;line-height:16px;min-width:16px;text-align:center;border-radius:8px;background:var(--amber-soft);color:var(--gold);margin-left:6px;padding:0 4px;font-variant-numeric:tabular-nums}
.sh-report{display:block;text-align:center;margin-top:10px;color:rgba(255,255,255,.45);font-size:12px} .sh-report{display:block;text-align:center;margin-top:10px;color:var(--muted);font-size:12px}
.sh-report:hover{color:rgba(255,255,255,.8)} .sh-report:hover{color:var(--ink)}
/* ── promo tools (2026-09-09) ── */ /* ── promo tools (2026-09-09) ── */
.promo-strip{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;padding:16px 20px} .promo-strip{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;padding:16px 20px}
@@ -666,7 +666,7 @@ img{max-width:100%}
.promo-bv{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:16px;padding:14px 16px;border:1px dashed var(--line-strong);border-radius:12px} .promo-bv{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:16px;padding:14px 16px;border:1px dashed var(--line-strong);border-radius:12px}
.promo-bv b{font-family:var(--disp)} .promo-bv b{font-family:var(--disp)}
.obj-wrap{display:flex;flex-direction:column;gap:8px} .obj-wrap{display:flex;flex-direction:column;gap:8px}
.obj{border:1px solid var(--line);border-radius:12px;background:rgba(4,8,7,.4)} .obj{border:1px solid var(--line);border-radius:12px;background:var(--ground-soft)}
.obj summary{cursor:pointer;padding:12px 16px;font-family:var(--disp);font-weight:700;font-size:15px;list-style:none;display:flex;justify-content:space-between;gap:10px} .obj summary{cursor:pointer;padding:12px 16px;font-family:var(--disp);font-weight:700;font-size:15px;list-style:none;display:flex;justify-content:space-between;gap:10px}
.obj summary::after{content:"+";color:var(--mint);font-weight:800} .obj summary::after{content:"+";color:var(--mint);font-weight:800}
.obj[open] summary::after{content:"–"} .obj[open] summary::after{content:"–"}
@@ -688,12 +688,12 @@ img{max-width:100%}
.wo-slot img{max-width:100%;border-radius:8px} .wo-slot img{max-width:100%;border-radius:8px}
/* getting-started stepper on the Overview (Jim could not find the wallet step, 2026-09-14) */ /* getting-started stepper on the Overview (Jim could not find the wallet step, 2026-09-14) */
.gs{border-color:rgba(59,157,255,.45)} .gs{border-color:var(--mint-line)}
.gs-steps{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:4px 0 12px} .gs-steps{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:4px 0 12px}
.gs-step{display:flex;gap:10px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:10px 12px;color:var(--muted);font-size:14px} .gs-step{display:flex;gap:10px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:10px 12px;color:var(--muted);font-size:14px}
.gs-step .n{flex:0 0 26px;width:26px;height:26px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:700;border:1px solid var(--line);font-size:13px} .gs-step .n{flex:0 0 26px;width:26px;height:26px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:700;border:1px solid var(--line);font-size:13px}
.gs-step.done{color:var(--ink)} .gs-step.done .n{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)} .gs-step.done{color:var(--ink)} .gs-step.done .n{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)}
.gs-step.now{color:var(--ink);border-color:var(--mint);background:rgba(59,157,255,.07)} .gs-step.now .n{border-color:var(--mint);color:var(--mint)} .gs-step.now{color:var(--ink);border-color:var(--mint);background:var(--mint-faint)} .gs-step.now .n{border-color:var(--mint);color:var(--mint)}
.gs-now{display:flex;gap:14px;align-items:center;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:12px} .gs-now{display:flex;gap:14px;align-items:center;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:12px}
.gs-now p{margin:0;flex:1;min-width:240px;max-width:60ch} .gs-now p b{display:block;font-family:var(--disp);font-size:16px;margin-bottom:2px} .gs-now p{margin:0;flex:1;min-width:240px;max-width:60ch} .gs-now p b{display:block;font-family:var(--disp);font-size:16px;margin-bottom:2px}
@keyframes gsPulse{0%{box-shadow:0 0 0 0 rgba(59,157,255,.7)}70%{box-shadow:0 0 0 14px rgba(59,157,255,0)}100%{box-shadow:0 0 0 0 rgba(59,157,255,0)}} @keyframes gsPulse{0%{box-shadow:0 0 0 0 rgba(59,157,255,.7)}70%{box-shadow:0 0 0 14px rgba(59,157,255,0)}100%{box-shadow:0 0 0 0 rgba(59,157,255,0)}}
@@ -702,16 +702,16 @@ img{max-width:100%}
/* promo toolkit tiers */ /* promo toolkit tiers */
.tk-tiers{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:10px} .tk-tiers{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:10px}
.tk-tier{border:1px solid var(--line);border-radius:12px;padding:12px 14px;font-size:13.5px;color:var(--muted)} .tk-tier{border:1px solid var(--line);border-radius:12px;padding:12px 14px;font-size:13.5px;color:var(--muted)}
.tk-tier.reached{border-color:rgba(59,157,255,.5);color:var(--ink)} .tk-tier.current{background:rgba(59,157,255,.07)} .tk-tier.reached{border-color:var(--mint-line-2);color:var(--ink)} .tk-tier.current{background:var(--mint-faint)}
.tk-tier b{display:block;font-family:var(--disp);font-size:15px;color:var(--ink)} .tk-tier .need{font-size:12px;margin:2px 0 8px;color:var(--muted)} .tk-tier b{display:block;font-family:var(--disp);font-size:15px;color:var(--ink)} .tk-tier .need{font-size:12px;margin:2px 0 8px;color:var(--muted)}
.tk-tier ul{margin:0;padding-left:16px} .tk-tier li{margin:3px 0} .tk-tier li.soon{opacity:.65} .tk-tier li.soon::after{content:' (coming)';font-size:11px;color:var(--muted)} .tk-tier ul{margin:0;padding-left:16px} .tk-tier li{margin:3px 0} .tk-tier li.soon{opacity:.65} .tk-tier li.soon::after{content:' (coming)';font-size:11px;color:var(--muted)}
.tk-tier .lock{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:#ffd15c} .tk-tier .lock{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--gold)}
.tk-hist{border-top:1px solid var(--line);padding:8px 0;font-size:13px} .tk-hist .muted{font-size:12px} .tk-hist{border-top:1px solid var(--line);padding:8px 0;font-size:13px} .tk-hist .muted{font-size:12px}
.tk-sec{margin-top:18px;padding-top:14px;border-top:1px solid var(--line)} .tk-grid{display:flex;gap:8px;flex-wrap:wrap} .tk-sec{margin-top:18px;padding-top:14px;border-top:1px solid var(--line)} .tk-grid{display:flex;gap:8px;flex-wrap:wrap}
.tk-vids{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px} .tk-vid{border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:13px} .tk-vid b{display:block;font-weight:600;margin-bottom:4px} .tk-vid .st{font-size:12px;color:var(--muted)} .tk-vids{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px} .tk-vid{border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:13px} .tk-vid b{display:block;font-weight:600;margin-bottom:4px} .tk-vid .st{font-size:12px;color:var(--muted)}
.tk-bar{height:8px;border-radius:99px;background:rgba(255,255,255,.08);overflow:hidden;margin:6px 0 4px} .tk-bar i{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,#1fb894,#3b9dff);transition:width .6s ease;min-width:4px} .tk-bar{height:8px;border-radius:99px;background:var(--ink-faint);overflow:hidden;margin:6px 0 4px} .tk-bar i{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,var(--cyan),var(--mint));transition:width .6s ease;min-width:4px}
.tk-table{width:100%;border-collapse:collapse;font-size:13px} .tk-table th,.tk-table td{text-align:left;padding:6px 8px;border-bottom:1px solid var(--line)} .tk-table th{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)} .tk-table td.n{font-variant-numeric:tabular-nums;text-align:right} .tk-table th.n{text-align:right} .tk-table tr.best td{color:var(--mint)} .tk-table{width:100%;border-collapse:collapse;font-size:13px} .tk-table th,.tk-table td{text-align:left;padding:6px 8px;border-bottom:1px solid var(--line)} .tk-table th{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)} .tk-table td.n{font-variant-numeric:tabular-nums;text-align:right} .tk-table th.n{text-align:right} .tk-table tr.best td{color:var(--mint)}
.tk-team{border:1px solid var(--line);border-radius:10px;padding:8px 12px;margin:6px 0;font-size:13px;display:flex;gap:10px;flex-wrap:wrap;align-items:center;justify-content:space-between} .tk-team .who b{font-weight:600} .tk-team .who span{color:var(--muted);font-size:12px} .tk-team.stalled{border-color:rgba(255,209,92,.45)} .tk-team{border:1px solid var(--line);border-radius:10px;padding:8px 12px;margin:6px 0;font-size:13px;display:flex;gap:10px;flex-wrap:wrap;align-items:center;justify-content:space-between} .tk-team .who b{font-weight:600} .tk-team .who span{color:var(--muted);font-size:12px} .tk-team.stalled{border-color:var(--gold-line)}
.tk-nudge{width:100%;margin:8px 0 0;padding:8px 12px;border:1px dashed var(--line);border-radius:10px;font-size:13px} .tk-nudge{width:100%;margin:8px 0 0;padding:8px 12px;border:1px dashed var(--line);border-radius:10px;font-size:13px}
/* click sources stack one per line so the Clicks column stays narrow (Marty, 2026-09-15) */ /* click sources stack one per line so the Clicks column stays narrow (Marty, 2026-09-15) */
.clk-src span{display:block;white-space:nowrap} .camp-table td{white-space:normal} .camp-table td:first-child{max-width:260px} .clk-src span{display:block;white-space:nowrap} .camp-table td{white-space:normal} .camp-table td:first-child{max-width:260px}
@@ -733,13 +733,13 @@ img{max-width:100%}
/* Pipeline board (Marty, 2026-09-15): columns scroll sideways inside their own box, never the page */ /* Pipeline board (Marty, 2026-09-15): columns scroll sideways inside their own box, never the page */
.pipe-board{display:flex;gap:10px;overflow-x:auto;padding:4px 2px 10px;scroll-snap-type:x proximity} .pipe-board{display:flex;gap:10px;overflow-x:auto;padding:4px 2px 10px;scroll-snap-type:x proximity}
.pipe-col{flex:0 0 220px;scroll-snap-align:start;background:rgba(4,8,7,.45);border:1px solid var(--line);border-radius:12px;padding:10px;min-height:120px} .pipe-col{flex:0 0 220px;scroll-snap-align:start;background:var(--ground-soft);border:1px solid var(--line);border-radius:12px;padding:10px;min-height:120px}
.pipe-col h4{margin:0 0 2px;font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);display:flex;justify-content:space-between;gap:8px} .pipe-col h4{margin:0 0 2px;font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);display:flex;justify-content:space-between;gap:8px}
.pipe-col h4 span{color:var(--muted);font-variant-numeric:tabular-nums} .pipe-col h4 span{color:var(--muted);font-variant-numeric:tabular-nums}
.pipe-col .hint{font-size:11.5px;color:var(--muted);margin:0 0 8px;line-height:1.35} .pipe-col .hint{font-size:11.5px;color:var(--muted);margin:0 0 8px;line-height:1.35}
.pipe-card{background:rgba(255,255,255,.04);border:1px solid var(--line);border-radius:10px;padding:8px 10px;margin:0 0 8px;cursor:pointer;transition:border-color .15s} .pipe-card{background:var(--ink-faint);border:1px solid var(--line);border-radius:10px;padding:8px 10px;margin:0 0 8px;cursor:pointer;transition:border-color .15s}
.pipe-card:hover,.pipe-card:focus-visible{border-color:var(--mint);outline:none} .pipe-card:hover,.pipe-card:focus-visible{border-color:var(--mint);outline:none}
.pipe-card.on{border-color:var(--gold,#e6c15a)} .pipe-card.on{border-color:var(--gold)}
.pipe-card .nm{font-weight:700;font-size:14px;display:flex;justify-content:space-between;gap:6px;align-items:baseline} .pipe-card .nm{font-weight:700;font-size:14px;display:flex;justify-content:space-between;gap:6px;align-items:baseline}
.pipe-card .nm small{font-weight:400;font-size:11px;color:var(--muted);white-space:nowrap} .pipe-card .nm small{font-weight:400;font-size:11px;color:var(--muted);white-space:nowrap}
.pipe-card .sub{font-size:12px;color:var(--muted);margin-top:3px;line-height:1.35} .pipe-card .sub{font-size:12px;color:var(--muted);margin-top:3px;line-height:1.35}
@@ -748,6 +748,18 @@ img{max-width:100%}
.pipe-due{display:grid;gap:6px} .pipe-due{display:grid;gap:6px}
.pipe-due .pipe-card{margin:0} .pipe-due .pipe-card{margin:0}
@media (max-width:640px){.pipe-form{grid-template-columns:1fr !important}.pipe-col{flex-basis:200px}} @media (max-width:640px){.pipe-form{grid-template-columns:1fr !important}.pipe-col{flex-basis:200px}}
/* the pipeline board fits on one screen (2026-11-20, a member: "need a bottom slide rule so we can see the entire window to the right
without having to reduce the size"): a long column scrolls inside itself with its heading pinned, so the board's own sideways
scrollbar stays in view; both scrollbars are wide and visible instead of the thin overlay ones */
.pipe-col{max-height:min(68vh,760px);overflow-y:auto;overflow-x:hidden}
.pipe-col h4{position:sticky;top:-10px;z-index:1;background:inherit;margin:-10px -10px 2px;padding:10px 10px 2px}
.pipe-board{scrollbar-width:auto;scrollbar-color:var(--mint) transparent}
.pipe-col{scrollbar-width:thin}
.pipe-board::-webkit-scrollbar{height:14px}
.pipe-board::-webkit-scrollbar-thumb{background:var(--mint);border-radius:8px;border:3px solid transparent;background-clip:padding-box}
.pipe-board::-webkit-scrollbar-track{background:var(--line);border-radius:8px}
.pipe-col::-webkit-scrollbar{width:8px}
.pipe-col::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px}
/* ── LinkSpin identity: sapphire + chrome, after the Nexus badge (Marty, 2026-09-16) ── /* ── LinkSpin identity: sapphire + chrome, after the Nexus badge (Marty, 2026-09-16) ──
Deep navy ground, electric-blue accent, brushed-silver headline highlights, circuit-line Deep navy ground, electric-blue accent, brushed-silver headline highlights, circuit-line
@@ -761,27 +773,76 @@ img{max-width:100%}
--cyan:#6fd3ff; --violet:#a48cff; --amber:#ffcf5a; --bad:#ff8f8f; --cyan:#6fd3ff; --violet:#a48cff; --amber:#ffcf5a; --bad:#ff8f8f;
--chrome:linear-gradient(180deg,#f4f9ff 0%,#bcd6f7 38%,#7fa9dc 52%,#dbe9fb 68%,#9cc0ec 100%); --chrome:linear-gradient(180deg,#f4f9ff 0%,#bcd6f7 38%,#7fa9dc 52%,#dbe9fb 68%,#9cc0ec 100%);
--disp:"Rajdhani","Segoe UI",system-ui,sans-serif; --disp:"Rajdhani","Segoe UI",system-ui,sans-serif;
/* 2026-11-01 theme tokens: every surface, text, border and soft fill that used to be a literal (tools.css maps
them onto Control Room tokens inside /tools and /admin). Light values live in :root[data-theme="light"] below. */
--mint-deep:#1f7be0; --mint-pale:#bcd6f7;
--mint-faint:rgba(59,157,255,.06); --mint-soft-2:rgba(59,157,255,.16); --mint-line:rgba(59,157,255,.38); --mint-line-2:rgba(59,157,255,.6);
--gold:#ffd15c; --gold-2:#f2c94c; --gold-soft:rgba(242,201,76,.14); --gold-faint:rgba(242,201,76,.04); --gold-line:rgba(242,201,76,.5);
--amber-soft:rgba(255,207,90,.12); --amber-line:rgba(255,207,90,.4); --amber-ink:#1a1206;
--cyan-soft:rgba(111,211,255,.1); --cyan-line:rgba(111,211,255,.3); --violet-soft:rgba(164,140,255,.12); --violet-line:rgba(164,140,255,.32);
--muted-soft:rgba(143,166,200,.12); --ink-faint:rgba(255,255,255,.04);
--ground-soft:rgba(2,10,36,.5); --field-bg:rgba(2,10,36,.65); --nav-bg:rgba(2,10,36,.78); --side-bg:rgba(4,16,48,.92); --pill-bg:rgba(10,26,60,.7);
--panel-grad:linear-gradient(165deg,rgba(14,34,74,.6),rgba(6,18,46,.66)); --panel-grad-deep:linear-gradient(170deg,#0a1c44,#040d2a);
--glow:#0a2a6b; --sh-lg:0 0 0 1px rgba(59,157,255,.06),0 18px 50px rgba(1,6,24,.55);
color-scheme:dark;
} }
body{background:radial-gradient(1200px 600px at 50% -10%,#0a2a6b 0%,rgba(10,42,107,0) 60%),var(--ground);font-family:"Manrope","Segoe UI",system-ui,sans-serif} body{background:radial-gradient(1200px 600px at 50% -10%,var(--glow) 0%,transparent 60%),var(--ground);font-family:"Manrope","Segoe UI",system-ui,sans-serif}
body::before{opacity:1;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%233b9dff' stroke-opacity='.10' stroke-width='1.2'%3E%3Cpath d='M0 60h120l30 30h90v60l40 40h140'/%3E%3Cpath d='M60 420V300l40-40h80V180l40-40h200'/%3E%3Cpath d='M420 340H300l-30-30h-90V220'/%3E%3Cpath d='M0 200h60l20 20v80'/%3E%3C/g%3E%3Cg fill='%233b9dff' fill-opacity='.22'%3E%3Ccircle cx='120' cy='60' r='2.4'/%3E%3Ccircle cx='240' cy='150' r='2.4'/%3E%3Ccircle cx='420' cy='190' r='2.4'/%3E%3Ccircle cx='60' cy='300' r='2.4'/%3E%3Ccircle cx='300' cy='340' r='2.4'/%3E%3Ccircle cx='180' cy='180' r='2.4'/%3E%3Ccircle cx='80' cy='300' r='2.4'/%3E%3C/g%3E%3C/svg%3E")} body::before{opacity:1;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%233b9dff' stroke-opacity='.10' stroke-width='1.2'%3E%3Cpath d='M0 60h120l30 30h90v60l40 40h140'/%3E%3Cpath d='M60 420V300l40-40h80V180l40-40h200'/%3E%3Cpath d='M420 340H300l-30-30h-90V220'/%3E%3Cpath d='M0 200h60l20 20v80'/%3E%3C/g%3E%3Cg fill='%233b9dff' fill-opacity='.22'%3E%3Ccircle cx='120' cy='60' r='2.4'/%3E%3Ccircle cx='240' cy='150' r='2.4'/%3E%3Ccircle cx='420' cy='190' r='2.4'/%3E%3Ccircle cx='60' cy='300' r='2.4'/%3E%3Ccircle cx='300' cy='340' r='2.4'/%3E%3Ccircle cx='180' cy='180' r='2.4'/%3E%3Ccircle cx='80' cy='300' r='2.4'/%3E%3C/g%3E%3C/svg%3E")}
h1,h2,h3{font-family:var(--disp);letter-spacing:.005em;font-weight:700} h1,h2,h3{font-family:var(--disp);letter-spacing:.005em;font-weight:700}
.hero h1{font-size:clamp(40px,6vw,70px);text-transform:uppercase;letter-spacing:.02em;line-height:1.02} .hero h1{font-size:clamp(40px,6vw,70px);text-transform:uppercase;letter-spacing:.02em;line-height:1.02}
.hero h1 em{background:var(--chrome);-webkit-background-clip:text;background-clip:text;color:transparent;text-shadow:none} .hero h1 em{background:var(--chrome);-webkit-background-clip:text;background-clip:text;color:transparent;text-shadow:none}
.btn{background:linear-gradient(180deg,#8cc8ff 0%,#3b9dff 55%,#1f7be0 100%);color:#03122e;border:1px solid rgba(220,236,255,.55);box-shadow:0 6px 28px rgba(59,157,255,.35),inset 0 1px 0 rgba(255,255,255,.55);text-transform:uppercase;letter-spacing:.06em;font-size:14px} .btn{background:linear-gradient(180deg,var(--mint-hi) 0%,var(--mint) 55%,var(--mint-deep) 100%);color:var(--mint-ink);border:1px solid var(--mint-line-2);box-shadow:0 6px 28px rgba(59,157,255,.35),inset 0 1px 0 rgba(255,255,255,.55);text-transform:uppercase;letter-spacing:.06em;font-size:14px}
.btn:hover{background:linear-gradient(180deg,#a6d6ff 0%,#4ea9ff 55%,#2a86ea 100%);box-shadow:0 10px 40px rgba(59,157,255,.5),inset 0 1px 0 rgba(255,255,255,.6)} .btn:hover{background:linear-gradient(180deg,var(--mint-hi) 0%,var(--mint) 40%,var(--mint-deep) 100%);filter:brightness(1.07);box-shadow:0 10px 40px rgba(59,157,255,.5),inset 0 1px 0 rgba(255,255,255,.6)}
.btn.sec{background:rgba(59,157,255,.06);color:#bcd6f7;border:1px solid rgba(140,200,255,.45);box-shadow:none;text-transform:none;letter-spacing:0} .btn.sec{background:var(--mint-faint);color:var(--mint-pale);border:1px solid var(--mint-line);box-shadow:none;text-transform:none;letter-spacing:0}
.btn.sec:hover{background:rgba(59,157,255,.14)} .btn.sec:hover{background:var(--mint-soft-2);filter:none}
.card,.promo-block,.stat{border-color:var(--line);box-shadow:0 0 0 1px rgba(59,157,255,.06),0 18px 50px rgba(1,6,24,.55)} .card,.promo-block,.stat{border-color:var(--line);box-shadow:var(--sh-lg)}
.card h3,.card-head h3{font-family:var(--disp);font-size:20px;letter-spacing:.02em;text-transform:uppercase} .card h3,.card-head h3{font-family:var(--disp);font-size:20px;letter-spacing:.02em;text-transform:uppercase}
.stat .n{background:var(--chrome);-webkit-background-clip:text;background-clip:text;color:transparent;font-family:var(--disp);font-size:34px} .stat .n{background:var(--chrome);-webkit-background-clip:text;background-clip:text;color:transparent;font-family:var(--disp);font-size:34px}
nav{background:rgba(2,10,36,.78);border-bottom:1px solid rgba(88,150,255,.2)} nav{background:var(--nav-bg);border-bottom:1px solid var(--line)}
nav .links a.active{color:#eaf2ff;background:rgba(59,157,255,.16);box-shadow:inset 0 0 0 1px rgba(140,200,255,.35)} nav .links a.active{color:var(--ink);background:var(--mint-soft-2);box-shadow:inset 0 0 0 1px var(--mint-line)}
.wordmark{font-family:var(--disp);font-weight:700;font-size:24px;letter-spacing:.06em;text-transform:uppercase;color:#eaf2ff;display:inline-flex;align-items:center;gap:8px;line-height:1} .wordmark{font-family:var(--disp);font-weight:700;font-size:24px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink);display:inline-flex;align-items:center;gap:8px;line-height:1}
.wordmark b{background:var(--chrome);-webkit-background-clip:text;background-clip:text;color:transparent;font-weight:700} .wordmark b{background:var(--chrome);-webkit-background-clip:text;background-clip:text;color:transparent;font-weight:700}
.wordmark svg{width:26px;height:26px;flex:none} .wordmark svg{width:26px;height:26px;flex:none}
.rehearsal{background:rgba(255,207,90,.08);border-bottom:1px solid rgba(255,207,90,.25);color:#cbb677} .rehearsal{background:var(--amber-soft);border-bottom:1px solid var(--amber-line);color:var(--amber)}
.rehearsal b{color:#ffcf5a} .rehearsal b{color:var(--amber)}
.bo-side,.bo-menu button.on{border-color:var(--line)} .bo-side,.bo-menu button.on{border-color:var(--line)}
.bo-menu button.on{background:rgba(59,157,255,.14);color:#eaf2ff} .bo-menu button.on{background:var(--mint-soft-2);color:var(--ink)}
.chip-t.on{background:linear-gradient(180deg,#8cc8ff,#3b9dff);color:#03122e;border-color:transparent} .chip-t.on{background:linear-gradient(180deg,var(--mint-hi),var(--mint));color:var(--mint-ink);border-color:transparent}
.pill{background:linear-gradient(180deg,#8cc8ff,#3b9dff);color:#03122e} .pill{background:linear-gradient(180deg,var(--mint-hi),var(--mint));color:var(--mint-ink)}
/* ── Light theme for the sapphire pages (2026-11-01): light ground, white panels, dark ink, the same blue family
darkened so it reads as text on white; the chrome headline gradient turns blue steel so it still shows. ── */
:root[data-theme="light"]{
--ground:#E9EEF5; --ground2:#F3F6FB; --panel:#FFFFFF; --panel-solid:#FFFFFF;
--line:#CDD7E5; --line-strong:#AEBED4; --ink:#0F1B2E; --muted:#596984;
--mint:#175FD8; --mint-hi:#0B4BB3; --mint-deep:#0A3F96; --mint-ink:#FFFFFF; --mint-pale:#0B4BB3;
--mint-faint:#EEF4FE; --mint-soft:#E1ECFC; --mint-soft-2:#CFE0FB; --mint-line:#A9C6F2; --mint-line-2:#5F93E6;
--cyan:#0A6F8C; --violet:#5B3FD6; --amber:#8F5400; --bad:#B91C1C;
--gold:#7A5200; --gold-2:#8A6400; --gold-soft:#FFF4D1; --gold-faint:#FFFBEB; --gold-line:#E6C25E;
--amber-soft:#FFF1D6; --amber-line:#E8C27A; --amber-ink:#FFFFFF;
--cyan-soft:#DDF1F8; --cyan-line:#9FD3E6; --violet-soft:#EEE9FF; --violet-line:#C4B5FF;
--muted-soft:rgba(94,110,136,.12); --ink-faint:rgba(15,27,46,.05);
--ground-soft:#F3F6FB; --field-bg:#FFFFFF; --nav-bg:rgba(243,246,251,.88); --side-bg:rgba(243,246,251,.97); --pill-bg:rgba(255,255,255,.85);
--panel-grad:linear-gradient(180deg,#FFFFFF,#F6F8FC); --panel-grad-deep:linear-gradient(180deg,#F3F6FB,#E3EAF4);
--glow:#E3EDFB; --sh-lg:0 0 0 1px rgba(15,27,46,.03),0 14px 34px -20px rgba(15,27,46,.35);
--chrome:linear-gradient(180deg,#0B4BB3 0%,#1F6FEB 40%,#5A97F0 52%,#1F6FEB 66%,#0B4BB3 100%);
color-scheme:light;
}
:root[data-theme="light"] body::before{opacity:.6}
:root[data-theme="light"] .ghost{background:linear-gradient(180deg,rgba(23,95,216,.22),transparent 78%);-webkit-background-clip:text;background-clip:text}
:root[data-theme="light"] .mockup,:root[data-theme="light"] .modal-card,:root[data-theme="light"] #status,:root[data-theme="light"] #iapChatPanel,:root[data-theme="light"] .chat-drawer{box-shadow:0 18px 50px -20px rgba(15,27,46,.35)}
/* ── holding-tank readiness (2026-11-18): stage chip, heat with its band, last action, how they got here. Theme tokens only. ── */
.rd-line{display:flex;flex-wrap:wrap;gap:4px 6px;align-items:center;margin-top:4px;font-weight:400;white-space:normal}
.rd-stage,.rd-heat{display:inline-block;font-size:11px;line-height:1.5;padding:0 7px;border-radius:999px;border:1px solid var(--line-strong);color:var(--muted);font-weight:600;font-variant-numeric:tabular-nums}
.rd-s-warming{color:var(--cyan);border-color:var(--cyan-line);background:var(--cyan-soft)}
.rd-s-engaged{color:var(--violet);border-color:var(--violet-line);background:var(--violet-soft)}
.rd-s-activated{color:var(--mint);border-color:var(--mint-line);background:var(--mint-soft)}
.rd-s-ready{color:var(--ok,#22c55e);border-color:var(--ok,#22c55e);background:var(--ok-soft,rgba(34,197,94,.15))}
.rd-hot{color:var(--bad);border-color:var(--bad);background:var(--bad-soft,rgba(255,143,125,.12))}
.rd-warm{color:var(--amber);border-color:var(--amber-line);background:var(--amber-soft)}
.rd-cooling{color:var(--cyan);border-color:var(--cyan-line);background:var(--cyan-soft)}
.rd-cold{color:var(--muted);border-color:var(--muted-line,var(--line-strong));background:var(--muted-soft)}
.rd-last{font-size:11.5px;color:var(--muted)}
.rd-entry{display:block;font-size:11.5px;color:var(--muted);font-weight:400;white-space:normal;margin-top:2px}
.lin-row .em .rd-line,.lin-row .em .rd-entry{white-space:normal}
.lin-row.rd-row .em{white-space:normal}
.rd-bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0 0 8px}
+12 -5
View File
@@ -5,11 +5,15 @@
(function () { (function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog; const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
let S = [], CAT = [], ROT = [], SEL = null, DET = null, FILTER = '', KEYS = [], EVENTS = ['join', 'lead', 'wallet', 'purchase', 'external'], LIMITS = {}, URL_ROT = null, PE = []; let S = [], CAT = [], ROT = [], SEL = null, DET = null, FILTER = '', KEYS = [], EVENTS = ['join', 'lead', 'wallet', 'purchase', 'external'], LIMITS = {}, URL_ROT = null, PE = [];
CR.mount({ active: 'sources', title: 'Traffic sources', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ New source</button>' }); CR.mount({ active: 'sources', title: 'Traffic sources', sub: 'loading', actions: '<a class="btn sm" href="/traffic-guide" title="Which traffic works for which kind of offer">Traffic guide</a> <button class="btn pri" type="button" id="newBtn">+ New source</button>' });
// traffic guide (2026-10-28): formats each network sells, adult-heavy / strict-policy flags, what it suits best
const TG = window.TRAFFIC_GUIDE || null;
const gTags = key => { const n = TG && TG.NETWORKS[key]; if (!n) return ''; return n.f.map(f => '<span class="tag plain">' + esc(TG.fmtName(f)) + '</span>').join('') + (n.adult === 'adult' ? '<span class="tag warn">adult sites</span>' : n.adult === 'mixed' ? '<span class="tag dim" title="Big adult inventory; target its mainstream sites">adult-heavy</span>' : '') + (n.strict ? '<span class="tag warn" title="Strict ad policy: crypto, income claims and MLM are restricted or need approval">strict policy</span>' : ''); };
const gText = key => { const n = TG && TG.NETWORKS[key]; return n ? n.f.map(f => (TG.FORMATS[f] || {}).name || f).join(' ') : ''; };
const ago = ts => { if (!ts) return 'never'; const s = Math.max(0, Math.round((Date.now() - ts) / 1000)); return s < 60 ? 'just now' : s < 3600 ? Math.round(s / 60) + ' min ago' : s < 86400 ? Math.round(s / 3600) + ' h ago' : Math.round(s / 86400) + ' d ago'; }; const ago = ts => { if (!ts) return 'never'; const s = Math.max(0, Math.round((Date.now() - ts) / 1000)); return s < 60 ? 'just now' : s < 3600 ? Math.round(s / 60) + ' min ago' : s < 86400 ? Math.round(s / 3600) + ' h ago' : Math.round(s / 86400) + ' d ago'; };
const netOf = s => CAT.find(c => c.key === s.template) || null; const netOf = s => CAT.find(c => c.key === s.template) || null;
const netName = s => { const n = netOf(s); return n ? n.name : (s.template === 'custom' ? 'Custom' : s.template); }; const netName = s => { const n = netOf(s); return n ? n.name : (s.template === 'custom' ? 'Custom' : s.template); };
const EV_LABEL = { join: 'Join', lead: 'Lead', wallet: 'Wallet', purchase: 'Purchase', external: 'Partner-reported' }; const EV_LABEL = { join: 'Join', lead: 'Lead', wallet: 'Wallet', purchase: 'Purchase', external: 'Partner-reported', goal: 'Any goal (pixel)' };
async function load(keep) { async function load(keep) {
let r; try { r = await CR.get('/api/my/sources'); } catch (e) { CR.sub('could not load'); return; } let r; try { r = await CR.get('/api/my/sources'); } catch (e) { CR.sub('could not load'); return; }
@@ -43,6 +47,9 @@
$('dOn').innerHTML = s.enabled ? '<span class="ok"><span class="dot"></span>ON</span>' : '<span class="warn"><span class="dot"></span>OFF' + (s.fails >= 10 ? ' (postback failed 10 times)' : '') + '</span>'; $('dOn').innerHTML = s.enabled ? '<span class="ok"><span class="dot"></span>ON</span>' : '<span class="warn"><span class="dot"></span>OFF' + (s.fails >= 10 ? ' (postback failed 10 times)' : '') + '</span>';
$('togBtn').textContent = s.enabled ? 'Disable' : 'Enable'; $('togBtn').textContent = s.enabled ? 'Disable' : 'Enable';
$('tiles').innerHTML = [CR.tile({ k: 'Clicks, 30 d', v: fmt(s.hits30 || 0), hi: true }), CR.tile({ k: 'Unique, 30 d', v: fmt(s.unique30 || 0) }), CR.tile({ k: 'Conversions, 30 d', v: fmt(s.conv30 || 0) }), CR.tile({ k: 'Postbacks sent', v: fmt(s.sent || 0), note: s.lastAt ? 'last ' + ago(s.lastAt) + ' · ' + s.lastStatus : 'none yet' }), CR.tile({ k: 'Links using it', v: fmt(s.links || 0) })].join(''); $('tiles').innerHTML = [CR.tile({ k: 'Clicks, 30 d', v: fmt(s.hits30 || 0), hi: true }), CR.tile({ k: 'Unique, 30 d', v: fmt(s.unique30 || 0) }), CR.tile({ k: 'Conversions, 30 d', v: fmt(s.conv30 || 0) }), CR.tile({ k: 'Postbacks sent', v: fmt(s.sent || 0), note: s.lastAt ? 'last ' + ago(s.lastAt) + ' · ' + s.lastStatus : 'none yet' }), CR.tile({ k: 'Links using it', v: fmt(s.links || 0) })].join('');
const gb = TG && TG.NETWORKS[s.template], bf = gb ? TG.bestFor(s.template) : [];
$('dGuide').hidden = !gb;
if (gb) $('dGuide').innerHTML = (gb.f.length ? '<span>Sells</span>' + gTags(s.template) : gTags(s.template)) + (bf.length ? '<span>· Best for: <b>' + esc(bf.join(', ')) + '</b></span>' : (gb.note ? '<span>' + esc(gb.note) + '</span>' : '')) + '<span class="grow"></span><a href="/traffic-guide">Which traffic for which offer &rarr;</a>';
renderUrl(s); renderPb(s, null); renderSettings(s); renderUrl(s); renderPb(s, null); renderSettings(s);
if (!quiet) window.scrollTo({ top: 0 }); if (!quiet) window.scrollTo({ top: 0 });
try { DET = await CR.get('/api/my/sources/' + id); } catch (e) { DET = null; } try { DET = await CR.get('/api/my/sources/' + id); } catch (e) { DET = null; }
@@ -102,14 +109,14 @@
async function newSource() { async function newSource() {
if (!CAT.length) { try { CAT = (await CR.get('/api/sources/catalog')).catalog || []; } catch (e) {} } if (!CAT.length) { try { CAT = (await CR.get('/api/sources/catalog')).catalog || []; } catch (e) {} }
let chosen = null; let chosen = null;
const row = c => '<div class="cat" data-key="' + esc(c.key) + '" role="button" tabindex="0"><div><b>' + esc(c.name) + '</b><span class="site">' + esc(c.site || '') + (c.costModel ? ' · ' + esc(c.costModel) : '') + '</span></div><div class="tags">' + (c.hasClickId ? '' : '<span class="tag warn" title="This network has no click id macro and no postback. The source still tags your campaign URL and shows in Reports.">no click id</span>') + (c.hasPostback ? '<span class="tag ok">postback</span>' : (c.hasClickId ? '<span class="tag dim">no postback</span>' : '')) + (c.verified ? '' : '<span class="tag dim" title="Macros copied from public docs, not yet checked against a live account">unverified</span>') + '</div></div>'; const row = c => '<div class="cat" data-key="' + esc(c.key) + '" role="button" tabindex="0"><div><b>' + esc(c.name) + '</b><span class="site">' + esc(c.site || '') + (c.costModel ? ' · ' + esc(c.costModel) : '') + '</span>' + (gTags(c.key) ? '<div class="fm">' + gTags(c.key) + '</div>' : '') + '</div><div class="tags">' + (c.hasClickId ? '' : '<span class="tag warn" title="This network has no click id macro and no postback. The source still tags your campaign URL and shows in Reports.">no click id</span>') + (c.hasPostback ? '<span class="tag ok">postback</span>' : (c.hasClickId ? '<span class="tag dim">no postback</span>' : '')) + (c.verified ? '' : '<span class="tag dim" title="Macros copied from public docs, not yet checked against a live account">unverified</span>') + '</div></div>';
const p1 = dialog({ title: 'New source', text: 'Pick the network you buy traffic on. Its macros and postback come prefilled; you can change anything later under Settings.', const p1 = dialog({ title: 'New source', text: 'Pick the network you buy traffic on. Its macros and postback come prefilled; you can change anything later under Settings. Search by name or by format (pop, push, native...). Not sure which fits your offer? See the Traffic guide.',
html: '<input class="field catf" id="catFilter" type="search" placeholder="Search ' + CAT.length + ' networks by name or site" aria-label="Search networks"><div class="catlist" id="catList">' + CAT.map(row).join('') + '</div>', ok: 'Custom (define your own)', no: 'Cancel' }); html: '<input class="field catf" id="catFilter" type="search" placeholder="Search ' + CAT.length + ' networks by name or site" aria-label="Search networks"><div class="catlist" id="catList">' + CAT.map(row).join('') + '</div>', ok: 'Custom (define your own)', no: 'Cancel' });
const host = $('crModalHost'); const host = $('crModalHost');
const wire = () => host.querySelectorAll('.cat').forEach(el => { const go = () => { chosen = el.dataset.key; host.querySelector('#dlgOk').click(); }; el.addEventListener('click', go); el.addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); go(); } }); }); const wire = () => host.querySelectorAll('.cat').forEach(el => { const go = () => { chosen = el.dataset.key; host.querySelector('#dlgOk').click(); }; el.addEventListener('click', go); el.addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); go(); } }); });
wire(); wire();
const flt = host.querySelector('#catFilter'); flt.focus(); const flt = host.querySelector('#catFilter'); flt.focus();
flt.addEventListener('input', () => { const q = flt.value.trim().toLowerCase(); const list = CAT.filter(c => !q || c.name.toLowerCase().includes(q) || (c.site || '').toLowerCase().includes(q) || c.key.includes(q)); host.querySelector('#catList').innerHTML = list.length ? list.map(row).join('') : '<div class="cat"><span class="muted">No network by that name. Use Custom and paste its macros yourself.</span></div>'; wire(); }); flt.addEventListener('input', () => { const q = flt.value.trim().toLowerCase(); const list = CAT.filter(c => !q || c.name.toLowerCase().includes(q) || (c.site || '').toLowerCase().includes(q) || c.key.includes(q) || gText(c.key).toLowerCase().includes(q)); host.querySelector('#catList').innerHTML = list.length ? list.map(row).join('') : '<div class="cat"><span class="muted">No network by that name. Use Custom and paste its macros yourself.</span></div>'; wire(); });
flt.addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); const first = host.querySelector('.cat[data-key]'); if (first) first.click(); } }); flt.addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); const first = host.querySelector('.cat[data-key]'); if (first) first.click(); } });
const ok = await p1; if (!ok) return; const ok = await p1; if (!ok) return;
const tpl = chosen ? CAT.find(c => c.key === chosen) : null; const tpl = chosen ? CAT.find(c => c.key === chosen) : null;
+51
View File
@@ -0,0 +1,51 @@
// Holding-tank readiness on the tank cards (Marty 2026-11-18, stage 1 of the tank warm-up). The server attaches `rd` to each waiting
// lead from the network hub: { entry: {reason, site, at, detail}, stage, heat: {score, band, label, trend}, last: {kind, site, at} }.
// A lead without `rd` (the hub is down) renders exactly as before. Shared by InstantAdPay and LinkSpin (same file in both).
(function () {
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const SITES = { iap: 'InstantAdPay', instantadpay: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', dlb: 'Downline Banners',
vbb: 'ViralBannerBlitz', vab: 'ViralAdBlitz', viraladblitz: 'ViralAdBlitz', fivex: '5xYourTeam', dh: 'DownlineHydra', downlinehydra: 'DownlineHydra', hydra: 'DownlineHydra',
ypb: 'YourProgramBuilder', yourprogrambuilder: 'YourProgramBuilder', vas: 'ViralAdSource', viraladsource: 'ViralAdSource', ctb: 'CryptoTeamBuild',
stackpol: 'Stack POL', earnerscorner: 'Earners Corner', polhunter: 'PolHunter', btc4hits: 'BTC4Hits' };
const site = s => (s ? SITES[String(s).toLowerCase()] || String(s) : '');
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const day = t => { if (!t) return ''; const d = new Date(t); return MON[d.getMonth()] + ' ' + d.getDate() + (d.getFullYear() !== new Date().getFullYear() ? ', ' + d.getFullYear() : ''); };
const month = t => { if (!t) return ''; const d = new Date(t); return MON[d.getMonth()] + ' ' + d.getFullYear(); };
const ago = t => { if (!t) return ''; const ms = Date.now() - t; if (ms < 3600e3) return Math.max(1, Math.round(ms / 60e3)) + ' min ago'; if (ms < 86400e3) return Math.round(ms / 3600e3) + 'h ago'; const d = Math.floor(ms / 86400e3); return d === 1 ? 'yesterday' : d + ' days ago'; };
const who = d => (d && d.from ? ' @' + d.from : '');
function entryText(e) {
if (!e || !e.reason || e.reason === 'unknown') return 'How they got here: unknown';
const d = e.detail || {};
switch (e.reason) {
case 'joined': {
const src = [d.via ? 'via ' + d.via : '', d.ref && d.ref !== 'direct' ? 'from ' + d.ref : d.ref === 'direct' ? 'typed in directly' : ''].filter(Boolean).join(', ');
return 'Joined ' + (site(e.site) || 'the network') + ' ' + day(e.at) + ' with no sponsor' + (src ? ' (' + src + ')' : '');
}
case 'imported': return 'Imported old member of ' + (site(d.oldSite) || 'an older network site') + (d.memberSince ? ', member since ' + month(d.memberSince) : '') + (d.lastSeenOld ? ', last seen there ' + month(d.lastSeenOld) : '') + (e.at ? ' (in the tank since ' + day(e.at) + ')' : '');
case 'rescued': return 'Moved here ' + day(e.at) + ': their sponsor' + who(d) + ' did not reach them in 14 days';
case 'released': return d.note ? 'Released ' + day(e.at) + ' by' + (who(d) || ' the member') + ' who had adopted them' : 'Released by their sponsor' + who(d) + ' ' + day(e.at);
case 'sponsor_gone': return 'Their sponsor left or was blocked (in the tank since ' + day(e.at) + ')';
case 'returned': return 'Back in the tank ' + day(e.at) + ': an adoption' + (d.from ? ' by @' + d.from : '') + ' ended before they got started';
default: return 'How they got here: unknown';
}
}
const STAGE = { new: ['New', 'Nothing yet beyond joining'], warming: ['Warming', 'Visited or clicked a tracked link'], engaged: ['Engaged', 'Signed in or replied'], activated: ['Activated', 'Wallet linked'], ready: ['Ready', 'Bought something'] };
const VERB = { signin: 'signed in', visit: 'visited', click: 'clicked a tracked link', wallet: 'linked a wallet', purchase: 'bought a package', upgrade: 'upgraded', message: 'replied to a message', share: 'shared a link' };
function lastText(l) {
if (!l) return 'no activity yet';
return (VERB[l.kind] || l.kind) + (l.site ? ' on ' + site(l.site) : '') + ', ' + ago(l.at);
}
// the block that goes under the lead's name: stage chip, heat, last action, entry reason
function html(rd) {
if (!rd) return '';
const st = STAGE[rd.stage] || STAGE.new; const h = rd.heat || { score: 0, band: 'cold', label: 'Cold' };
const tr = h.trend === 'up' ? ' &#8599;' : h.trend === 'down' ? ' &#8600;' : '';
return '<span class="rd-line"><span class="rd-stage rd-s-' + esc(rd.stage) + '" title="' + esc(st[1]) + '">' + esc(st[0]) + '</span>'
+ '<span class="rd-heat rd-' + esc(h.band) + '" title="Heat 0-100 from real actions across the network, recent ones count most. Hot 70+, Warm 40-69, Cooling 15-39, Cold under 15.">' + Number(h.score || 0) + ' &middot; ' + esc(h.label || '') + tr + '</span>'
+ '<span class="rd-last" title="Their newest real action on the network">' + esc(lastText(rd.last)) + '</span></span>'
+ '<span class="rd-entry">' + esc(entryText(rd.entry)) + '</span>';
}
const score = m => (m && m.rd && m.rd.heat ? Number(m.rd.heat.score) || 0 : -1);
window.TankReady = { html, entryText, lastText, score, stageLabel: s => (STAGE[s] || STAGE.new)[0] };
})();
+5 -1
View File
@@ -17,11 +17,15 @@
ms.sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0)); ms.sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0));
return ms; return ms;
} }
// where a direct came from + how they joined (2026-11-13): src = first-touch referrer with the link's ?src= tag, via = the path
const VIA_LABEL = { carried: 'came over from InstantAdPay', btc4hits: 'moved over from BTC4Hits', direct: 'your invite link', stack: 'Stack POL', zones: 'an ad zone', tank: 'adopted from the holding tank' };
const srcLabel = s => !s ? '' : s === 'direct' ? 'no referring site' : s === 'network' ? 'InstantAdPay' : /^legacy:/.test(s) ? s.split(':')[1] : s;
const originText = m => { const a = srcLabel(m.src), b = m.via ? (VIA_LABEL[m.via] || ('link "' + m.via + '"')) : ''; return (a ? 'from ' + a : '') + (a && b ? ' · ' : '') + (b ? 'via ' + b : ''); };
function render() { function render() {
const ms = rows(); const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); const total = L ? L.members.length : 0; const ms = rows(); const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); const total = L ? L.members.length : 0;
$('rows').innerHTML = ms.length ? ms.map(m => { const today = (m.lastSeen || 0) >= dayStart(); $('rows').innerHTML = ms.length ? ms.map(m => { const today = (m.lastSeen || 0) >= dayStart();
const sg = stageOf(m), q = quiet(m); const sg = stageOf(m), q = quiet(m);
return '<div class="rw st-row' + (q ? ' stalled' : '') + '" data-st="' + sg + '"><div><b>' + esc(m.name) + (m.own ? ' <span class="tag dim">YOURS</span>' : '') + '</b><br><span class="mono muted" style="font-size:11px">' + (m.memberId ? '#' + m.memberId + ' · ' : '') + 'joined ' + new Date(m.joined).toLocaleDateString() + (m.bought ? ' · $25+ buy' : '') + (m.buyers ? ' · ' + m.buyers + ' qualifying' : '') + '</span></div>' return '<div class="rw st-row' + (q ? ' stalled' : '') + '" data-st="' + sg + '"><div><b>' + esc(m.name) + (m.own ? ' <span class="tag dim">YOURS</span>' : '') + (m.founder ? ' <span class="tag" title="Founder badge: signed in before LinkSpin launched" style="background:#ffc94d;color:#5a3f00">FOUNDER</span>' : '') + '</b><br><span class="mono muted" style="font-size:11px">' + (m.memberId ? '#' + m.memberId + ' · ' : '') + 'joined ' + new Date(m.joined).toLocaleDateString() + (m.bought ? ' · $25+ buy' : '') + (m.buyers ? ' · ' + m.buyers + ' qualifying' : '') + '</span>' + (m.email && !m.own ? '<br><span class="mono" style="font-size:11.5px;word-break:break-all">' + esc(m.email) + '</span>' : '') + (!m.own && originText(m) ? '<br><span class="muted" style="font-size:11.5px">' + esc(originText(m)) + '</span>' : '') + '</div>'
+ '<span class="mono ' + (today ? 'ok' : (m.lastSeen && Date.now() - m.lastSeen > 3 * 86400e3 ? 'warn' : '')) + '" style="font-size:12px">' + (today ? 'today' : ago(m.lastSeen)) + '</span>' + '<span class="mono ' + (today ? 'ok' : (m.lastSeen && Date.now() - m.lastSeen > 3 * 86400e3 ? 'warn' : '')) + '" style="font-size:12px">' + (today ? 'today' : ago(m.lastSeen)) + '</span>'
+ '<span><span class="stg" data-st="' + sg + '">' + STAGE[sg] + '</span>' + (q ? '<br><span class="stg quiet">' + (m.lastSeen ? 'quiet ' + Math.floor((Date.now() - m.lastSeen) / 86400e3) + 'd' : 'never signed in') + '</span>' : '') + '</span>' + '<span><span class="stg" data-st="' + sg + '">' + STAGE[sg] + '</span>' + (q ? '<br><span class="stg quiet">' + (m.lastSeen ? 'quiet ' + Math.floor((Date.now() - m.lastSeen) / 86400e3) + 'd' : 'never signed in') + '</span>' : '') + '</span>'
+ '<span class="r num">' + (m.earnedWei && m.earnedWei !== '0' ? '+' + pol(m.earnedWei) + ' POL' : '<span class="muted">0</span>') + '</span>' + '<span class="r num">' + (m.earnedWei && m.earnedWei !== '0' ? '+' + pol(m.earnedWei) + ' POL' : '<span class="muted">0</span>') + '</span>'
+40 -24
View File
@@ -1,7 +1,12 @@
/* /tools: the legacy member panes inside the Control Room. site.css sits in the "legacy" layer under cr.css, so the /* /tools: the legacy member panes inside the Control Room. site.css sits in the "legacy" layer under cr.css, so the
shared classes (.btn .chip .chips .muted .mono .tile) already take the Control Room look; this file restyles the shared classes (.btn .chip .chips .muted .mono .tile) already take the Control Room look; this file restyles the
pane internals that only site.css knows about, to the INSTRUMENT light scheme. */ pane internals that only site.css knows about, to the INSTRUMENT light scheme. */
:root{--mint:var(--accent-hi);--mint-ink:#fff;--mint-hi:var(--accent);--mint-soft:var(--accent-soft);--cyan:var(--ok);--violet:#6D4AFF;--amber:var(--warn);--gold:var(--sig);--disp:var(--display);--radius:8px;--ground:var(--bg);--ground2:var(--panel-2);--panel-solid:var(--panel);--ink:#0F1B2E} /* every site.css token maps onto a Control Room token here, so both themes flow through (2026-11-01) */
:root{--mint:var(--accent-hi);--mint-ink:var(--accent-ink);--mint-hi:var(--accent);--mint-deep:var(--accent-hi);--mint-pale:var(--accent-hi);--mint-soft:var(--accent-soft);--mint-faint:var(--accent-soft);--mint-soft-2:var(--accent-soft);--mint-line:var(--accent-dim);--mint-line-2:var(--accent);
--cyan:var(--ok);--cyan-soft:var(--ok-soft);--cyan-line:var(--ok-line);--amber:var(--warn);--amber-soft:var(--warn-soft);--amber-line:var(--warn-line);--amber-ink:var(--accent-ink);
--gold:var(--sig);--gold-2:var(--sig-2);--gold-soft:var(--sig-soft);--gold-faint:var(--sig-soft);--gold-line:var(--sig-line);--muted-soft:var(--panel-2);--ink-faint:var(--row-hover);
--ground:var(--bg);--ground2:var(--panel-2);--ground-soft:var(--panel-2);--panel-solid:var(--panel);--nav-bg:var(--panel);--side-bg:var(--panel);--pill-bg:var(--panel-2);--panel-grad-deep:var(--panel-grad);--glow:transparent;
--disp:var(--display);--radius:8px}
#page{color:var(--ink)} #page{color:var(--ink)}
#memberArea.bo{display:block;min-height:0} #memberArea.bo{display:block;min-height:0}
.bo-main{display:block} .bo-main{display:block}
@@ -12,7 +17,7 @@
.tabs.bo-menu button.on{background:var(--panel);border-color:var(--accent);color:var(--accent-hi);box-shadow:0 1px 2px rgba(15,27,46,.08)} .tabs.bo-menu button.on{background:var(--panel);border-color:var(--accent);color:var(--accent-hi);box-shadow:0 1px 2px rgba(15,27,46,.08)}
.tabs.bo-menu button svg{display:none} .tabs.bo-menu button svg{display:none}
.tools-right{margin-left:auto;display:flex;gap:8px;align-items:center} .tools-right{margin-left:auto;display:flex;gap:8px;align-items:center}
.chat-badge{display:inline-grid;place-items:center;min-width:16px;height:16px;border-radius:8px;background:var(--sig);color:#fff;font:700 10px var(--mono);padding:0 4px} .chat-badge{display:inline-grid;place-items:center;min-width:16px;height:16px;border-radius:8px;background:var(--sig);color:var(--sig-ink);font:700 10px var(--mono);padding:0 4px}
.ad-strip{padding:8px 24px 0} .ad-strip{padding:8px 24px 0}
.card{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:14px 16px;margin:0 0 14px;box-shadow:var(--sh);color:var(--ink)} .card{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:14px 16px;margin:0 0 14px;box-shadow:var(--sh);color:var(--ink)}
.card h3,.card-head h3{font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;margin:0 0 8px;color:var(--ink)} .card h3,.card-head h3{font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;margin:0 0 8px;color:var(--ink)}
@@ -20,20 +25,20 @@
.card-head .sub{font-family:var(--mono);font-size:10.5px;color:var(--muted);letter-spacing:.04em} .card-head .sub{font-family:var(--mono);font-size:10.5px;color:var(--muted);letter-spacing:.04em}
.card p{color:var(--ink-2)} .card .muted{color:var(--muted)} .card p{color:var(--ink-2)} .card .muted{color:var(--muted)}
.small{font-size:12.5px} .eyebrow{font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:var(--muted)} .small{font-size:12.5px} .eyebrow{font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:var(--muted)}
#page input:not([type=checkbox]):not([type=radio]):not([type=file]),#page select,#page textarea{background:#fff;border:1px solid var(--line-strong);border-radius:6px;padding:7px 10px;color:var(--ink);font:inherit;box-shadow:0 1px 2px rgba(15,27,46,.06) inset} #page input:not([type=checkbox]):not([type=radio]):not([type=file]),#page select,#page textarea{background:var(--field-bg);border:1px solid var(--line-strong);border-radius:6px;padding:7px 10px;color:var(--ink);font:inherit;box-shadow:0 1px 2px rgba(15,27,46,.06) inset}
#page input:focus,#page select:focus,#page textarea:focus{border-color:var(--sig);outline:none;box-shadow:0 0 0 3px rgba(255,106,26,.18)} #page input:focus,#page select:focus,#page textarea:focus{border-color:var(--sig);outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--sig) 18%,transparent)}
#page input::placeholder,#page textarea::placeholder{color:#8E9BB1} #page input::placeholder,#page textarea::placeholder{color:var(--muted)}
.btn.sec{background:transparent;color:var(--ink);box-shadow:none} .btn.sec{background:transparent;color:var(--ink);box-shadow:none}
.btn.small{padding:4px 9px;font-size:11px} .btn.small{padding:4px 9px;font-size:11px}
.btn.disabled,.btn[disabled]{opacity:.5} .btn.disabled,.btn[disabled]{opacity:.5}
.chip-t,.chips button.chip-t{border:1px solid var(--line-strong);border-radius:999px;padding:4px 12px;font:700 11.5px var(--body);color:var(--ink-2);background:#fff;cursor:pointer} .chip-t,.chips button.chip-t{border:1px solid var(--line-strong);border-radius:999px;padding:4px 12px;font:700 11.5px var(--body);color:var(--ink-2);background:var(--panel);cursor:pointer}
.chip-t.on,.chips button.chip-t.on{border-color:var(--accent);color:var(--accent-hi);background:var(--accent-soft)} .chip-t.on,.chips button.chip-t.on{border-color:var(--accent);color:var(--accent-hi);background:var(--accent-soft)}
.chip,.chip.flat{font-size:10.5px;padding:2px 8px} .chip,.chip.flat{font-size:10.5px;padding:2px 8px}
.pill{display:inline-block;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;border:1px solid var(--line-strong);border-radius:4px;padding:1px 7px;color:var(--ink-2);background:var(--panel-2)} .pill{display:inline-block;font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;border:1px solid var(--line-strong);border-radius:4px;padding:1px 7px;color:var(--ink-2);background:var(--panel-2)}
.statx{background:linear-gradient(180deg,#FFFFFF,#F6F8FC);border:1px solid var(--line);border-radius:8px;padding:12px 14px;box-shadow:var(--sh)} .statx{background:var(--panel-grad);border:1px solid var(--line);border-radius:8px;padding:12px 14px;box-shadow:var(--sh)}
.statx .pl{background:var(--accent-soft);border:1px solid var(--line)} .statx .pl svg{stroke:var(--accent-hi)} .statx .pl{background:var(--accent-soft);border:1px solid var(--line)} .statx .pl svg{stroke:var(--accent-hi)}
.statx.c-cyan .pl{background:var(--ok-soft)} .statx.c-cyan .pl svg{stroke:var(--ok)} .statx.c-cyan .pl{background:var(--ok-soft)} .statx.c-cyan .pl svg{stroke:var(--ok)}
.statx.c-violet .pl{background:#EEE9FF} .statx.c-violet .pl svg{stroke:#6D4AFF} .statx.c-violet .pl{background:var(--violet-soft)} .statx.c-violet .pl svg{stroke:var(--violet)}
.statx.c-amber .pl{background:var(--warn-soft)} .statx.c-amber .pl svg{stroke:var(--warn)} .statx.c-amber .pl{background:var(--warn-soft)} .statx.c-amber .pl svg{stroke:var(--warn)}
.statx .nv{font-family:var(--display);font-size:28px;color:var(--ink)} .statx .lb{font-size:10.5px;letter-spacing:.1em} .statx .nv{font-family:var(--display);font-size:28px;color:var(--ink)} .statx .lb{font-size:10.5px;letter-spacing:.1em}
.promo-block,.pv,.obj,.gs,.next-card,.wo-slot,.lin-row,.tk-sec,.pipe-col,.pipe-card,.angle-row,.pb-acc{background:var(--panel-2);border:1px solid var(--line);border-radius:8px} .promo-block,.pv,.obj,.gs,.next-card,.wo-slot,.lin-row,.tk-sec,.pipe-col,.pipe-card,.angle-row,.pb-acc{background:var(--panel-2);border:1px solid var(--line);border-radius:8px}
@@ -45,17 +50,17 @@
.pb-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:6px} .pb-size{font-family:var(--mono);font-size:11px;color:var(--muted);flex:1} .pb-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:6px} .pb-size{font-family:var(--mono);font-size:11px;color:var(--muted);flex:1}
.obj>summary{padding:10px 14px;font-weight:700;cursor:pointer;color:var(--ink)} .obj-body{padding:0 14px 14px} .obj-truth p{color:var(--ink-2)} .obj>summary{padding:10px 14px;font-weight:700;cursor:pointer;color:var(--ink)} .obj-body{padding:0 14px 14px} .obj-truth p{color:var(--ink-2)}
.next-card{border-color:var(--accent-soft)} .next-card::before{display:none} .next-card{border-color:var(--accent-soft)} .next-card::before{display:none}
.callout{background:var(--sig-soft);border:1px solid #F7C7A9;border-radius:8px;padding:10px 12px;color:var(--ink)} .callout{background:var(--sig-soft);border:1px solid var(--sig-line);border-radius:8px;padding:10px 12px;color:var(--ink)}
table{font-size:13px;color:var(--ink)} th{font-family:var(--mono);font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);text-align:left;padding:8px 10px;border-bottom:1px solid var(--line)} td{padding:8px 10px;border-bottom:1px solid var(--line)} table{font-size:13px;color:var(--ink)} th{font-family:var(--mono);font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);text-align:left;padding:8px 10px;border-bottom:1px solid var(--line)} td{padding:8px 10px;border-bottom:1px solid var(--line)}
.feed .row{color:var(--ink)} .feed .row:first-child{background:var(--accent-soft)} .feed .t-TierPaid,.feed .t-Purchase,.feed .t-AwardPaid{color:var(--accent-hi)} .feed .row{color:var(--ink)} .feed .row:first-child{background:var(--accent-soft)} .feed .t-TierPaid,.feed .t-Purchase,.feed .t-AwardPaid{color:var(--accent-hi)}
.badge{background:var(--accent-soft);color:var(--accent-hi);border-color:var(--accent-soft)} .badge{background:var(--accent-soft);color:var(--accent-hi);border-color:var(--accent-soft)}
.qa button{display:block;width:100%;text-align:left;background:#fff;border:1px solid var(--line-strong);border-radius:var(--r);padding:8px 12px;margin:0 0 6px;font:700 12px var(--body);color:var(--ink);cursor:pointer} .qa button:hover{border-color:var(--accent)} .qa button{display:block;width:100%;text-align:left;background:var(--panel);border:1px solid var(--line-strong);border-radius:var(--r);padding:8px 12px;margin:0 0 6px;font:700 12px var(--body);color:var(--ink);cursor:pointer} .qa button:hover{border-color:var(--accent)}
.line-tree,.lt-node{color:var(--ink)} .lt-node{background:#fff;border:1px solid var(--line-strong);border-radius:6px;padding:4px 10px} .lt-node.qualified{border-color:var(--sig);color:var(--sig-2)} .line-tree,.lt-node{color:var(--ink)} .lt-node{background:var(--panel);border:1px solid var(--line-strong);border-radius:6px;padding:4px 10px} .lt-node.qualified{border-color:var(--sig);color:var(--sig-2)}
.boot-spin .ring{border-color:var(--accent-soft);border-top-color:var(--accent)} .boot-spin .ring{border-color:var(--accent-soft);border-top-color:var(--accent)}
.bo-pagefoot{margin:8px 0 0;padding:14px 24px;border-top:1px solid var(--line);display:flex;gap:18px;flex-wrap:wrap;align-items:center;font-size:12px} .bo-pagefoot a{color:var(--muted)} .bo-pagefoot a:hover{color:var(--ink)} .bo-pagefoot{margin:8px 0 0;padding:14px 24px;border-top:1px solid var(--line);display:flex;gap:18px;flex-wrap:wrap;align-items:center;font-size:12px} .bo-pagefoot a{color:var(--muted)} .bo-pagefoot a:hover{color:var(--ink)}
#status{position:fixed;left:50%;transform:translateX(-50%);bottom:20px;background:var(--chrome);color:var(--chrome-ink);border:1px solid var(--chrome-line);border-left:3px solid var(--ok);padding:9px 14px;border-radius:6px;font-size:12px;font-weight:600;z-index:60;max-width:min(560px,92vw)} #status{position:fixed;left:50%;transform:translateX(-50%);bottom:20px;background:var(--chrome);color:var(--chrome-ink);border:1px solid var(--chrome-line);border-left:3px solid var(--ok);padding:9px 14px;border-radius:6px;font-size:12px;font-weight:600;z-index:60;max-width:min(560px,92vw)}
#status.bad{border-left-color:var(--sig)} #status.bad{border-left-color:var(--sig)}
.ed-body{background:#fff;border:1px solid var(--line-strong);border-radius:6px;min-height:110px;padding:10px;color:var(--ink)} .ed-bar button{background:#fff;border:1px solid var(--line-strong);border-radius:5px;color:var(--ink);padding:3px 8px;cursor:pointer} .ed-body{background:var(--field-bg);border:1px solid var(--line-strong);border-radius:6px;min-height:110px;padding:10px;color:var(--ink)} .ed-bar button{background:var(--panel);border:1px solid var(--line-strong);border-radius:5px;color:var(--ink);padding:3px 8px;cursor:pointer}
.chat-drawer{background:var(--panel);color:var(--ink);border-left:1px solid var(--line);box-shadow:-20px 0 40px -30px rgba(15,27,46,.5)} .chat-head{border-bottom:1px solid var(--line)} .chat-msgs,.chat-threads{color:var(--ink)} .chat-drawer{background:var(--panel);color:var(--ink);border-left:1px solid var(--line);box-shadow:-20px 0 40px -30px rgba(15,27,46,.5)} .chat-head{border-bottom:1px solid var(--line)} .chat-msgs,.chat-threads{color:var(--ink)}
.grid.c2{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))} .grid.c2{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}
.tr-group{color:var(--muted)!important} .tr-group{color:var(--muted)!important}
@@ -72,17 +77,28 @@ table{font-size:13px;color:var(--ink)} th{font-family:var(--mono);font-size:10.5
.pipe-board [data-stage="bought"],.pipe-due [data-stage="bought"]{--st:#16a34a} .pipe-board [data-stage="bought"],.pipe-due [data-stage="bought"]{--st:#16a34a}
.pipe-board [data-stage="building"],.pipe-due [data-stage="building"]{--st:#b7791f} .pipe-board [data-stage="building"],.pipe-due [data-stage="building"]{--st:#b7791f}
.pipe-board [data-stage="later"],.pipe-due [data-stage="later"]{--st:#64748b} .pipe-board [data-stage="later"],.pipe-due [data-stage="later"]{--st:#64748b}
.pipe-board .pipe-col{background:color-mix(in srgb,var(--st) 7%,#f8fafc);border:1px solid color-mix(in srgb,var(--st) 28%,#e2e8f0);border-top:4px solid var(--st);border-radius:10px} .pipe-board .pipe-col{background:color-mix(in srgb,var(--st) 7%,var(--panel-2));border:1px solid color-mix(in srgb,var(--st) 28%,var(--line));border-top:4px solid var(--st);border-radius:10px}
.pipe-board .pipe-col h4{color:var(--st);font-weight:800} .pipe-board .pipe-col h4{color:color-mix(in srgb,var(--st) 72%,var(--ink));font-weight:800}
.pipe-board .pipe-col h4 span{background:var(--st);color:#fff;border-radius:999px;padding:0 8px;font-size:12px;line-height:20px;min-width:22px;text-align:center} .pipe-board .pipe-col h4 span{background:var(--st);color:var(--on-ink);border-radius:999px;padding:0 8px;font-size:12px;line-height:20px;min-width:22px;text-align:center}
.pipe-board .pipe-col .hint{color:#475569} .pipe-board .pipe-col .hint{color:var(--ink-2)}
.pipe-board .pipe-card,.pipe-due .pipe-card{background:#fff;border:1px solid color-mix(in srgb,var(--st) 22%,#e2e8f0);border-left:4px solid var(--st);border-radius:8px;box-shadow:0 1px 2px rgba(15,23,42,.06)} .pipe-board .pipe-card,.pipe-due .pipe-card{background:var(--panel);border:1px solid color-mix(in srgb,var(--st) 22%,var(--line));border-left:4px solid var(--st);border-radius:8px;box-shadow:0 1px 2px rgba(15,23,42,.06)}
.pipe-board .pipe-card:hover,.pipe-board .pipe-card:focus-visible,.pipe-due .pipe-card:hover{border-color:var(--st);box-shadow:0 2px 8px color-mix(in srgb,var(--st) 25%,transparent)} .pipe-board .pipe-card:hover,.pipe-board .pipe-card:focus-visible,.pipe-due .pipe-card:hover{border-color:var(--st);box-shadow:0 2px 8px color-mix(in srgb,var(--st) 25%,transparent)}
.pipe-board .pipe-card.on{box-shadow:0 0 0 2px var(--st)} .pipe-board .pipe-card.on{box-shadow:0 0 0 2px var(--st)}
.pipe-card .nm{color:#0f172a} .pipe-card .nm{color:var(--ink)}
.pipe-card .nm small{color:#64748b} .pipe-card .nm small{color:var(--muted)}
.pipe-card .sub{color:#334155} .pipe-card .sub{color:var(--ink-2)}
.pipe-card .note{color:#1e293b} .pipe-card .note{color:var(--ink)}
.pipe-card.stalled{background:#fffbeb} .pipe-card.stalled{background:var(--note-bg)}
.pipe-card .chip.warm{background:#fef3c7;border-color:#f59e0b;color:#92400e;font-weight:700} .pipe-card .chip.warm{background:var(--note-soft);border-color:var(--note-line);color:var(--note-ink);font-weight:700}
.pipe-card .chip.flat{background:#f1f5f9;border-color:#cbd5e1;color:#334155} .pipe-card .chip.flat{background:var(--panel-2);border-color:var(--line-strong);color:var(--ink-2)}
/* dark theme: pipeline stage colours lifted for dark panels (titles, stripes, count pills) */
:root[data-theme="dark"] :where(.pipe-board .pipe-col,.pipe-due .pipe-card,.pipe-board .pipe-card){--st:#8E9FB8}
:root[data-theme="dark"] .pipe-board [data-stage="talking"],:root[data-theme="dark"] .pipe-due [data-stage="talking"]{--st:#B59CFF}
:root[data-theme="dark"] .pipe-board [data-stage="joined"],:root[data-theme="dark"] .pipe-due [data-stage="joined"]{--st:#7AAAFF}
:root[data-theme="dark"] .pipe-board [data-stage="wallet"],:root[data-theme="dark"] .pipe-due [data-stage="wallet"]{--st:#4FC3E6}
:root[data-theme="dark"] .pipe-board [data-stage="payouts"],:root[data-theme="dark"] .pipe-due [data-stage="payouts"]{--st:#FF9A5C}
:root[data-theme="dark"] .pipe-board [data-stage="bought"],:root[data-theme="dark"] .pipe-due [data-stage="bought"]{--st:#4CCB7A}
:root[data-theme="dark"] .pipe-board [data-stage="building"],:root[data-theme="dark"] .pipe-due [data-stage="building"]{--st:#D9A441}
:root[data-theme="dark"] .pipe-board [data-stage="later"],:root[data-theme="dark"] .pipe-due [data-stage="later"]{--st:#8E9FB8}
/* Appearance card on the Profile pane */
.theme-card .seg{margin-top:4px} .theme-card .seg button.on{background:var(--accent);color:var(--accent-ink)}
+149
View File
@@ -0,0 +1,149 @@
// LinkSpin traffic guide data (2026-10-28, Marty: members ask "what traffic for what kind of offer?").
// Shared by the Traffic guide page (/traffic-guide) and the Sources screen (format tags, "good for" line).
// Network formats are what each network is known to sell; members should still confirm in their own ad panel.
window.TRAFFIC_GUIDE = (function () {
const FORMATS = {
pop: {
name: 'Popunder', short: 'Pop',
what: 'Your page opens in a new window or tab behind (or over) the site the visitor was reading.',
buy: 'Usually CPM or CPV (per thousand views). The cheapest clicks you can buy, and the most of them.',
wins: 'One-step offers that need no trust: free sign-ups, email capture, giveaways, games, app installs.',
fails: 'Anything that needs explaining or trust first: long sales letters, high-ticket offers, a cold opportunity pitch.',
page: 'Fast, mobile, one headline and one big button. If it takes more than a few seconds to load, the visitor is gone.',
},
push: {
name: 'Push notifications', short: 'Push',
what: 'A short notification with an icon and a headline, sent to people who allowed notifications from some site.',
buy: 'CPC (per click). You only pay when someone taps.',
wins: 'Curiosity and news-style hooks: lead capture, giveaways, games, "how I..." stories, free tools.',
fails: 'Sending the click straight to a checkout or a signup that asks for a lot. Push readers want a quick payoff.',
page: 'Use a short pre-lander that continues the headline, then the sign-up. Refresh the headline and icon often; push audiences tire fast.',
},
inpage: {
name: 'In-page push', short: 'In-page',
what: 'An ad that looks like a push notification but shows inside the web page (works on iPhones too).',
buy: 'CPC or CPM.',
wins: 'The same offers as push and pop: free sign-ups, giveaways, games, quick lead forms.',
fails: 'Offers that need a long read before anyone acts.',
page: 'Same as push: a headline that promises one thing, and a page that delivers it right away.',
},
native: {
name: 'Native ads', short: 'Native',
what: 'A thumbnail and headline inside "recommended stories" boxes on news and content sites.',
buy: 'CPC. Clicks cost more than pop or push, but readers are in reading mode.',
wins: 'Story-style pre-sells: courses and info products, software, an opportunity explained through your own story.',
fails: 'Hard sells and hype. Mainstream native networks reject income claims and are strict about crypto.',
page: 'An article or "my story" page that warms the reader up, then sends them to the sign-up. Never a bare sign-up form.',
},
search: {
name: 'Search ads', short: 'Search',
what: 'Text ads next to search results, shown to people typing a keyword you bid on.',
buy: 'CPC on keywords. Can be pricey on popular words, cheap on specific ones.',
wins: 'Things people already look for: advertising tools, buying website traffic, software, how-to courses.',
fails: 'Offers nobody searches for. Google and Microsoft also restrict crypto, income opportunities and MLM.',
page: 'Match the keyword in your headline. A searcher wants the answer to what they typed, not a detour.',
},
social: {
name: 'Social ads', short: 'Social',
what: 'Ads in social feeds and stories, aimed by interests, age and location.',
buy: 'CPM or CPC, set by auction.',
wins: 'Video and story content, free lead magnets, community and webinar invites, software and courses.',
fails: 'Direct crypto or "make money" pitches: Facebook restricts them, and accounts get banned for it.',
page: 'Lead with something free and useful (a guide, a video, a webinar), then follow up by email.',
},
display: {
name: 'Banners', short: 'Banner',
what: 'Image ads in fixed spots on websites (728x90, 300x250 and so on).',
buy: 'CPM or CPC.',
wins: 'Retargeting people who already know you, brand reminders, simple free offers.',
fails: 'Cold, complex offers. Banner click rates are low, so the offer has to be obvious at a glance.',
page: 'Bold, simple creative with one message. Test several sizes; some spots convert far better than others.',
},
redirect: {
name: 'Domain redirect', short: 'Redirect',
what: 'Visitors who typed a parked or expired domain are sent straight to your page (also called zero-click).',
buy: 'CPV (per visit).',
wins: 'Lead capture, giveaways, simple sign-ups in the right niche.',
fails: 'Offers that need a pre-sell. The visitor did not choose your ad.',
page: 'Fast and simple, like pop traffic.',
},
};
// offer types LinkSpin members promote; rating per format: best / good / weak / avoid, with a one-line why
const OFFERS = [
{ key: 'join', name: 'Free sign-up or email capture', ex: 'a free join page, a squeeze page, a lead magnet',
fit: { pop: ['best', 'Cheap volume for a one-field page'], inpage: ['best', 'Works on every phone, fast decision'], push: ['good', 'Use a short pre-lander first'], native: ['good', 'Pre-sell with a story, then the form'], redirect: ['good', 'Simple page, quick decision'], social: ['good', 'Offer something free and useful'], display: ['weak', 'Low click rates for cold sign-ups'], search: ['weak', 'Few people search for a page they have never heard of'] },
tip: 'Ask for the email only. Every extra field costs sign-ups. Follow up by email; most people join on a later message.' },
{ key: 'opp', name: 'Crypto or team-build opportunity', ex: 'an on-chain team build, a crypto earning program',
fit: { native: ['good', 'Explain it through your story, check each network\'s crypto rules first'], push: ['good', 'Curiosity hook to a pre-sell or squeeze page, never straight to a buy'], inpage: ['good', 'Same as push'], pop: ['weak', 'Cold and skimming; only to a free squeeze page'], display: ['weak', 'Too much to explain in a banner'], redirect: ['weak', 'No pre-sell'], search: ['avoid', 'Google and Microsoft restrict crypto and income offers'], social: ['avoid', 'Facebook restricts crypto and money-making ads; accounts get banned'] },
tip: 'Capture the email first and explain by email or video. No income promises in ads or pages; networks reject them and they draw complaints.' },
{ key: 'ads', name: 'Advertising tools and ad credits', ex: 'InstantAdPay, LinkSpin, traffic tools',
fit: { search: ['best', 'People search for "buy website traffic" and "advertise my site"'], push: ['good', '"Free ad credits" is a strong hook'], pop: ['good', 'Send to a free join that gives credits'], inpage: ['good', 'Same as push'], native: ['good', 'A how-I-get-traffic story'], social: ['good', 'Target small business owners and marketers'], display: ['weak', 'Fine for retargeting'], redirect: ['weak', 'Rarely the right audience'] },
tip: 'Sell the free starting credits, not the plan. "Get your first ads seen free" beats "join my business".' },
{ key: 'games', name: 'Games and play-to-earn', ex: 'browser games, game rewards',
fit: { pop: ['best', 'Gamers click fast; send to the game itself'], inpage: ['best', 'Mobile-heavy, quick tap to play'], push: ['good', 'Short, playful headlines'], social: ['good', 'Short gameplay video'], native: ['weak', 'Readers are not in play mode'], display: ['weak', 'Only with an eye-catching game image'], redirect: ['weak', 'Hit and miss'], search: ['weak', 'Only for the game\'s own name'] },
tip: 'Land them in the game, not on a sign-up wall. Let them play first and ask for an account when they win something.' },
{ key: 'software', name: 'Software, apps and AI tools', ex: 'an AI writer, a page builder, an app',
fit: { search: ['best', 'High intent: people search for the job the tool does'], native: ['good', 'Review-style or how-to articles'], social: ['good', 'Show the tool working in a short video'], push: ['good', 'A free trial or free tool hook'], inpage: ['good', 'Same as push'], display: ['weak', 'Retargeting only'], pop: ['weak', 'Low attention for a tool that needs a demo'], redirect: ['weak', 'Rarely the right audience'] },
tip: 'Lead with the free trial or free version and one clear result ("write a week of posts in 5 minutes").' },
{ key: 'info', name: 'Courses and info products', ex: 'a course, an ebook, a coaching program',
fit: { native: ['best', 'Story pre-sell to a free lesson'], social: ['good', 'Free lesson or webinar invite'], search: ['good', 'How-to keywords'], push: ['good', 'Only through a pre-lander'], inpage: ['good', 'Only through a pre-lander'], pop: ['weak', 'Too cold for a paid course'], display: ['weak', 'Retargeting only'], redirect: ['weak', 'No pre-sell'] },
tip: 'Give a free first lesson for an email, then sell by email. Cold traffic rarely buys a course on the first visit.' },
{ key: 'sweeps', name: 'Giveaways and freebies', ex: 'a contest, a free gift, a spin-to-win',
fit: { pop: ['best', 'The classic pop offer'], push: ['best', '"You could win" headlines work'], inpage: ['best', 'Same as push'], redirect: ['good', 'Quick entry form'], display: ['good', 'A clear prize image'], native: ['weak', 'Pricey clicks for a freebie'], social: ['weak', 'Strict contest rules on social'], search: ['avoid', 'Almost nobody searches for it'] },
tip: 'Show the prize and the deadline. Keep the entry to one field and say clearly what happens next.' },
];
// formats each catalog network sells (by catalog key). adult: 'mixed' = big adult inventory with mainstream
// options (pick mainstream / non-adult in the targeting), 'adult' = mostly adult sites.
// strict: mainstream ad policies (crypto, income claims, MLM are restricted or need approval).
const NETWORKS = {
'7search-ppc': { f: ['search', 'display'], note: 'Small search network, cheaper and less strict than Google' },
activerevenue: { f: ['pop', 'push', 'inpage', 'native'] },
adskeeper: { f: ['native'], note: 'Native network from the MGID family' },
adsterra: { f: ['pop', 'inpage', 'display', 'native'], note: 'Social Bar is its in-page push format' },
bidvertiser: { f: ['pop', 'push', 'native', 'display'] },
clickadu: { f: ['pop', 'inpage', 'push', 'display'] },
exoclick: { f: ['pop', 'display', 'native', 'push', 'inpage'], adult: 'mixed' },
ezmob: { f: ['pop', 'push', 'native', 'display'] },
facebook: { f: ['social'], strict: true },
froggyads: { f: ['pop', 'push', 'inpage', 'display'] },
'google-adwords': { f: ['search', 'display'], strict: true, note: 'Also YouTube video ads' },
hilltopads: { f: ['pop', 'inpage', 'display'] },
mgid: { f: ['native'], strict: true },
'microsoft-advertising': { f: ['search'], strict: true, note: 'Bing, Yahoo and partner search' },
mondiad: { f: ['push', 'inpage', 'native'] },
mybid: { f: ['pop', 'push', 'native', 'display'] },
plugrush: { f: ['pop', 'display', 'native'], adult: 'mixed' },
popads: { f: ['pop'] },
popcash: { f: ['pop'] },
propellerads: { f: ['pop', 'push', 'inpage'] },
pushground: { f: ['push', 'inpage'] },
reacheffect: { f: ['push', 'pop'] },
revcontent: { f: ['native'], strict: true },
taboola: { f: ['native'], strict: true },
tonic: { f: [], note: 'Mostly a search-monetization partner; confirm what traffic they sell before you spend' },
trafficjunky: { f: ['display', 'native'], adult: 'adult', note: 'Adult sites; also video pre-roll' },
trafficshop: { f: ['pop', 'display'], adult: 'mixed' },
trafficstars: { f: ['pop', 'display', 'native', 'push', 'inpage'], adult: 'mixed' },
ungads: { f: [], note: 'Check the ad formats in your account' },
zeropark: { f: ['pop', 'push', 'redirect', 'search'] },
};
const RULES = [
['Test small, then scale', 'Start each network with a small daily budget and one offer. Keep what converts, cut what does not, then raise the budget on the winners.'],
['Track every click', 'Set the network up under Sources so its click id and postback are on the link. Then Reports shows which network, zone and creative actually converts.'],
['Change one thing at a time', 'New headline or new page or new network, not all three at once, or you will not know what made the difference.'],
['Block the zones that waste money', 'Pop, push and native networks sell from thousands of sites. After a day or two, block the sites and zones with clicks and no sign-ups.'],
['No income promises', 'Ads and pages that promise earnings get rejected and draw complaints. Show what the program is and let people decide.'],
['Mainstream vs adult inventory', 'Networks marked adult-heavy sell a lot of adult traffic. Target their mainstream (non-adult) sites unless your offer fits that audience.'],
];
const fmtName = k => (FORMATS[k] || {}).short || k;
// the formats a source sells, and the offers those formats suit best (for the Sources screen line)
function bestFor(key) {
const n = NETWORKS[key]; if (!n || !n.f.length) return [];
return OFFERS.filter(o => n.f.some(f => o.fit[f] && o.fit[f][0] === 'best') && !(n.strict && o.key === 'opp') && !(n.adult === 'adult' && !['games', 'sweeps'].includes(o.key))).map(o => o.name);
}
return { FORMATS, OFFERS, NETWORKS, RULES, fmtName, bestFor };
})();
+53
View File
@@ -0,0 +1,53 @@
// LinkSpin Traffic guide page (2026-10-28): offer picker, the ad formats, the networks, ground rules.
(function () {
const G = window.TRAFFIC_GUIDE, $ = id => document.getElementById(id), esc = CR.esc;
CR.mount({ active: 'sources', crumb: 'Control room · Sources', title: 'Traffic guide', sub: 'which traffic for which offer', actions: '<a class="btn sm" href="/sources">&larr; Sources</a>' });
let CAT = [], OFF = null, NF = '';
const nameOf = k => { const c = CAT.find(x => x.key === k); return c ? c.name : k; };
const ORDER = ['best', 'good', 'weak', 'avoid'];
function tags(k) {
const n = G.NETWORKS[k] || { f: [] };
return n.f.map(f => '<span class="tag plain">' + esc(G.fmtName(f)) + '</span>').join('')
+ (n.adult === 'adult' ? '<span class="tag warn">adult sites</span>' : n.adult === 'mixed' ? '<span class="tag dim" title="Big adult inventory; target its mainstream sites">adult-heavy</span>' : '')
+ (n.strict ? '<span class="tag warn" title="Strict ad policy: crypto, income claims and MLM are restricted or need approval">strict policy</span>' : '');
}
function renderOffers() {
$('offers').innerHTML = G.OFFERS.map(o => '<button type="button" class="chip' + (OFF === o.key ? ' on' : '') + '" data-k="' + o.key + '">' + esc(o.name) + '</button>').join('');
$('offers').querySelectorAll('.chip').forEach(b => b.addEventListener('click', () => { OFF = OFF === b.dataset.k ? null : b.dataset.k; try { history.replaceState(null, '', OFF ? '#' + OFF : location.pathname); } catch (e) {} renderOffers(); renderResult(); }));
}
function renderResult() {
const o = G.OFFERS.find(x => x.key === OFF);
if (!o) { $('result').innerHTML = '<div class="muted">Pick one above.</div>'; return; }
const rows = Object.keys(o.fit).sort((a, b) => ORDER.indexOf(o.fit[a][0]) - ORDER.indexOf(o.fit[b][0]));
const good = rows.filter(f => o.fit[f][0] === 'best' || o.fit[f][0] === 'good');
// networks that sell at least one best/good format; strict-policy networks are left out for the opportunity offer
// adult-only sites suit few offers
const nets = Object.keys(G.NETWORKS).filter(k => { const n = G.NETWORKS[k]; if (n.strict && o.key === 'opp') return false; if (n.adult === 'adult' && !['games', 'sweeps'].includes(o.key)) return false; return n.f.some(f => good.includes(f)); })
.map(k => ({ k, score: G.NETWORKS[k].f.reduce((s, f) => s + (o.fit[f] ? (o.fit[f][0] === 'best' ? 3 : o.fit[f][0] === 'good' ? 1 : 0) : 0), 0) }))
.sort((a, b) => b.score - a.score || nameOf(a.k).localeCompare(nameOf(b.k)));
$('result').innerHTML = '<div class="res"><div class="fit">'
+ rows.map(f => '<div class="r"><span class="fn">' + esc(G.FORMATS[f].name) + '</span><span class="rate ' + o.fit[f][0] + '">' + o.fit[f][0] + '</span><span class="why">' + esc(o.fit[f][1]) + '</span></div>').join('')
+ '</div><div style="display:grid;gap:12px;align-content:start"><div class="tipbox"><b>Tip.</b> ' + esc(o.tip) + '</div>'
+ '<div><div class="sec" style="margin-bottom:6px">Networks that sell those formats</div><div class="nets">' + nets.map(x => '<a href="#net-' + esc(x.k) + '">' + esc(nameOf(x.k)) + '</a>').join('') + '</div></div>'
+ (o.key === 'opp' ? '<div class="muted" style="font-size:12px">Google, Microsoft, Facebook, Taboola, Revcontent and MGID are left out: their policies restrict crypto and income offers.</div>' : '')
+ '</div></div>';
}
function renderFormats() {
$('fmts').innerHTML = Object.keys(G.FORMATS).map(k => { const f = G.FORMATS[k];
return '<div class="fmt" id="fmt-' + k + '"><h3>' + esc(f.name) + '</h3><p>' + esc(f.what) + '</p><p><b>How you pay:</b> ' + esc(f.buy) + '</p><p><b>Converts:</b> ' + esc(f.wins) + '</p><p><b>Struggles:</b> ' + esc(f.fails) + '</p><p><b>Landing page:</b> ' + esc(f.page) + '</p></div>'; }).join('');
}
function renderNets() {
const fs = Object.keys(G.FORMATS);
$('nfilter').innerHTML = '<button type="button" class="chip' + (NF ? '' : ' on') + '" data-f="">All</button>' + fs.map(f => '<button type="button" class="chip' + (NF === f ? ' on' : '') + '" data-f="' + f + '">' + esc(G.FORMATS[f].name) + '</button>').join('');
$('nfilter').querySelectorAll('.chip').forEach(b => b.addEventListener('click', () => { NF = b.dataset.f; renderNets(); }));
const keys = Array.from(new Set(CAT.map(c => c.key).concat(Object.keys(G.NETWORKS)))).filter(k => !NF || ((G.NETWORKS[k] || {}).f || []).includes(NF)).sort((a, b) => nameOf(a).localeCompare(nameOf(b)));
$('nrows').innerHTML = keys.length ? keys.map(k => { const n = G.NETWORKS[k] || { f: [] }, c = CAT.find(x => x.key === k) || {}, bf = G.bestFor(k);
return '<div class="rw" id="net-' + esc(k) + '"><div class="nm"><b>' + esc(nameOf(k)) + '</b><span>' + esc(c.site || '') + '</span></div><div class="tg2">' + (tags(k) || '<span class="muted" style="font-size:12px">check in your account</span>') + '</div>'
+ '<div class="note">' + (bf.length ? 'Best for: ' + esc(bf.join(', ')) + '. ' : '') + esc(n.note || '') + '</div></div>'; }).join('')
: '<div class="rw"><span class="muted">No network sells that format.</span></div>';
}
$('rules').innerHTML = G.RULES.map(r => '<div><b>' + esc(r[0]) + '</b><span>' + esc(r[1]) + '</span></div>').join('');
OFF = (location.hash.slice(1) && G.OFFERS.some(o => o.key === location.hash.slice(1))) ? location.hash.slice(1) : null;
renderOffers(); renderResult(); renderFormats(); renderNets();
CR.get('/api/sources/catalog').then(r => { CAT = r.catalog || []; renderResult(); renderNets(); }).catch(() => {});
})();
+108
View File
@@ -0,0 +1,108 @@
// Video Spin (2026-11-22): the third view on the Links screen. One short link that rotates through video pages on Social Tube.
// It is a spin link underneath (rotator.js, kind 'video'): pause, weights and removal go through the spin-link routes; creating one,
// adding videos and the play counts go through /api/my/videospins (server.js), which checks every video with Video App Income.
(function () {
'use strict';
if (!window.CR || !document.getElementById('vsWs')) return;
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast;
let D = null, SPINS = [], SEL = null, HOST = '', PLAYS = {}, BUSY = false;
let WANT = Number((/^#v([0-9]+)$/.exec(location.hash) || [])[1]) || 0; // the Video Spin named in the address when the page opened
const mark = () => { if (!$('vsWs').hidden) history.replaceState(null, '', '#v' + (SEL || '')); };
const base = () => 'https://' + (HOST || location.host), linkOf = s => base() + '/r/' + s.code;
const clicks7 = s => s.hits7 || 0;
const zoneCode = s => '<iframe src="' + base() + '/vz/' + s.code + '" width="315" height="560" style="border:0;border-radius:14px;max-width:100%" allow="fullscreen" allowfullscreen loading="lazy" title="Videos"></iframe>';
const state = s => s.paused ? { cls: 'warn', t: 'PAUSED' } : !s.destinations.some(d => d.active) ? { cls: 'bad', t: 'NO LIVE VIDEO' } : { cls: 'ok', t: 'LIVE' };
// ── view switch: this script only owns the Video Spins view; banner-spin.js keeps switching the other two ──
function show(on) {
$('vsWs').hidden = !on; const vb = $('vsNewBtn'); if (vb) vb.hidden = !on;
if (on) { $('ws').hidden = true; $('bsWs').hidden = true; const nb = $('newBtn'), bn = $('bsNewBtn'); if (nb) nb.hidden = true; if (bn) bn.hidden = true; }
}
$('vsw').querySelectorAll('button').forEach(b => b.addEventListener('click', () => {
const on = b.dataset.v === 'videos'; show(on);
if (on) load(true);
}));
(function addBtn(n) { const nb = $('newBtn'); if (!nb) { if (n < 50) setTimeout(() => addBtn(n + 1), 200); return; }
const b = document.createElement('button'); b.className = 'btn pri'; b.id = 'vsNewBtn'; b.type = 'button'; b.hidden = $('vsWs').hidden; b.textContent = '+ New Video Spin'; nb.parentNode.appendChild(b);
b.addEventListener('click', () => { SEL = null; render(); const i = $('vsNewName'); if (i) i.focus(); }); })(0);
async function load(keep) {
try { D = await CR.get('/api/my/videospins'); } catch (e) { toast(e.message, true); return; }
SPINS = (D.spins || []).slice().sort((a, b) => clicks7(b) - clicks7(a) || b.created - a.created);
const hs = D.hosts || []; if (!HOST || !hs.includes(HOST)) HOST = hs[0] || location.host;
if (!keep || !SPINS.some(s => s.id === SEL)) SEL = null;
if (WANT) { if (SPINS.some(s => s.id === WANT)) SEL = WANT; WANT = 0; }
mark(); setTimeout(mark, 1500); // the spin-link list reloads in the background and may set its own address; keep ours while this view is open
render(); if (SEL) loadPlays();
}
async function loadPlays() { const id = SEL; try { const r = await CR.get('/api/my/videospins/' + id + '/plays'); if (id === SEL) { PLAYS = r.plays || {}; renderDetail(); } } catch (e) {} }
function render() { renderList(); renderDetail(); }
function renderList() {
const L = D.limits || { spins: 0, videos: 0 }, t = D.tier || { label: '' };
$('vsCount').textContent = SPINS.length + ' Video Spin' + (SPINS.length === 1 ? '' : 's');
$('vsTier').innerHTML = L.spins ? esc(t.label) + ' tier: ' + L.spins + ' Video Spins, ' + L.videos + ' videos in each.'
: 'Video Spins start at the Starter tier (any package of your own): 2 Video Spins with 5 videos in each.';
$('vsItems').innerHTML = SPINS.length ? SPINS.map(s => { const h = state(s); return '<div class="item' + (s.id === SEL ? ' on' : '') + '" data-id="' + s.id + '" role="button" tabindex="0">'
+ '<div><div class="nm">' + esc(s.name) + (h.cls !== 'ok' ? ' <span class="tag ' + h.cls + '">' + h.t + '</span>' : '') + ' <span class="tag plain">' + s.destinations.length + ' video' + (s.destinations.length === 1 ? '' : 's') + '</span></div><div class="cd">' + esc((HOST || location.host) + '/r/' + s.code) + '</div></div>'
+ '<div class="rt"><span class="n">' + fmt(clicks7(s)) + '</span><span class="muted" style="font-size:10px">7 d</span></div></div>'; }).join('')
: '<div class="empty"><div class="muted">No Video Spins yet.</div></div>';
$('vsItems').querySelectorAll('.item').forEach(el => { const go = () => { SEL = Number(el.dataset.id); PLAYS = {}; history.replaceState(null, '', '#v' + SEL); render(); loadPlays(); };
el.addEventListener('click', go); el.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); go(); } }); });
}
function renderDetail() {
const box = $('vsDetail'), s = SPINS.find(x => x.id === SEL), L = D.limits || { spins: 0, videos: 0 };
if (!s) {
const can = D.on && L.spins > 0 && SPINS.length < L.spins;
box.innerHTML = '<div class="vsp"><div class="h-disp" style="font-size:18px">Video Spin</div>'
+ '<p class="muted" style="margin:8px 0 14px;max-width:560px">One short link that plays a different video page each time it is opened. Pick videos you made on Video App Income, or add any member\'s video by its Social Tube link. Share the one link; the videos take turns. People who go on to make their own video are credited to you.</p>'
+ '<details id="vsHow" style="margin:0 0 14px;max-width:640px"><summary style="cursor:pointer;font-weight:600">Watch how this works (1:42)</summary>'
+ '<video controls playsinline preload="none" poster="https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/video-spins.jpg?v=20261122a" style="display:block;width:100%;height:auto;background:#000;border-radius:12px;margin-top:10px" aria-label="Video: Marty walks through Video Spins, 1 minute 42 seconds"><source src="https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/video-spins.mp4?v=20261122a" type="video/mp4"></video></details>'
+ (D.vaiError ? '<p class="muted" style="margin:0 0 12px">' + esc(D.vaiError) + '</p>' : '')
+ (!D.on ? '<p class="muted">Video Spins are not switched on yet.</p>'
: can ? '<div class="vsrow"><input class="field" id="vsNewName" maxlength="80" placeholder="Name this Video Spin, for example: My best videos"><button class="btn pri" type="button" id="vsCreate">Create</button></div>'
: '<p class="muted">' + (L.spins ? 'You have all ' + L.spins + ' Video Spins your tier holds. Remove one to make another.' : 'Video Spins start at the Starter tier (any package of your own).') + '</p>')
+ '</div>';
const c = $('vsCreate'); if (c) { const go = async () => { const name = $('vsNewName').value.trim(); if (!name) { toast('Give it a name first.', true); return; } if (BUSY) return; BUSY = true;
try { const r = await api('/api/my/videospins', { name }); SEL = r.rotation.id; history.replaceState(null, '', '#v' + SEL); toast('Video Spin created. Now add videos.'); await load(true); } catch (e) { toast(e.message, true); } BUSY = false; };
c.addEventListener('click', go); $('vsNewName').addEventListener('keydown', e => { if (e.key === 'Enter') go(); }); }
return;
}
const inSpin = new Set(s.destinations.map(d => d.vid)), mine = (D.videos || []).filter(v => !inSpin.has(v.id)), room = Math.max(0, L.videos - s.destinations.length);
const rows = s.destinations.map(d => { const p = PLAYS[d.vid] || null, gone = p && p.live === false;
const tag = gone ? '<span class="tag bad">REMOVED BY OWNER</span>' : !d.active ? '<span class="tag warn">' + (d.autoPaused ? 'PAUSED: NOT LOADING' : 'PAUSED') + '</span>' : '';
return '<div class="vsv"><img src="' + esc(d.poster || '') + '" alt="" loading="lazy"><div class="vsi"><b>' + esc(d.label || 'Video') + '</b> ' + tag + '<div class="muted">' + (d.vowner ? 'By ' + esc(d.vowner) + '. ' : '') + fmt(d.hits || 0) + ' click' + ((d.hits || 0) === 1 ? '' : 's')
+ (p ? ', ' + fmt(p.views) + ' opened, ' + fmt(p.plays) + ' played, ' + fmt(p.taps) + ' tapped the button' : '') + '</div></div>'
+ '<div class="vsa"><button class="btn sm" type="button" data-act="' + (d.active ? 'pause' : 'resume') + '" data-d="' + d.id + '">' + (d.active ? 'Pause' : 'Resume') + '</button><button class="btn sm" type="button" data-act="remove" data-d="' + d.id + '">Remove</button></div></div>'; }).join('');
box.innerHTML = '<div class="vsp"><div class="vshead"><h2>' + esc(s.name) + '</h2><span class="tag ' + state(s).cls + '">' + state(s).t + '</span></div>'
+ '<div class="vsrow"><input class="field mono" id="vsLink" readonly value="' + esc(linkOf(s)) + '"><button class="btn pri" type="button" id="vsCopy">Copy link</button><button class="btn" type="button" id="vsPause">' + (s.paused ? 'Resume' : 'Pause') + '</button><button class="btn" type="button" id="vsDel">Delete</button></div>'
+ '<p class="muted" style="margin:8px 0 0">' + fmt(s.hits || 0) + ' clicks in all, ' + fmt(s.hits7 || 0) + ' in the last 7 days' + (s.conversions ? ', ' + s.conversions + ' conversion' + (s.conversions === 1 ? '' : 's') : '') + '. Each open goes to one of the videos below.</p>'
+ '<details class="vsz"><summary>Put it on a web page (rotating player)</summary><p class="muted" style="margin:8px 0">Paste this code into any page. Each page view plays a different video from this spin, with that video\'s own button. Page views are not counted as clicks; plays and button taps show under each video.</p><textarea class="field mono" id="vsZone" readonly rows="3" style="width:100%">' + esc(zoneCode(s)) + '</textarea><div class="vsrow" style="margin-top:8px"><button class="btn" type="button" id="vsZoneCopy">Copy code</button></div></details>'
+ '<h3 class="vsh">Videos in this spin <span class="muted">' + s.destinations.length + ' of ' + L.videos + '</span></h3>'
+ (rows || '<p class="muted">No videos yet. Add some below; the link starts working with the first one.</p>')
+ '<h3 class="vsh">Add your videos</h3>'
+ (D.vaiError ? '<p class="muted">' + esc(D.vaiError) + '</p>' : !D.member ? '<p class="muted">No Video App Income account was found for your email address. Make your first video at <a href="https://linkspin.app/r/nwvai?src=linkspin&amp;s2=" target="_blank" rel="noopener">videoappincome.com</a> (it is free), then come back.</p>'
: !room ? '<p class="muted">This Video Spin is full for your tier.</p>'
: mine.length ? '<div class="vsgrid">' + mine.map(v => '<label class="vsc"><input type="checkbox" value="' + esc(v.id) + '"><img src="' + esc(v.poster) + '" alt="" loading="lazy"><span>' + esc(v.title) + '</span></label>').join('') + '</div><div class="vsrow" style="margin-top:10px"><button class="btn pri" type="button" id="vsAddMine">Add selected</button><span class="muted">Room for ' + room + ' more.</span></div>'
: '<p class="muted">' + ((D.videos || []).length ? 'All of your videos are already in this spin.' : 'You have no videos on Social Tube yet. Make one on Video App Income and it appears here.') + '</p>')
+ '<h3 class="vsh">Add any member\'s video</h3><p class="muted" style="margin:0 0 8px">Open the video on socialtube.club and paste its address. Its owner gets the views; people who go on to join are credited to you.</p>'
+ (room ? '<div class="vsrow"><input class="field" id="vsLinkIn" maxlength="300" placeholder="https://socialtube.club/watch/..."><button class="btn" type="button" id="vsAddLink">Add</button></div>' : '<p class="muted">This Video Spin is full for your tier.</p>')
+ '</div>';
$('vsCopy').addEventListener('click', () => { const u = linkOf(s); (navigator.clipboard && navigator.clipboard.writeText ? navigator.clipboard.writeText(u) : Promise.reject()).then(() => toast('Link copied'), () => { $('vsLink').select(); toast('Select and copy the link', true); }); });
$('vsZoneCopy').addEventListener('click', () => { const u = zoneCode(s); (navigator.clipboard && navigator.clipboard.writeText ? navigator.clipboard.writeText(u) : Promise.reject()).then(() => toast('Code copied'), () => { $('vsZone').select(); toast('Select and copy the code', true); }); });
$('vsPause').addEventListener('click', () => act(() => api('/api/my/rotations/' + s.id, { paused: !s.paused }), s.paused ? 'Resumed' : 'Paused'));
$('vsDel').addEventListener('click', e => { const b = e.currentTarget; if (b.dataset.arm !== '1') { b.dataset.arm = '1'; b.textContent = 'Tap again to delete'; setTimeout(() => { b.dataset.arm = ''; b.textContent = 'Delete'; }, 4000); return; }
act(async () => { await api('/api/my/rotations/' + s.id, { remove: true }); SEL = null; history.replaceState(null, '', '#v'); }, 'Video Spin deleted'); });
box.querySelectorAll('[data-act]').forEach(b => b.addEventListener('click', () => { const a = b.dataset.act, p = '/api/my/rotations/' + s.id + '/dest/' + b.dataset.d;
act(() => api(p, a === 'remove' ? { remove: true } : { active: a === 'resume' }), a === 'remove' ? 'Video removed from this spin' : a === 'resume' ? 'Video resumed' : 'Video paused'); }));
const am = $('vsAddMine'); if (am) am.addEventListener('click', () => { const ids = [...box.querySelectorAll('.vsc input:checked')].map(x => x.value); if (!ids.length) { toast('Tick at least one video.', true); return; }
act(() => api('/api/my/videospins/' + s.id + '/add', { ids }), ids.length === 1 ? 'Video added' : ids.length + ' videos added'); });
const al = $('vsAddLink'); if (al) { const go = () => { const link = $('vsLinkIn').value.trim(); if (!link) { toast('Paste a Social Tube video link first.', true); return; } act(() => api('/api/my/videospins/' + s.id + '/add', { link }), 'Video added'); };
al.addEventListener('click', go); $('vsLinkIn').addEventListener('keydown', e => { if (e.key === 'Enter') go(); }); }
}
async function act(fn, done) { if (BUSY) return; BUSY = true; try { await fn(); if (done) toast(done); await load(true); } catch (e) { toast(e.message, true); } BUSY = false; }
window.VideoSpin = { reload: () => load(true) };
if (/^#v/.test(location.hash)) setTimeout(() => { const b = $('vsw').querySelector('button[data-v="videos"]'); if (b) b.click(); }, 400);
})();
+9
View File
@@ -0,0 +1,9 @@
// The Founder badge on a member's wall (2026-11-05, cosmetic). Kept apart from wall.js, which a shared policy test pins by version.
(async function () {
const img = document.getElementById('bioFounder'); if (!img) return;
const name = location.pathname.split('/').pop();
try {
const w = await (await fetch('/api/wall/' + encodeURIComponent(name))).json();
if (w && w.founder && w.founder.img) { img.src = w.founder.img; img.title = 'Founder badge: signed in before LinkSpin launched'; img.hidden = false; }
} catch (e) {}
})();
+8 -5
View File
@@ -17,9 +17,11 @@
title.innerHTML = safeName; title.innerHTML = safeName;
if (hostEl) hostEl.innerHTML = safeName; if (hostEl) hostEl.innerHTML = safeName;
IAP.$('bioHead').hidden = false; IAP.$('bioHead').hidden = false;
if (w.avatarUrl) { const av = IAP.$('bioAvatar'); av.src = w.avatarUrl; av.hidden = false; } // profile fields (avatar, bio, socials, intro video) are rendered only when the server says the member has bought (w.bought);
// a free member's wall shows the name, the line's ads and the join call, nothing from the profile (2026-10-30)
if (w.bought && w.avatarUrl) { const av = IAP.$('bioAvatar'); av.src = w.avatarUrl; av.hidden = false; }
if (w.badge) { const bb = IAP.$('bioBadge'); if (bb) { bb.src = w.badge.img; bb.title = w.badge.label + ' badge'; bb.hidden = false; } } if (w.badge) { const bb = IAP.$('bioBadge'); if (bb) { bb.src = w.badge.img; bb.title = w.badge.label + ' badge'; bb.hidden = false; } }
IAP.$('bioText').textContent = w.bio || 'Building a team on LinkSpin — join through this page and you\'re in my line.'; IAP.$('bioText').textContent = (w.bought && w.bio) || 'Building a team on LinkSpin. Join through this page and you are in my line.';
if (w.qrUrl) IAP.$('bioQr').src = w.qrUrl; if (w.qrUrl) IAP.$('bioQr').src = w.qrUrl;
// social links // social links
const SOC = { facebook: 'Facebook', twitter: 'X', youtube: 'YouTube', instagram: 'Instagram', tiktok: 'TikTok', telegram: 'Telegram', linkedin: 'LinkedIn', website: 'Website' }; const SOC = { facebook: 'Facebook', twitter: 'X', youtube: 'YouTube', instagram: 'Instagram', tiktok: 'TikTok', telegram: 'Telegram', linkedin: 'LinkedIn', website: 'Website' };
@@ -36,14 +38,15 @@
website: svg('<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.5 3 14.5 0 18M12 3c-3 3.5-3 14.5 0 18"/>') website: svg('<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.5 3 14.5 0 18M12 3c-3 3.5-3 14.5 0 18"/>')
}; };
const sc = IAP.$('bioSocials'); const sc = IAP.$('bioSocials');
if (sc && w.socials && typeof w.socials === 'object') { if (sc && w.bought && w.socials && typeof w.socials === 'object') {
// paid placement: Google wants these marked sponsored (plus ugc), never a plain dofollow (2026-10-30)
const links = Object.keys(SOC).filter(k => w.socials[k]).map(k => const links = Object.keys(SOC).filter(k => w.socials[k]).map(k =>
'<a href="' + String(w.socials[k]).replace(/"/g, '%22') + '" target="_blank" rel="noopener nofollow me">' + (ICON[k] || '') + '<span>' + SOC[k] + '</span></a>'); '<a href="' + String(w.socials[k]).replace(/"/g, '%22') + '" target="_blank" rel="sponsored ugc noopener">' + (ICON[k] || '') + '<span>' + SOC[k] + '</span></a>');
sc.innerHTML = links.join(''); sc.innerHTML = links.join('');
} }
// intro video under the bio: YouTube / Vimeo embed, or a direct file // intro video under the bio: YouTube / Vimeo embed, or a direct file
const bv = IAP.$('bioVideo'); const bv = IAP.$('bioVideo');
const vurl = w.socials && typeof w.socials === 'object' ? String(w.socials.video || '') : ''; const vurl = w.bought && w.socials && typeof w.socials === 'object' ? String(w.socials.video || '') : '';
if (bv && vurl) { if (bv && vurl) {
let yt = /(?:youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/)|youtu\.be\/)([A-Za-z0-9_-]{6,})/.exec(vurl); let yt = /(?:youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/)|youtu\.be\/)([A-Za-z0-9_-]{6,})/.exec(vurl);
let vm = /vimeo\.com\/(?:video\/)?(\d+)/.exec(vurl); let vm = /vimeo\.com\/(?:video\/)?(\d+)/.exec(vurl);
-13
View File
@@ -7,17 +7,4 @@
document.getElementById('gate').style.display = signedIn ? 'none' : 'block'; document.getElementById('gate').style.display = signedIn ? 'none' : 'block';
document.getElementById('body').style.display = signedIn ? 'block' : 'none'; document.getElementById('body').style.display = signedIn ? 'block' : 'none';
if (!signedIn) return; if (!signedIn) return;
// MoonPay: same signed link the Buy pane uses, prefilled with this member's wallet when one is linked
const mb = document.getElementById('wlMoonpay'), note = document.getElementById('wlMoonpayNote');
if (note && !me.address) note.textContent = 'Link your wallet first (Wallet tab) and MoonPay opens with your address already filled in. Without it you paste the address yourself.';
if (mb) mb.addEventListener('click', async () => {
let pol = 30;
try { const { products } = await (await fetch('/api/catalog')).json(); const p25 = (products || []).find(p => p.priceCents === 2500); if (p25 && p25.costWei) pol = Math.max(30, Math.ceil(Number(p25.costWei) / 1e18) + 3); } catch (e) {}
try {
const r = await (await fetch('/api/moonpay-url?pol=' + pol + (me.address ? '&address=' + encodeURIComponent(me.address) : ''))).json();
if (!r.url) throw new Error('no url');
window.open(r.url, '_blank', 'noopener');
IAP.status(r.signed ? 'MoonPay opened with your wallet address pre-filled. Choose the amount, pay, and the POL lands in your wallet.' : 'MoonPay opened. Choose POL on the Polygon network and paste your own wallet address as the destination.', 'ok');
} catch (e) { IAP.status('Could not open MoonPay. Try again in a minute.', 'bad'); }
});
})(); })();
Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

+6 -4
View File
@@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="light">
<head> <head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>The contract | LinkSpin</title> <title>The contract | LinkSpin</title>
@@ -16,9 +16,10 @@
<meta name="twitter:image" content="{{SITE_URL}}/banners/linkspin-og-1200x630.png"> <meta name="twitter:image" content="{{SITE_URL}}/banners/linkspin-og-1200x630.png">
<meta name="theme-color" content="#0B1424"> <meta name="theme-color" content="#0B1424">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png"> <link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/pub.css?v=20261007b"> <link rel="stylesheet" href="/assets/pub.css?v=20261118w">
<style> <style>
.rule{display:grid;grid-template-columns:150px minmax(0,1fr);gap:14px;padding:10px 0;border-bottom:1px solid var(--line);font-size:14px;color:var(--ink-2)} .rule{display:grid;grid-template-columns:150px minmax(0,1fr);gap:14px;padding:10px 0;border-bottom:1px solid var(--line);font-size:14px;color:var(--ink-2)}
.rule:last-child{border-bottom:0} .rule:last-child{border-bottom:0}
@@ -49,7 +50,7 @@
<h1 class="disp" style="margin:0;font-size:44px;line-height:1.04">The contract, in plain words</h1> <h1 class="disp" style="margin:0;font-size:44px;line-height:1.04">The contract, in plain words</h1>
<p style="font-size:16px">Every dollar on this platform moves through one smart contract on Polygon. It takes a package payment and splits it to real wallets in the same transaction. It has no balance to drain, no pause button, and no owner power over money. This page says what it does, with the source beside it. Verify every claim yourself. That is the point.</p> <p style="font-size:16px">Every dollar on this platform moves through one smart contract on Polygon. It takes a package payment and splits it to real wallets in the same transaction. It has no balance to drain, no pause button, and no owner power over money. This page says what it does, with the source beside it. Verify every claim yourself. That is the point.</p>
<div class="ctas"> <div class="ctas">
<span class="mono" id="cAddr" style="font-size:12px;padding:10px 12px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;color:#8CC8FF;overflow-wrap:anywhere">…</span> <span class="mono" id="cAddr" style="font-size:12px;padding:10px 12px;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;color:var(--chrome-hi);overflow-wrap:anywhere">…</span>
<span class="tag" id="cChain">…</span> <span class="tag" id="cChain">…</span>
</div> </div>
<div class="ctas"> <div class="ctas">
@@ -142,11 +143,12 @@
<a href="/support">Support</a> <a href="/support">Support</a>
<a href="/terms">Terms</a> <a href="/terms">Terms</a>
<a href="/privacy">Privacy</a> <a href="/privacy">Privacy</a>
<a href="/disclaimer">Disclaimer</a> <a href="/disclaimer">Earnings Disclaimer</a>
<span class="grow"></span> <span class="grow"></span>
<span class="mono" style="font-size:11px">Advertising services with a performance referral program. Not an investment. Crypto transactions are irreversible.</span> <span class="mono" style="font-size:11px">Advertising services with a performance referral program. Not an investment. Crypto transactions are irreversible.</span>
</div> </div>
</footer> </footer>
<script src="/assets/contract.js?v=20261023ov"></script> <script src="/assets/contract.js?v=20261023ov"></script>
<script src="/assets/netline.js?v=20261117nw" data-site="linkspin"></script>
</body> </body>
</html> </html>
+289
View File
@@ -0,0 +1,289 @@
<!doctype html>
<html lang="en" data-theme-base="light">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Conversion tracking: see which ad, link and page bring sign-ups | LinkSpin</title>
<meta name="description" content="How to set up the LinkSpin conversion pixel: create a goal under Conversions, put the landing tag on the page your ad or spin link points to and the goal pixel on your thank-you page, then read conversions and cost per goal by campaign, spin link, page and traffic source. Copy-paste examples for HTML, WordPress, page builders, Aweber and GetResponse.">
<link rel="canonical" href="{{SITE_URL}}/conversion-tracking">
<meta property="og:type" content="website"><meta property="og:site_name" content="LinkSpin">
<meta property="og:url" content="{{SITE_URL}}/conversion-tracking">
<meta property="og:title" content="Conversion tracking: see which ad, link and page bring sign-ups">
<meta property="og:description" content="Clicks tell you who looked. The LinkSpin conversion pixel tells you which ad, spin link, page and traffic source brought a subscriber or a sale. Free for every member. Set it up in four steps.">
<meta name="twitter:card" content="summary">
<meta name="theme-color" content="#0B1424">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/pub.css?v=20261118w">
<style>
.rg{max-width:980px}
.rg p{margin:0}
.pb{padding:14px 16px}
.rg-two{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,400px),1fr));gap:12px}
.rg-two .tile{display:grid;gap:4px;padding:12px 14px;font-size:14.5px;align-content:start;min-width:0}
.rg-two .tile span{color:var(--ink-2)}
/* the flow: across on a wide screen, down on a phone */
.cg-flow{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:26px}
.cg-flow li{position:relative;border:1px solid var(--line-strong);border-radius:8px;padding:10px 12px;font-size:13.5px;line-height:1.45;background:var(--panel);color:var(--ink-2);min-width:0}
.cg-flow li b{display:block;font-weight:800;color:var(--ink);margin-bottom:3px}
.cg-flow li .k{display:inline-grid;place-items:center;width:24px;height:24px;border-radius:50%;font:700 12px var(--mono);margin-bottom:6px;background:var(--chrome);color:var(--chrome-ink)}
.cg-flow li code{font:500 12px var(--mono);color:var(--accent-hi);overflow-wrap:anywhere}
.cg-flow li.f-ad{border-color:var(--accent);background:var(--accent-soft)}
.cg-flow li.f-tag{border-color:var(--ok);background:var(--ok-soft)}
.cg-flow li.f-px{border-color:var(--sig);background:var(--sig-soft)}
.cg-flow li.f-win{border-color:var(--ok);background:var(--ok-soft)}
.cg-flow li:not(:last-child)::after{content:"";position:absolute;right:-20px;top:50%;margin-top:-7px;border:7px solid transparent;border-left:9px solid var(--line-strong);border-right:0}
@media (max-width:820px){
.cg-flow{grid-template-columns:1fr;gap:24px}
.cg-flow li:not(:last-child)::after{right:auto;left:22px;top:auto;bottom:-19px;margin-top:0;border:7px solid transparent;border-top:9px solid var(--line-strong);border-bottom:0}
}
/* member route */
.rg-route{list-style:none;counter-reset:s;margin:0;padding:0;display:grid;gap:12px}
.rg-route > li{counter-increment:s;display:grid;grid-template-columns:40px minmax(0,1fr);gap:14px;align-items:start;padding:12px 0;border-bottom:1px solid var(--line)}
.rg-route > li:last-child{border-bottom:0}
.rg-route > li::before{content:counter(s);font:700 20px var(--display);width:40px;height:40px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(180deg,#FF7A32,var(--sig));color:var(--sig-ink)}
.rg-route > li > div{min-width:0;display:grid;gap:8px}
.rg-route h3{font:700 17px var(--display);letter-spacing:.04em;text-transform:uppercase;margin:0;color:var(--ink)}
.rg-route p{font-size:14px;color:var(--ink-2)}
.rg-where{display:flex;flex-wrap:wrap;gap:6px}
.rg-chip{font:700 11.5px var(--body);padding:3px 10px;border-radius:999px;background:var(--accent-soft);color:var(--accent-hi);border:1px solid var(--accent-dim)}
.rg-chip.iap{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-line)}
/* code */
.cg-code{border:1px solid var(--chrome-line);border-radius:8px;background:var(--inset);padding:10px 12px;min-width:0}
.cg-code pre{margin:0;font:500 12.5px/1.6 var(--mono);color:var(--chrome-ink);white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}
.cg-lbl{display:flex;justify-content:space-between;align-items:center;gap:8px;font:700 10.5px var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--chrome-sub);margin:0 0 6px}
.cg-copy{font:700 12px var(--body);background:transparent;color:var(--chrome-ink);border:1px solid var(--chrome-sub);border-radius:6px;padding:2px 10px;cursor:pointer}
.cg-copy:hover{background:var(--chrome-2)}
.cg-ph{color:var(--chrome-warm);font-weight:700}
.rg code.i{font:500 13px var(--mono);color:var(--accent-hi);background:var(--accent-soft);padding:1px 5px;border-radius:4px;overflow-wrap:anywhere}
.cg-ex{display:grid;gap:8px}
.cg-ex p,.cg-ex li{font-size:14px;color:var(--ink-2)}
.cg-ex ol,.cg-ex ul{margin:0;padding-left:20px;display:grid;gap:5px}
.cg-warn{border-left:4px solid var(--sig);background:var(--sig-soft);padding:10px 14px;border-radius:0 8px 8px 0;font-size:14px;color:var(--ink-2)}
/* numbers */
.rg-tbl table{width:100%;border-collapse:collapse;font-size:14px;table-layout:fixed}
.rg-tbl th,.rg-tbl td{padding:9px 14px;text-align:left;border-bottom:1px solid var(--line);vertical-align:top;overflow-wrap:anywhere}
.rg-tbl th{font:700 10.5px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.rg-tbl td:first-child{width:32%;font-weight:700}
.rg-tbl tr:last-child td{border-bottom:0}
.cg-check{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.cg-check li{position:relative;padding:10px 12px 10px 40px;border:1px solid var(--line);border-radius:8px;background:var(--panel-2);font-size:14px;color:var(--ink-2)}
.cg-check li::before{content:"";position:absolute;left:12px;top:12px;width:16px;height:16px;border-radius:4px;border:2px solid var(--accent)}
.cg-check li b{color:var(--ink)}
.rg-faq{display:grid;gap:14px;margin:0}
.rg-faq dt{font-weight:800;color:var(--ink)}
.rg-faq dd{margin:4px 0 0;color:var(--ink-2);font-size:14px}
@media (max-width:640px){.rg h1{font-size:34px!important}.rg-route > li{grid-template-columns:34px minmax(0,1fr);gap:10px}.rg-route > li::before{width:34px;height:34px;font-size:17px}.rg-tbl th,.rg-tbl td{padding:8px 10px}}
</style>
</head>
<body>
<header class="top">
<div class="wrap">
<a class="brand" href="/" aria-label="LinkSpin home"><span class="mark"></span><span class="word">Link<b>Spin</b></span></a>
<span class="eyebrow" style="color:var(--chrome-sub);padding-left:14px;border-left:1px solid var(--chrome-line)">Conversion tracking</span>
<span class="grow"></span>
<a href="/conversions" class="btn ghost">Open Conversions</a>
<a href="/join" class="btn pri">Start free</a>
</div>
</header>
<main class="sec" style="padding-top:44px">
<div class="wrap rg" style="display:grid;gap:22px">
<div class="text" style="display:grid;gap:12px">
<span class="eyebrow">LinkSpin + InstantAdPay · free for every member</span>
<h1 class="disp" style="margin:0;font-size:44px;line-height:1.04">Conversion tracking: see which ad, link and page bring sign-ups</h1>
<p style="font-size:16px;color:var(--ink-2)">Clicks tell you who looked. The conversion pixel tells you which ad, which spin link, which page and which traffic source brought a subscriber or a sale, and what each one cost you in credits. You paste two small tags on your own site, one time. After that, Conversions in your Control Room counts every goal against the click that sent it.</p>
<div class="ctas"><a class="btn pri" href="/conversions">Open Conversions</a><a class="btn blue" href="/join">Not a member yet? Start free</a></div>
</div>
<video src="https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/conversion-tracking-ls.mp4?v=20261026" poster="https://coolify-saasytop.nyc3.digitaloceanspaces.com/training/conversion-tracking-ls.jpg?v=20261026" controls playsinline preload="metadata" width="1200" height="675" style="display:block;width:100%;height:auto;max-width:860px;background:#000;border-radius:16px;border:1px solid var(--line);margin:0 auto" aria-label="Video: Marty walks through setting up conversion tracking, about 3 minutes"></video>
<div class="panel">
<div class="ph"><h2>Why track conversions</h2><span class="meta">why it matters</span></div>
<div class="pb" style="display:grid;gap:12px">
<div class="rg-two">
<div class="tile"><b>Clicks are not sign-ups</b><span>One banner can get lots of clicks from people who never sign up. Another gets fewer clicks and brings you subscribers. Without tracking, both look the same, or the wrong one looks better.</span></div>
<div class="tile"><b>Find the winner</b><span>Every goal is counted against the click that sent the visitor, so you see which ad campaign, spin link, destination page and traffic source produced it.</span></div>
<div class="tile"><b>A cost per goal, in credits</b><span>Each ad campaign shows its goals, its rate and what each goal cost: the credits the campaign has spent, divided by its goals. Lower is better.</span></div>
<div class="tile"><b>Put next month's fuel behind it</b><span>This is the "your numbers get useful" part of <a href="/refuel">Fuel Your Offers</a>. Run your traffic all month, let the goals come in, then put next month's refuel behind the ad, link and page that convert, instead of guessing. Your goals also feed the goals dial in the Engine Room.</span></div>
</div>
</div>
</div>
<div class="panel">
<div class="ph"><h2>How a conversion gets counted</h2><span class="meta">the flow</span></div>
<div class="pb" style="display:grid;gap:12px">
<ol class="cg-flow" aria-label="How a conversion gets counted, step by step">
<li class="f-ad"><span class="k">1</span><b>Someone clicks</b>Your ad or your spin link. The click gets a random id, added to your page's address as <code>?lsclk=…</code></li>
<li class="f-tag"><span class="k">2</span><b>They land on your page</b>The landing tag keeps that id on your own site for 30 days.</li>
<li><span class="k">3</span><b>They sign up or buy</b>Through your form or your checkout. Nothing changes for them.</li>
<li class="f-px"><span class="k">4</span><b>Your thank-you page loads</b>The goal pixel there reads the kept id and sends it to LinkSpin.</li>
<li class="f-win"><span class="k">5</span><b>Counted in Conversions</b>Against the ad, spin link, page and source that sent them, with cost per goal.</li>
</ol>
<p class="muted" style="font-size:13px">The id is random. It identifies the click, not the person. Nothing personal is read from your page or sent anywhere. An ad click and the spin-link click it led to count as one click.</p>
<p class="muted" style="font-size:13px"><b>Sending people to LinkSpin or InstantAdPay?</b> Those two count by themselves, with no goal and no pixel. The landing tag adds the click id to your links to either site, also when the address sits inside a redirect link of your own. A spin link or Banner Spin pointed straight at either site carries it too. Then their sign-up, wallet link and each package they buy within 30 days of the click show in <a href="/reports">Reports</a> under Conversions, purchases with their USD price. This is reporting only. It never changes who a sponsor is or what anyone is paid.</p>
</div>
</div>
<div class="panel">
<div class="ph"><h2>Set it up in four steps</h2><span class="meta">one time</span></div>
<div class="pb">
<ol class="rg-route">
<li><div>
<h3>Create a goal</h3>
<p>Open <b>Conversions</b> in your Control Room and press <b>Add a goal</b>. Name it with one word for what you count: <b>subscriber</b>, <b>sale</b>, <b>signup</b> (letters, numbers, - or _, up to 32). The default value is optional, in US dollars, used when the pixel carries none. Up to 20 goals per account.</p>
<p>Each goal gets its own pixel id: <b>px</b> plus 10 letters and numbers. It is public and safe to paste: it can only count clicks that are yours. Once you have a goal, your spin links and Banner Spins add the click id to your destinations automatically.</p>
<div class="rg-where"><span class="rg-chip">LinkSpin: Control Room, Conversions</span><span class="rg-chip iap">InstantAdPay: Campaigns, Conversion tracking</span></div>
</div></li>
<li><div>
<h3>Landing tag on the page your traffic lands on</h3>
<p>Under <b>Snippets for</b>, pick your goal and copy <b>1. Landing tag</b>. Paste it once on your landing page (the address your ad or spin link sends people to), just before <code class="i">&lt;/body&gt;</code>. It keeps the click id on your site for 30 days, fills hidden form fields named <code class="i">lsclk</code>, and adds the id to links that stay on your site.</p>
<div class="cg-code"><div class="cg-lbl"><span>1. Landing tag</span><button class="cg-copy" type="button" data-copy>Copy</button></div><pre>&lt;script async src="https://linkspin.app/t.js?px=<span class="cg-ph">YOUR_PIXEL_ID</span>"&gt;&lt;/script&gt;</pre></div>
<p>It is fine on every page of your site (in a site-wide footer). It never slows or breaks the page, even if LinkSpin cannot be reached, and it works inside traffic-exchange frames.</p>
</div></li>
<li><div>
<h3>Goal pixel on your thank-you page</h3>
<p>Copy the goal pixel and paste it on the page people see only after they sign up or buy. Use the script version (<b>2b</b>) wherever your page allows scripts: it reads the id the landing tag kept, the surest match. Use the image version (<b>2</b>) where scripts are not allowed.</p>
<div class="cg-code"><div class="cg-lbl"><span>2b. Goal pixel, script (surest)</span><button class="cg-copy" type="button" data-copy>Copy</button></div><pre>&lt;script async src="https://linkspin.app/cv.js?px=<span class="cg-ph">YOUR_PIXEL_ID</span>&amp;goal=<span class="cg-ph">subscriber</span>"&gt;&lt;/script&gt;</pre></div>
<div class="cg-code"><div class="cg-lbl"><span>2. Goal pixel, image</span><button class="cg-copy" type="button" data-copy>Copy</button></div><pre>&lt;img src="https://linkspin.app/cv.gif?px=<span class="cg-ph">YOUR_PIXEL_ID</span>&amp;goal=<span class="cg-ph">subscriber</span>" width="1" height="1" alt="" style="display:none"&gt;</pre></div>
<p>Recording what a sale was worth? Add <code class="i">&amp;value=19.95</code> to the pixel address. Without it, the goal's default value is used.</p>
<div class="cg-warn"><b>Only on the thank-you page.</b> Never put the goal pixel on your landing page. Everyone who lands would count as a goal.</div>
</div></li>
<li><div>
<h3>Send a test conversion</h3>
<p>Press <b>Send a test conversion</b> next to the snippets. It loads your real pixel, is recorded apart and never counted, and the goal row shows when the last test arrived. That proves your pixel id works.</p>
<p>To check the pixel on your real thank-you page, add <code class="i">&amp;test=1</code> to the end of the pixel address, open your thank-you page once, then reload Conversions: the last test time updates. Take <code class="i">&amp;test=1</code> back out afterwards. Last, open your own spin link, Banner Spin click link or ad and look at the address bar on your landing page: you should see <code class="i">lsclk=</code> in it. That click is yours, so anything you finish after it is kept as a test, never counted.</p>
</div></li>
</ol>
</div>
</div>
<div class="panel">
<div class="ph"><h2>Where the code goes, by platform</h2><span class="meta">copy and paste</span></div>
<div class="pb" style="display:grid;gap:18px">
<p class="muted" style="font-size:13.5px">In every example, replace <span class="mono" style="color:var(--sig-2);font-weight:700">YOUR_PIXEL_ID</span> with your goal's pixel id and <span class="mono" style="color:var(--sig-2);font-weight:700">subscriber</span> with your goal's name. The snippets on your Conversions screen come with both filled in.</p>
<div class="cg-ex">
<h3 style="margin:0">A plain HTML page</h3>
<p>Landing page: the landing tag right before the closing body tag.</p>
<div class="cg-code"><div class="cg-lbl"><span>landing.html</span><button class="cg-copy" type="button" data-copy>Copy</button></div><pre> ...your page...
&lt;script async src="https://linkspin.app/t.js?px=<span class="cg-ph">YOUR_PIXEL_ID</span>"&gt;&lt;/script&gt;
&lt;/body&gt;</pre></div>
<p>Thank-you page: the goal pixel.</p>
<div class="cg-code"><div class="cg-lbl"><span>thank-you.html</span><button class="cg-copy" type="button" data-copy>Copy</button></div><pre> ...your thank-you message...
&lt;script async src="https://linkspin.app/cv.js?px=<span class="cg-ph">YOUR_PIXEL_ID</span>&amp;goal=<span class="cg-ph">subscriber</span>"&gt;&lt;/script&gt;
&lt;/body&gt;</pre></div>
<p>Your own form on the landing page? Add a hidden field and the landing tag fills it with the click id, so your own system can keep it with the lead:</p>
<div class="cg-code"><div class="cg-lbl"><span>hidden field</span><button class="cg-copy" type="button" data-copy>Copy</button></div><pre>&lt;input type="hidden" name="lsclk" value=""&gt;</pre></div>
</div>
<div class="cg-ex">
<h3 style="margin:0">WordPress</h3>
<ol>
<li><b>Landing tag, site-wide:</b> with a header and footer plugin (WPCode, for example), paste the landing tag into the <b>footer</b> box and save. It now runs on every page, landing page included.</li>
<li><b>Goal pixel, thank-you page only:</b> edit your thank-you page, add a <b>Custom HTML</b> block, paste the goal pixel into it and update the page. Do not put the goal pixel in the site-wide footer.</li>
<li>If your WordPress plan or theme strips scripts out of blocks (some hosted plans do), use the image version of the goal pixel in the Custom HTML block.</li>
</ol>
</div>
<div class="cg-ex">
<h3 style="margin:0">Funnel and page builders</h3>
<p>Most builders that allow custom code give you one of two places, and either works:</p>
<ul>
<li>A <b>tracking code</b> or <b>footer code</b> box in the page or funnel settings. Landing tag in the landing page's box, goal pixel in the thank-you page's box.</li>
<li>A <b>custom HTML</b> or <b>code</b> element you drop onto the page. One on each page with the matching line.</li>
</ul>
<p>If a page only accepts images and no scripts, use the image version of the goal pixel there. Keep the landing page and the thank-you page on the same domain.</p>
</div>
<div class="cg-ex">
<h3 style="margin:0">Autoresponders: Aweber, GetResponse and others</h3>
<p>If your list provider shows its own thank-you page after someone subscribes, you cannot paste the pixel there. Point the provider at a thank-you page on <b>your</b> site instead, and put the goal pixel on that page.</p>
<ul>
<li><b>Aweber:</b> open your sign-up form's settings, set <b>Thank You Page</b> to a custom page, and paste your own page's address.</li>
<li><b>GetResponse:</b> in the form or landing page settings, set the <b>thank-you page</b> to a custom URL, and paste your own page's address.</li>
<li><b>Any other provider:</b> look for "thank-you page", "success page" or "redirect after sign-up" and give it your own page's address.</li>
</ul>
<p>Your own thank-you page needs only your message and the goal pixel. Keep the form on your landing page (where the landing tag runs) and use the same domain for both pages.</p>
</div>
<div class="cg-ex">
<h3 style="margin:0">What if I can't put code on the thank-you page?</h3>
<p>Best fix: send people to a thank-you page you control, as above. If that is not possible:</p>
<ul>
<li><b>The pixel can go on the thank-you page, but it is on another domain, or only images are allowed.</b> Use the image version. It cannot read the id your landing tag kept, so it counts through LinkSpin's cookie or the 24-hour match (the same network and browser within a day of the click). Both work, just less surely, and Conversions labels them so you can tell. Keep the landing tag on your landing page: it is what sets up both of these for spin-link clicks.</li>
<li><b>No code of any kind after the sign-up.</b> Then nothing can tell LinkSpin the sign-up happened. You can still keep the click id with each lead through the hidden <code class="i">lsclk</code> field, if your provider stores custom fields.</li>
<li><b>Your page signs people up without leaving the page</b> (a pop-up form). With the landing tag on that page, your page's own code can count the goal with one line after a successful sign-up: <code class="i">if (window.LinkSpin) LinkSpin.goal('YOUR_PIXEL_ID', 'subscriber');</code></li>
<li><b>A tracker or traffic network wants the conversion too.</b> Set a postback to the event <code class="i">goal</code> on <a href="/links">Links</a> or on a <a href="/sources">traffic source</a>. It fires for every counted goal, with <code class="i">{event}</code> set to the goal's name.</li>
</ul>
</div>
</div>
</div>
<div class="panel rg-tbl">
<div class="ph"><h2>How to read Conversions</h2><span class="meta">your numbers</span></div>
<table>
<thead><tr><th>You see</th><th>What it means</th></tr></thead>
<tbody>
<tr><td>Counted</td><td>Goals counted in the range you picked (7, 30 or 90 days), tests and your own clicks (ads, spin links, Banner Spins) left out.</td></tr>
<tr><td>Cost / goal</td><td>The credits the ad campaign has spent so far, divided by its goals of this goal type, in that site's ad credits. Clicks and goals follow the range; spend is the campaign's total, so on an older campaign the figure reads high.</td></tr>
<tr><td>Rate</td><td>Goals divided by the campaign's tracked clicks in the range.</td></tr>
<tr><td>Address</td><td>Surest. The thank-you page's own address still carried the click id.</td></tr>
<tr><td>Kept</td><td>Exact. The landing tag kept the click id on your site and the goal pixel read it back.</td></tr>
<tr><td>Cookie</td><td>Exact, through LinkSpin's own cookie. Some browsers block it.</td></tr>
<tr><td>24 h match</td><td>The same network and browser within a day of the click. A good guess, not proof.</td></tr>
<tr><td>Test / last test</td><td>When your last test conversion arrived. Tests are recorded apart and never counted.</td></tr>
<tr><td>Joins, wallets, purchases</td><td>In Reports, under Conversions, beside your goals. People who came through your click and signed up, linked a wallet or bought a package on LinkSpin or InstantAdPay. A sign-up and a wallet count once per click, every package counts on its own with its USD price, all within 30 days of the click. Your own account is left out.</td></tr>
</tbody>
</table>
<div class="pb" style="border-top:1px solid var(--line)"><p class="muted" style="font-size:13px">Each goal gets its own report: by ad campaign (LinkSpin and InstantAdPay), by spin link, by Banner Spin, by destination page and by traffic source (a source you named under Sources, or else the referring site or ad placement). Press CSV for every conversion with its time in Central time, goal, value, match method, campaign, spin link, page, source, country and device. The counting rules: each goal counts once per click, only within 30 days of a real click, and only for clicks on your own ads, links and Banner Spins. Your own clicks on any of them (made while signed in, or from a browser you sign in from) are kept as tests: the note at the top of "How sure is each count" says how many.</p></div>
</div>
<div class="panel">
<div class="ph"><h2>Troubleshooting checklist</h2><span class="meta">not counting?</span></div>
<div class="pb">
<ul class="cg-check">
<li><b>Is the pixel id right?</b> It is <code class="i">px</code> plus 10 letters and numbers, copied from Snippets. A removed goal's pixel stops counting.</li>
<li><b>Did the test arrive?</b> Press Send a test conversion. If the last test time updates, the goal is live. If the <code class="i">&amp;test=1</code> check on your real page does not update it, the pixel is not on that page or the page strips it.</li>
<li><b>Does the click id reach your page?</b> Open your own spin link, Banner Spin or ad: your landing page's address should show <code class="i">lsclk=</code>. If it does not, something between the click and your page (another redirect or a link shortener) is dropping it. Point the link straight at the page with the landing tag.</li>
<li><b>Banner Spin straight to a page?</b> That works too. Once you have a goal, a Banner Spin banner that points straight at a page adds its own click id (<code class="i">lsclk=</code>) to the page address, and its goals show under By Banner Spin. A banner that points at one of your spin links is counted under that spin link.</li>
<li><b>Is the landing tag on the page the click lands on?</b> Exactly that address, not another page of your site.</li>
<li><b>Same domain for both pages?</b> The landing tag keeps the id on one domain. If the landing page is on <code class="i">www.yoursite.com</code> and the thank-you page on <code class="i">yoursite.com</code> (or another site), the script pixel cannot read it and only the cookie or 24-hour match is left.</li>
<li><b>Goal pixel only on the thank-you page?</b> Not in a site-wide footer, not on the landing page.</li>
<li><b>Scripts stripped?</b> Some builders and hosted blogs remove scripts. Use the image version of the goal pixel there.</li>
<li><b>Testing with your own clicks?</b> Your own clicks on your own ads, spin links and Banner Spins are kept as tests and never show in the counts, whether you are signed in or not on that browser (LinkSpin knows the browsers you sign in from). Use Send a test conversion and the <code class="i">&amp;test=1</code> check above to test.</li>
<li><b>Older than 30 days, or the same click twice?</b> A sign-up more than 30 days after the click does not count, and each click counts once per goal.</li>
</ul>
</div>
</div>
<div class="panel">
<div class="ph"><h2>Questions members ask</h2><span class="meta">quick answers</span></div>
<div class="pb">
<dl class="rg-faq">
<div><dt>Does it cost anything?</dt><dd>No. The conversion pixel is free for every member and uses no credits.</dd></div>
<div><dt>Will the tags slow down or break my page?</dt><dd>No. Both load in the background, never stop your page from showing and do nothing visible. If LinkSpin cannot be reached, your page works exactly as before.</dd></div>
<div><dt>Do I need a separate goal for each link or ad?</dt><dd>No. One goal covers every ad and spin link you own. Each conversion is counted against whichever click sent that visitor.</dd></div>
<div><dt>I advertise on InstantAdPay too. Do I set it up twice?</dt><dd>No. Your InstantAdPay goals are these same goals, held on your LinkSpin account under the same email. One landing tag and one goal pixel count clicks from both sites.</dd></div>
<div><dt>Is any personal data sent?</dt><dd>No. The click id is random. No name or email from your page is read or sent. When someone joins InstantAdPay on your click, the two sites match the event to your click server to server, and your reports show counts and values, never who the person is.</dd></div>
<div><dt>Why does a sign-up I sent not show?</dt><dd>The click has to reach the join page. Check that your landing tag is on the page and the link is a real link (a button that only runs a script cannot carry it), and that the visitor opened it from your click within the last 30 days. People who joined before this was switched on on 2026-11-07 cannot be matched afterwards.</dd></div>
</dl>
</div>
</div>
<p class="muted" style="font-size:12.5px">One credit is one cent of ad delivery. Credits are not money and cannot be withdrawn. Conversion tracking shows what your own ads and pages produce; it does not promise any number of sign-ups or sales. No income is guaranteed; any commissions depend on real purchases in your line and on your own effort. Cryptocurrency involves risk of loss. (<a href="https://instantadpay.com/conversion-tracking">The InstantAdPay side</a>.)</p>
</div>
</main>
<footer class="foot">
<div class="wrap">
<span class="word">Link<b>Spin</b></span>
<a href="/">Home</a>
<a href="/refuel">Fuel Your Offers</a>
<a href="/support">Support</a>
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/disclaimer">Earnings Disclaimer</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">Advertising services with a performance referral program. Not an investment. Crypto transactions are irreversible.</span>
</div>
</footer>
<script src="/assets/conversion-guide.js?v=20261024ct"></script>
<script src="/assets/netline.js?v=20261117nw" data-site="linkspin"></script>
</body>
</html>
+76
View File
@@ -0,0 +1,76 @@
<!doctype html>
<html lang="en" data-theme-base="light">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow">
<title>Conversions · LinkSpin</title>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20261114tu">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;align-items:start}
.panel{align-content:start}
.range{display:flex;border:1px solid var(--line-strong);border-radius:var(--r);overflow:hidden;background:var(--panel-2)} .range button{background:transparent;border:0;color:var(--muted);font-family:var(--mono);font-size:12px;padding:5px 10px;cursor:pointer} .range button.on{background:var(--ink);color:var(--on-ink)}
.goals .hd,.goals .rw{grid-template-columns:minmax(0,1fr) 120px 70px 90px 150px;gap:8px;align-items:center}
.camps .hd,.camps .rw{grid-template-columns:minmax(0,1fr) 92px 60px 56px 60px 90px;gap:8px}
.lst .hd,.lst .rw{grid-template-columns:minmax(0,1fr) 60px;gap:8px}
.meth{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.meth .m{background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:8px 10px;display:grid;gap:2px}
.meth .m .k{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)} .meth .m .v{font-family:var(--display);font-weight:700;font-size:20px}
.snip{display:grid;gap:6px;margin-top:10px} .snip .code{display:block;font-size:12px;line-height:1.6;padding:10px 12px;overflow-wrap:anywhere;white-space:pre-wrap}
.steps{margin:6px 0 0;padding-left:20px;display:grid;gap:6px}
.gsel{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.pill{font-family:var(--mono);font-size:11px;padding:1px 7px;border-radius:3px;background:var(--panel-2);border:1px solid var(--line)}
@media (max-width:900px){.two{grid-template-columns:1fr}.body{padding:12px 16px}.goals .hd{display:none}.goals .rw{grid-template-columns:minmax(0,1fr) auto;row-gap:4px}.camps .hd,.camps .rw{grid-template-columns:minmax(0,1fr) 60px 44px 44px 64px;font-size:12px}.camps .hd span:nth-child(2),.camps .rw span:nth-child(2){display:none}.meth{grid-template-columns:repeat(2,minmax(0,1fr))}}
</style>
</head>
<body>
<div id="page">
<div class="body">
<div class="panel">
<div class="ph" style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px"><h2>Your goals</h2><button class="btn pri" type="button" id="addGoal">Add a goal</button></div>
<div class="muted" style="margin:4px 0 10px">A goal is something you want counted: a subscriber, a sale, a sign-up. Each goal has its own pixel id. The id is public and safe to paste: it can only count clicks that are yours.</div>
<div class="tbl goals"><div class="hd"><span>Goal</span><span>Pixel id</span><span class="r">Value</span><span class="r">Counted</span><span></span></div><div id="goalRows"></div></div>
</div>
<div class="two">
<div class="panel">
<h2>Set it up in 3 steps</h2>
<div class="muted" style="margin:2px 0 6px">Goals show here with their cost. <a href="/reports">Reports</a> shows everything in one list: goals, plus joins, wallets and purchases on LinkSpin and InstantAdPay.</div>
<div style="margin:2px 0 6px"><a href="/conversion-tracking" target="_blank" rel="noopener">How to set it up: the step-by-step guide with copy-paste examples (WordPress, page builders, Aweber, GetResponse)</a></div>
<ol class="steps">
<li><b>Landing page:</b> paste the landing tag once, before &lt;/body&gt;. It keeps the click id on your own site for 30 days.</li>
<li><b>Thank-you page:</b> paste the goal pixel for the goal (the image works anywhere; the script version is surer).</li>
<li><b>Test it:</b> press <b>Send a test conversion</b> below. To check your real thank-you page, add <span class="mono">&amp;test=1</span> to its pixel, open the page once, and the last test time updates (take it back out afterwards). Your own clicks on your ads, spin links and Banner Spins are kept as tests and never counted, so finishing your own form proves nothing in the counts.</li>
</ol>
<div class="gsel" style="margin-top:12px"><span class="muted">Snippets for</span><select class="field" id="goalPick" style="width:auto;min-width:160px"></select><button class="btn" type="button" id="testBtn">Send a test conversion</button><span class="muted" id="testNote"></span></div>
<div class="snip"><span class="sec">1. Landing tag</span><code class="code mono" id="snTag"></code><div><button class="btn sm" type="button" data-copy="snTag">Copy</button></div></div>
<div class="snip"><span class="sec">2. Goal pixel (image)</span><code class="code mono" id="snImg"></code><div><button class="btn sm" type="button" data-copy="snImg">Copy</button></div></div>
<div class="snip"><span class="sec">2b. Goal pixel (script, reads what the landing tag kept)</span><code class="code mono" id="snJs"></code><div><button class="btn sm" type="button" data-copy="snJs">Copy</button></div></div>
<div class="muted" style="margin-top:8px">Add <span class="mono">&amp;value=19.95</span> to the pixel to record what the sale was worth. Without it, the goal's default value is used.</div>
</div>
<div class="panel">
<h2>Autoresponders and hosted thank-you pages</h2>
<div class="ink2" style="display:grid;gap:8px">
<p style="margin:0">If your list provider shows its own thank-you page, you cannot paste the pixel there. Point the provider at a page on <b>your</b> site instead, and put the pixel on that page.</p>
<p style="margin:0"><b>Aweber:</b> open your sign-up form, go to its settings, set <b>Thank You Page</b> to a custom page and paste your page's address.</p>
<p style="margin:0"><b>GetResponse:</b> in the form or landing page settings, set the <b>thank-you page</b> to a custom URL and paste your page's address.</p>
<p style="margin:0">If you cannot change it, the pixel can still count through LinkSpin's cookie or the 24-hour match, just less surely.</p>
<p style="margin:0"><b>Forms on your own page:</b> add a hidden field named <span class="mono">lsclk</span> and the landing tag fills it with the click id, so your own system can pass it on.</p>
<p style="margin:0"><b>Postbacks:</b> a postback set to the event <span class="mono">goal</span> (on <a href="/links">Links</a> or a <a href="/sources">traffic source</a>) fires for every goal, with <span class="mono">{event}</span> = the goal's name.</p>
</div>
</div>
</div>
<div class="panel">
<div class="ph" style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px"><h2>How sure is each count</h2><span class="muted" id="totalNote"></span></div>
<div class="meth" id="methRows"></div>
<div class="muted" style="margin-top:8px"><b>Address</b>: the click id was on the thank-you page's address. <b>Kept</b>: the landing tag kept it on your site. Both are exact. <b>Cookie</b>: LinkSpin's own cookie, exact but some browsers block it. <b>24 h match</b>: same network and browser within a day of the click, a good guess, not proof. Each goal counts once per click, only within 30 days of the click, and only for clicks on your own ads and links.</div>
</div>
<div id="goalReports"></div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261115hub"></script>
<script src="/assets/conversions.js?v=20261026a"></script>
</body>
</html>
+11 -9
View File
@@ -1,19 +1,20 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="light">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
<title>Credits · LinkSpin</title> <title>Credits · LinkSpin</title>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20261020s"> <link rel="stylesheet" href="/assets/cr.css?v=20261114tu">
<style> <style>
.body{padding:16px 24px;display:grid;gap:16px} .body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:16px;align-items:start} .two{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:16px;align-items:start}
.pkgs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} .pkgs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.pk{border:1px solid var(--line);border-radius:8px;padding:12px 12px 10px;background:#FFF;display:flex;flex-direction:column;gap:4px;cursor:pointer;text-align:left;font:inherit;color:inherit;min-height:44px;box-shadow:var(--sh)} .pk{border:1px solid var(--line);border-radius:8px;padding:12px 12px 10px;background:var(--panel);display:flex;flex-direction:column;gap:4px;cursor:pointer;text-align:left;font:inherit;color:inherit;min-height:44px;box-shadow:var(--sh)}
.pk:hover{border-color:var(--accent)} .pk:hover{border-color:var(--accent)}
.pk.on{border-color:var(--sig);box-shadow:0 0 0 3px rgba(255,106,26,.18);background:linear-gradient(180deg,#FFFFFF,var(--hi-row))} .pk.on{border-color:var(--sig);box-shadow:0 0 0 3px color-mix(in srgb,var(--sig) 18%,transparent);background:linear-gradient(180deg,var(--panel),var(--hi-row))}
.pk .k{font:700 10px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted)} .pk .k{font:700 10px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.pk.on .k{color:var(--sig-2)} .pk.on .k{color:var(--sig-2)}
.pk .price{font-family:var(--display);font-weight:700;font-size:28px;line-height:1;letter-spacing:.02em} .pk .price{font-family:var(--display);font-weight:700;font-size:28px;line-height:1;letter-spacing:.02em}
@@ -34,7 +35,7 @@
<div class="tiles" id="tiles"></div> <div class="tiles" id="tiles"></div>
<div class="two"> <div class="two">
<div style="display:grid;gap:16px;align-content:start"> <div style="display:grid;gap:16px;align-content:start">
<div class="panel" style="padding:0"> <div class="panel" id="buyPanel" style="padding:0">
<div class="ph"><h3>Buy a package</h3><span class="meta" id="buyMeta">priced in dollars · settled in POL at the live rate · one transaction</span></div> <div class="ph"><h3>Buy a package</h3><span class="meta" id="buyMeta">priced in dollars · settled in POL at the live rate · one transaction</span></div>
<div style="padding:14px 16px 16px;display:grid;gap:14px"> <div style="padding:14px 16px 16px;display:grid;gap:14px">
<div class="pkgs" id="pkgs"><div class="muted">loading packages…</div></div> <div class="pkgs" id="pkgs"><div class="muted">loading packages…</div></div>
@@ -45,7 +46,6 @@
<div class="acts" id="fromWrap" hidden><label class="lbl" style="min-width:min(100%,320px)">Buy from<select class="field" id="buyFrom"></select></label><span class="muted" style="font-size:12px" id="fromHint"></span></div> <div class="acts" id="fromWrap" hidden><label class="lbl" style="min-width:min(100%,320px)">Buy from<select class="field" id="buyFrom"></select></label><span class="muted" style="font-size:12px" id="fromHint"></span></div>
<div class="acts" id="buyActs"> <div class="acts" id="buyActs">
<button class="btn pri" type="button" id="buyBtn" disabled>Connect a wallet to buy</button> <button class="btn pri" type="button" id="buyBtn" disabled>Connect a wallet to buy</button>
<button class="btn" type="button" id="cardBtn">Buy POL with a card</button>
<span class="muted" style="font-size:12px">SafePal recommended. MetaMask, Phantom and WalletConnect wallets also work.</span> <span class="muted" style="font-size:12px">SafePal recommended. MetaMask, Phantom and WalletConnect wallets also work.</span>
</div> </div>
<div id="holdBox" class="warn" style="font-size:13px" hidden></div> <div id="holdBox" class="warn" style="font-size:13px" hidden></div>
@@ -60,6 +60,7 @@
</div> </div>
</div> </div>
<div style="display:grid;gap:16px;align-content:start"> <div style="display:grid;gap:16px;align-content:start">
<div class="panel" id="rfPanel" hidden style="padding:0" aria-live="polite"><div class="ph"><h3>Monthly Refuel</h3><span class="meta" id="rfMeta"></span></div><div style="padding:12px 16px 14px;font-size:13px" class="ink2" id="rfBody"></div></div>
<div class="panel" style="padding:0"> <div class="panel" style="padding:0">
<div class="ph"><h3 id="goesTitle">Where it goes</h3><span class="meta">same transaction</span></div> <div class="ph"><h3 id="goesTitle">Where it goes</h3><span class="meta">same transaction</span></div>
<div style="padding:10px 16px 14px" id="goesRows"></div> <div style="padding:10px 16px 14px" id="goesRows"></div>
@@ -80,9 +81,10 @@
</div> </div>
</div> </div>
</div> </div>
<script src="/assets/common.js?v=20261023ov"></script> <script src="/assets/common.js?v=20261117nw"></script>
<script src="/assets/wallet.js?v=20261021a"></script> <script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/cr-shell.js?v=20261023a"></script> <script src="/assets/cr-shell.js?v=20261115hub"></script>
<script src="/assets/credits-screen.js?v=20261019pos"></script> <script src="/assets/credits-screen.js?v=20261107tg"></script>
<script src="/assets/fuel.js?v=20261112sso"></script>
</body> </body>
</html> </html>
+34
View File
@@ -0,0 +1,34 @@
/* LinkSpin goal pixel, script version (conversion pixel, 2026-10-23). Paste on your thank-you page:
* <script async src="https://linkspin.app/cv.js?px=YOUR_PIXEL_ID&goal=subscriber"></script> (optional &value=19.95)
* It sends the click id from this page's address, or the one the landing tag (t.js) kept on your site, to LinkSpin.
* The image version (cv.gif) works without scripts; this one is surer because it can read what the landing tag kept.
* It never throws and never blocks your page.
*/
(function () {
try {
var RX = /^[a-z0-9]{6,24}$/i, W = window;
function stored() {
var v = '';
try { var j = JSON.parse(W.localStorage.getItem('ls_clk') || 'null'); if (j && RX.test(j.id || '') && Date.now() - (j.ts || 0) < 30 * 864e5) v = j.id; } catch (e) {}
if (!v) { try { var m = /(?:^|;\s*)ls_clk=([a-z0-9]{6,24})/i.exec(document.cookie || ''); if (m) v = m[1]; } catch (e) {} }
return v;
}
var q = new URLSearchParams(location.search);
var inUrl = q.get('lsclk') || q.get('lsid') || q.get('clickid') || '';
var c = '', m = '';
if (RX.test(inUrl)) { c = inUrl; m = 'url'; } else { c = stored(); m = c ? 'stored' : ''; }
var list = document.getElementsByTagName('script');
for (var i = 0; i < list.length; i++) {
var s = list[i];
try {
if (!/\/cv\.js(\?|$)/.test(s.src || '') || s.getAttribute('data-ls-done')) continue;
s.setAttribute('data-ls-done', '1');
var u = new URL(s.src, location.href), px = u.searchParams.get('px') || '';
if (!/^px[a-f0-9]{10}$/.test(px)) continue;
var goal = u.searchParams.get('goal') || '', value = u.searchParams.get('value');
var out = u.origin + '/cv.gif?px=' + px + (goal ? '&goal=' + encodeURIComponent(goal) : '') + (value != null && value !== '' ? '&value=' + encodeURIComponent(value) : '') + (c ? '&c=' + encodeURIComponent(c) + '&m=' + m : '') + (u.searchParams.get('test') === '1' ? '&test=1' : '') + '&r=' + Math.random().toString(36).slice(2, 8);
var im = new Image(1, 1); im.src = out;
} catch (e) {}
}
} catch (e) { /* never break the member's page */ }
})();
+4 -2
View File
@@ -1,14 +1,15 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="light">
<head> <head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Risk and Earnings Disclaimer | LinkSpin</title> <title>Risk and Earnings Disclaimer | LinkSpin</title>
<meta name="description" content="LinkSpin risk and earnings disclaimer."> <meta name="description" content="LinkSpin risk and earnings disclaimer.">
<link rel="canonical" href="{{SITE_URL}}/disclaimer"> <link rel="canonical" href="{{SITE_URL}}/disclaimer">
<meta name="theme-color" content="#0B1424"> <meta name="theme-color" content="#0B1424">
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png"> <link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/pub.css?v=20261007b"> <link rel="stylesheet" href="/assets/pub.css?v=20261118w">
</head> </head>
<body> <body>
<header class="top"> <header class="top">
@@ -46,5 +47,6 @@
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span> <span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div> </div>
</footer> </footer>
<script src="/assets/netline.js?v=20261117nw" data-site="linkspin"></script>
</body> </body>
</html> </html>
+6 -4
View File
@@ -1,14 +1,15 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="dark">
<head> <head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>How earning works | LinkSpin</title> <title>How earning works | LinkSpin</title>
<meta name="description" content="How members earn ad credits on LinkSpin: the daily set, the claim streak, verified visits, videos, inbox ads, the login bonus, and what to do with the credits."> <meta name="description" content="How members earn ad credits on LinkSpin: the daily set, the claim streak, verified visits, videos, inbox ads, the login bonus, and what to do with the credits.">
<meta name="robots" content="noindex"> <meta name="robots" content="noindex">
<meta name="theme-color" content="#043b2f"> <meta name="theme-color" content="#043b2f">
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@500;700;800&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@500;700;800&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png"> <link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/site.css?v=ls20260916a"> <link rel="stylesheet" href="/assets/site.css?v=ls20261101t">
<style> <style>
.eg{max-width:820px} .eg{max-width:820px}
.eg h2{font-size:23px;margin:40px 0 10px;padding-top:18px;border-top:1px solid var(--line)} .eg h2{font-size:23px;margin:40px 0 10px;padding-top:18px;border-top:1px solid var(--line)}
@@ -17,7 +18,7 @@
table{border-collapse:collapse;width:100%;max-width:560px;margin:10px 0 16px;font-variant-numeric:tabular-nums;font-size:15px} table{border-collapse:collapse;width:100%;max-width:560px;margin:10px 0 16px;font-variant-numeric:tabular-nums;font-size:15px}
th,td{text-align:left;padding:8px 10px;border-bottom:1px solid var(--line)} th{color:var(--muted);font-family:var(--mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;font-weight:500} th,td{text-align:left;padding:8px 10px;border-bottom:1px solid var(--line)} th{color:var(--muted);font-family:var(--mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;font-weight:500}
td:last-child,th:last-child{text-align:right} td:last-child,th:last-child{text-align:right}
.rule{border-left:4px solid var(--mint);background:rgba(59,157,255,.07);padding:14px 18px;border-radius:0 12px 12px 0;margin:0 0 20px} .rule{border-left:4px solid var(--mint);background:var(--mint-faint);padding:14px 18px;border-radius:0 12px 12px 0;margin:0 0 20px}
.rule b{font-family:var(--disp);display:block;margin-bottom:4px} .rule b{font-family:var(--disp);display:block;margin-bottom:4px}
</style> </style>
</head> </head>
@@ -68,6 +69,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div> <div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer> </footer>
</div> </div>
<script src="/assets/common.js?v=20261023ov"></script> <script src="/assets/common.js?v=20261117nw"></script>
<script src="/assets/netline.js?v=20261117nw" data-site="linkspin"></script>
</body> </body>
</html> </html>
+6 -4
View File
@@ -1,12 +1,13 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en" data-theme-base="light">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
<title>Help · LinkSpin</title> <title>Help · LinkSpin</title>
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20261020s"> <link rel="stylesheet" href="/assets/cr.css?v=20261114tu">
<style> <style>
.body{padding:16px 24px;display:grid;gap:16px;max-width:980px} .body{padding:16px 24px;display:grid;gap:16px;max-width:980px}
.hl .hd,.hl .rw{grid-template-columns:minmax(0,1fr) 150px 130px}.hl .rw{cursor:pointer} .hl .hd,.hl .rw{grid-template-columns:minmax(0,1fr) 150px 130px}.hl .rw{cursor:pointer}
@@ -18,6 +19,7 @@
.hf textarea.field{font:500 14px var(--body, Manrope, system-ui);line-height:1.5;resize:vertical} .hf textarea.field{font:500 14px var(--body, Manrope, system-ui);line-height:1.5;resize:vertical}
.acts{display:flex;gap:8px;flex-wrap:wrap;align-items:center} .acts{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.hmsg{font-size:12.5px;color:var(--muted)} .hmsg.bad{color:var(--bad)} .hmsg{font-size:12.5px;color:var(--muted)} .hmsg.bad{color:var(--bad)}
.hsg{border:1px solid var(--line);border-radius:12px;padding:10px 14px;font-size:13.5px}.hsg-h{margin:0 0 6px}.hsg-h span,.hsg-s{color:var(--muted);font-weight:500}.hsg details{margin:4px 0}.hsg summary{cursor:pointer;font-weight:700}.hsg-b{white-space:pre-wrap;word-wrap:break-word;line-height:1.5;margin:6px 0 8px}
.sup-msg{border:1px solid var(--line);border-radius:8px;padding:12px 14px;background:var(--panel-2)} .sup-msg{border:1px solid var(--line);border-radius:8px;padding:12px 14px;background:var(--panel-2)}
.sup-msg.admin{border-color:var(--accent-dim, #7CB2FF);background:var(--accent-soft, #E1ECFC)} .sup-msg.admin{border-color:var(--accent-dim, #7CB2FF);background:var(--accent-soft, #E1ECFC)}
.sup-msg .sm-head{font-size:12px;color:var(--muted);margin:0 0 6px;display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap} .sup-msg .sm-head{font-size:12px;color:var(--muted);margin:0 0 6px;display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap}
@@ -29,7 +31,7 @@
<div id="page"> <div id="page">
<div class="body" id="helpBody"><div class="panel"><span class="muted">loading</span></div></div> <div class="body" id="helpBody"><div class="panel"><span class="muted">loading</span></div></div>
</div> </div>
<script src="/assets/cr-shell.js?v=20261023a"></script> <script src="/assets/cr-shell.js?v=20261115hub"></script>
<script src="/assets/help-screen.js?v=20261016a"></script> <script src="/assets/help-screen.js?v=20261116sg"></script>
</body> </body>
</html> </html>

Some files were not shown because too many files have changed in this diff Show More