Compare commits
7 Commits
0938e89fbe
...
16a9d9af92
| Author | SHA1 | Date | |
|---|---|---|---|
| 16a9d9af92 | |||
| f52de70e9d | |||
| f63a37947a | |||
| 8606db6a8e | |||
| 0a30b1da60 | |||
| c9f85121e2 | |||
| 97b206f3b5 |
@@ -153,7 +153,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>';
|
||||
}
|
||||
function sitemap(posts) {
|
||||
const pages = ['/', '/blog', '/whats-new', '/leaderboard', '/ledger', '/contract', '/plays', '/wallets', '/earning', '/partners'];
|
||||
const pages = ['/', '/blog', '/whats-new', '/leaderboard', '/ledger', '/contract', '/plays', '/wallets', '/earning', '/partners', '/publishers'];
|
||||
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('');
|
||||
return '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + u + '</urlset>';
|
||||
|
||||
+74
-100
@@ -1,9 +1,12 @@
|
||||
// 24/7 site assistant (RM Circle pattern): canned answers first for the
|
||||
// questions everyone asks, OpenRouter AI for everything else, hard honesty
|
||||
// rules baked into the system prompt.
|
||||
// 24/7 site assistant: canned answers first for the questions everyone asks, OpenRouter AI for everything else,
|
||||
// hard honesty rules baked into the system prompt.
|
||||
//
|
||||
// HOUSE RULE: whenever a site feature changes, update BOTH the CANNED
|
||||
// answers and FACTS below in the same commit.
|
||||
// Rewritten for LinkSpin 2026-10-10 (the earlier copy still described InstantAdPay: holding-tank rescue, surf earn tab,
|
||||
// Five Dollar Friday, the $20 ladder). Every fact below was checked against this repo: rotator.js, pages.js,
|
||||
// pagestyle.js, zones.js, audiences.js, ads.js, registry.js, carry.js, the Control Room screens and the public pages.
|
||||
//
|
||||
// HOUSE RULE: whenever a site feature changes, update BOTH the CANNED answers and FACTS below in the same commit.
|
||||
// Plain words, no em dashes, never a promise of income.
|
||||
const { SITE_HOST, SITE_URL } = require('./host');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@@ -12,6 +15,7 @@ const https = require('https');
|
||||
let DATA_DIR = null;
|
||||
let chain = null;
|
||||
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
|
||||
const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b';
|
||||
|
||||
function init(opts) { DATA_DIR = opts.dataDir; chain = opts.chain; }
|
||||
function key() {
|
||||
@@ -20,110 +24,80 @@ function key() {
|
||||
}
|
||||
function enabled() { return !!key(); }
|
||||
|
||||
// ---- canned answers: instant, free, always in voice ----
|
||||
// ---- canned answers: instant, free, always in voice. Order matters: the first regex that matches wins. ----
|
||||
const CANNED = [
|
||||
{ re: /(pyramid|ponzi|scam|scheme)/i,
|
||||
a: 'Fair question. A pyramid pays for recruiting with no product; here every payment is for real ad delivery, bought by real advertisers, and the whole money flow is public. Check the code and every payout yourself at ' + SITE_URL + '/contract and ' + SITE_URL + '/ledger.' },
|
||||
{ re: /(withdraw|cash ?out|payout request|minimum payout)/i,
|
||||
a: 'There are no withdrawals here, ever. The contract pays your share straight to your own wallet in the same transaction as the purchase. Nothing to request, nothing to wait on.' },
|
||||
{ re: /(how (much|do i) earn|commission|percent|split)/i,
|
||||
a: 'Every package splits the same way: 50 percent to the direct sponsor, 20 percent to level 2, 10 percent to level 3, 20 percent to the platform. Those numbers are constants in the contract and cannot be changed. Play with scenarios on the home page calculator. No income is promised; nobody earns unless real ad buying happens.' },
|
||||
{ re: /(balance (went|going|keeps going) down|credits? (disappear|missing|gone|dropping|went down|ticking)|why (is|did) my (balance|credits)|in campaigns|set aside|reserved credits|available to spend)/i,
|
||||
a: 'One rule: your balance is what is NOT committed to a live campaign. When you start a campaign its whole budget is set aside right then (earned credits first, then purchased), so your Available number drops once and then sits still while the ad runs. The budget spends down inside that campaign in Members > Campaigns, where you can see delivered views, network views and what is left. The dashboard shows Purchased available, Earned available and In live campaigns as three separate numbers; a paused campaign keeps its unspent budget set aside so it can resume. Nothing is lost when a balance reads low while a campaign is live. Purchased credits live on the blockchain; if we ever refund or credit purchased money it shows under Purchased as "credited to you" and spends like a purchase, login ads included. Earned credits fund every format except login ads.' },
|
||||
{ re: /(qualif|unlock level|level 2|level 3|pass.?up)/i,
|
||||
a: 'Two different things are earned here. CREDITS: every member, free ones included, earns ad credits by viewing ads, videos, visits and the daily sign-in; credits buy your own ads and are never withdrawn. POL: real crypto paid to your wallet when your referrals buy packages, once you are activated: the $20 starter package plus payouts switched on from your wallet. Level 1 pays 50 percent of the packages your direct referrals buy, from the day you are activated. Bring 2 buyers of $20 or more and level 2 unlocks; 5 unlock level 3. When a level is not qualified, its share climbs the sponsor line, checking up to 25 positions, and pays the first qualified person. Qualification never expires and cannot be bought. Qualified Start: you may link extra wallets of your own as positions under your account (Buy packages > Qualified Start); each one that buys a $20+ package counts as a qualifying buyer, its credits pool with yours, and 50% of its purchase comes back to your main wallet. Your own money, your own wallets, a faster start, never an income promise.' },
|
||||
{ re: /(free member|without (a )?wallet|do i (have to|need to) buy|earn (in )?credits|credits (vs|versus|or) pol|earn pol|get paid in)/i,
|
||||
a: 'Free members earn ad credits: view ads, watch videos, make verified visits, read inbox ads, sign in daily. Credits buy your own ads and are never cashed out. POL, the real crypto, is paid to your wallet by the contract when your referrals buy packages, once you are activated: the $20 starter package (2,000 credits to advertise with) and payouts switched on from the Wallet tab. Your own $20 purchase also makes you count as a qualifying buyer for your sponsor, and two or five such buyers in your own line open levels 2 and 3 for you.' },
|
||||
{ re: /(need (a )?wallet|crypto experience|metamask|how (do i|to) join|sign ?up|register)/i,
|
||||
a: 'Join free with just your email at ' + SITE_URL + '/my, no wallet and no password needed. Your wallet only comes out when you buy a package or switch on payouts, and the site walks you through it.' },
|
||||
{ re: /(referral link|invite link|share link|refer)/i,
|
||||
a: 'You get your share link the moment you sign in, free members included. Open Members > Promo tools: the "Your links" block at the top lists your invite link plus five angle versions (Instant, Ad spend, Free, Ledger, Two), each with a note on who it is for and Copy and Share buttons. They are the same link with a code on the end, so every join and purchase credits you; only the first page the person sees changes. One tip: switch on payouts (one free wallet step in Members) before your people start buying, because the contract locks each buyer to their sponsor at their first purchase.' },
|
||||
{ re: /(promo tools?|social posts?|email swipes?|banners?|text a friend|objection|share buttons?)/i,
|
||||
a: 'Promo tools (Members > Promo tools) has pill menus for each kit: Social posts (X, Facebook, LinkedIn, Telegram or WhatsApp, with post and share buttons), Text a friend (SMS-sized messages with Text it, WhatsApp, Telegram and Copy), Email swipes (short, standard, long, follow-up), Banners (every standard ad size plus square, story and Telegram sizes, download or copy URL), your Banner wall link, and an Objection handling bank with the truth plus a ready-to-send reply. Everything is personalized with your invite link.' },
|
||||
{ re: /(pyramid|ponzi|scam|scheme|mlm|legit)/i,
|
||||
a: 'Fair question. A pyramid pays for recruiting with no product. LinkSpin sells advertising: an ad package buys real ad delivery (banner, text and login ads across the ad viewer, every member zone and the partner network), and the free tools, spin links, pages and zones, work with no purchase at all. The referral split is a fixed rule in a verified contract on Polygon, 50 percent to the direct sponsor, 20 to level 2, 10 to level 3 and 10 plus 10 to two admin wallets, paid in the same transaction as the purchase. Nobody is paid for recruiting without a sale, nothing is held, and no income is promised. Read the code and every payout yourself at ' + SITE_URL + '/contract and ' + SITE_URL + '/ledger.' },
|
||||
{ re: /(withdraw|cash ?out|payout request|minimum payout|pending (payment|payout|commission))/i,
|
||||
a: 'There are no withdrawals here, ever. When someone in your line buys a package, the contract pays your share straight to your own wallet in the same transaction as the purchase, so there is nothing to request and nothing pending. Credits are the other thing you can have, and they never cash out: they only buy ad delivery.' },
|
||||
{ re: /(how (do|does) (the )?payouts? work|how (much|do i|does one|can i) (earn|get paid|make)|commission|percent(age)?|the split|split (the|a) (package|purchase)|who gets paid|where does the money go)/i,
|
||||
a: 'Every package splits the same way, in the same Polygon transaction it sells in: 50 percent to the direct sponsor, 20 percent to level 2, 10 percent to level 3, and 10 plus 10 percent to the two admin wallets. Level 1 pays you from your referral\'s very first qualifying purchase once your payouts are switched on. Level 2 opens after two of your people buy a qualifying package ($25 or larger; the $10 door does not count), level 3 after five. A level with no qualified member passes up the line to the next qualified person, then to the platform; nothing waits in a balance. Those numbers are constants in the verified contract at ' + SITE_URL + '/contract. No income is promised: nobody earns unless real ad buying happens in their line.' },
|
||||
{ re: /(free member|free account|for free|without (a )?(wallet|buying|purchase)|do i (have|need) to (buy|pay|purchase)|what do (i|free members|members) get|what is free|is it free|costs? nothing)/i,
|
||||
a: 'A free account gets the whole toolset: spin links (one short link that rotates every page you promote, with weights, a fallback and a report by source), the page builder (bridge, review and squeeze pages from a scan of any offer, leads to your own list), zones (an ad slot on your own site that pays ad credits per viewable impression), audiences (first-party retargeting), reports, promo tools and the blog. Free members earn ad credits by running zones, viewing the daily ad set, watching videos, making verified visits and signing in daily. Credits buy your own banner and text ads at one cent each and never cash out. POL, the real crypto, only ever reaches a wallet through the contract split when a package sells in your line, and you can switch payouts on without buying anything.' },
|
||||
{ re: /(qualif|unlock level|open level|level ?2|level ?3|pass.?up|two buyers|five buyers)/i,
|
||||
a: 'Level 1, half of every package your direct referrals buy, pays from their first qualifying purchase once your payouts are on. Level 2 (20 percent) opens after two of your people buy a qualifying package, $25 or larger. Level 3 (10 percent) opens after five. The $10 door package is for trying the ads and does not count toward opening levels. Until a level opens, its share passes up the line to the next qualified member, then to the platform, and it never comes back, so leaders qualify before their teams\' teams buy. Qualification is counted by the contract, never expires and cannot be bought.' },
|
||||
{ re: /(what('s| is) (a |an )?(ad )?zone|zones?\b|embed|script tag|publisher|site owner|my (own )?(web)?site|ad slot|viewable)/i,
|
||||
a: 'A zone is an ad slot on your own site: one script tag, nine standard sizes (728x90, 468x60, 300x250, 336x280, 250x250, 125x125, 160x600, 120x600, 320x50). Each load shows a LinkSpin member campaign first, then a network ad, then our house banner if nothing paid fits. You earn ad credits per viewable impression (half the banner on screen for one second, bots never, 50 credited views per visitor per zone per day): 1 credit per 5 viewable member-ad views and 1 per 10 network-ad views, or 1 per 8 on a Verified zone the admin has reviewed. A new zone earns after its first 100 on-site views with at least 40 percent viewable, and paid ads serve only on the site you declared, so copying the tag elsewhere earns nothing. Everything is explained at ' + SITE_URL + '/publishers and you add zones under Zones in your Control Room.' },
|
||||
{ re: /(spin ?link|rotat|short link|one link|weights?|fallback|split test|sub ?id|click ?id|daypart|health check|dead link|redirect)/i,
|
||||
a: 'A spin link is one short link that rotates between every page you promote. Behind it you set destinations with weights, pause any of them, and name a fallback for when everything else is off. Every click is recorded in one hop with the day, country, source and device, bots are filtered on the server, and click ids and sub ids (clickid, subid, s1 to s4 and the usual tracker names) ride through to the destination, so you can split-test by tagging the same link with different sub ids. Reports show it per link and across all of them. Set the hours of the day and week a spin or a destination runs (the local time of your visitor by default), and automatic health checks pause a dead or parked destination for you. You can try a spin with no account on the home page.' },
|
||||
{ re: /(page builder|bridge page|squeeze page|review page|sales page|advertorial|press release|landing page|build (a|me a) page|my pages?|lead capture|leads?\b)/i,
|
||||
a: 'Pages is the built-in page builder. Paste the address of any offer you promote, LinkSpin scans its headline and points, you add your angle, and you get a bridge, review or squeeze page with your own leads list (CSV or webhook), published on LinkSpin\'s pages domain, lookfirst.page. Pick a design, palette and layout, or a niche preset that sets them for you with a matching hero image. Put the page behind a spin link to send traffic by weight. Sales, advertorial and press-release layouts are on the way. Open Pages in your Control Room; it is free.' },
|
||||
{ re: /(audience|retarget|pixel|p\.js|my visitors|show only to|never show to)/i,
|
||||
a: 'Audiences is first-party retargeting. Everyone who views your LinkSpin pages or your zones lands in "My visitors" for 30 days with no setup, and for any other site you control you paste a small pixel tag (/p.js). Then, on any banner or text campaign, choose "show only to" or "never show to" an audience. The match uses a LinkSpin cookie with a 24-hour fallback where browsers block cross-site cookies, and nothing personal is stored. It lives on the Zones screen.' },
|
||||
{ re: /(promo tools?|social posts?|email swipes?|banners? (kit|set)|text a friend|objection|hook videos?|angle (link|video|page)|share buttons?)/i,
|
||||
a: 'Promo tools (' + SITE_URL + '/tools#promo) holds everything personalised with your invite link: social posts, text-a-friend messages, email swipes, banners in the standard sizes, an objection-handling bank with honest replies, and the hook videos. There are five hook angles, each with its own join page and video: links (stop juggling links), pages (a bridge page in a minute), zones (your site pays you), audiences (reach your visitors again) and stack (the three tools, free). An angle link is your normal link with ?v= on the end, so every join and purchase still credits you.' },
|
||||
{ re: /\bblog\b|articles?|read more/i,
|
||||
a: 'The blog at ' + SITE_URL + '/blog has Marty\'s articles on building a line, advertising that pays and daily habits. Each article has its own page you can share, and there is an RSS feed at /blog/feed.xml.' },
|
||||
{ re: /(price|cost|packages?|how much is|ladder|\$10|\$25|\$50|\$100|\$250|\$500|door package)/i,
|
||||
a: 'Six packages, priced in dollars and settled in POL at the live rate: the $10 door (1,000 credits, for trying the ads; it does not count toward qualification), $25 Starter (2,500), $50 Builder (5,000), $100 Growth (10,000), $250 Leader (25,000) and $500 Network (50,000). One credit is one cent of ad delivery. Any package of $25 or more makes you a qualifying buyer for your sponsor. Buy under Credits in your Control Room; the live ladder is on the home page.' },
|
||||
{ re: /(credits?|impression|cpm|what do i get|what am i buying|one cent|1 cent)/i,
|
||||
a: 'One credit is one cent of ad delivery: banner, text and login ads shown across the LinkSpin ad viewer, every member zone and the partner network, managed from the Ads screen. Credits come two ways, bought in a package or earned free (zones, the daily ad set, videos, verified visits, daily sign-in). Earned credits spend on banner and text campaigns; the login spot takes purchased credits. Credits are advertising, not money: they never cash out and are never converted to crypto.' },
|
||||
{ re: /(drain (my|your) wallet|stop and go back|trust wallet.*(warn|block|red)|wallet (warning|blocked))/i,
|
||||
a: 'That red "this transaction will drain your wallet" screen is the wallet\'s own safety rule, not a problem with the purchase: Trust Wallet blocks any transaction that spends most of the POL in the wallet. Ways through: buy a smaller package first, add some POL so the purchase is well under half the balance, or connect a different wallet (MetaMask, Phantom, SafePal have no such block). Extra POL always stays yours. If the next try says WalletConnect disconnected, open Wallet, tap Disconnect, then Connect again. Phantom, SafePal and MetaMask do not have the hard block.' },
|
||||
{ re: /(wall (page|slots?|positions?)|banner wall|my wall|three (ads|slots) on (my|the) wall)/i,
|
||||
a: 'Your wall (' + SITE_HOST + '/wall/yourname) shows three ads. Position 1 is always your line banner. Positions 2 and 3 show your upline (or LinkSpin) until you earn them: 2 qualifying buyers ($20 or more) make position 2 yours, 5 make position 3 yours, so a fully qualified member owns the whole page with their own links and offers. Set them in Profile > Your wall; an unlocked slot you leave empty keeps showing your upline until you fill it.' },
|
||||
{ re: /(solo ad|inbox ad|inbox)/i,
|
||||
a: 'Solo ads are full-message ads delivered straight into member inboxes on-site. Compose one under Campaigns (pick "Solo ad"): subject line, a rich-text message with a real editor (bold, headings, lists, links), an attached image or video if you want one, and a call-to-action button with your own label. You pay 5 credits per guaranteed delivery, 10 deliveries minimum. On the reading side, your Inbox section collects solos from other members — give one a real read (10 seconds on the open message) and claim 2 credits, up to 5 rewarded reads a day. You never receive your own solo.' },
|
||||
{ re: /(wrong sponsor|who is my sponsor|which sponsor|sponsor (cookie|link|credit)|clicked (someone|another|two).*link|last (link|click)|first (link|click|touch)|change (my )?sponsor)/i,
|
||||
a: 'The invite link you opened most recently sets your sponsor, and the join page shows it: "Personal invitation from @name". It locks the moment you create your account, so opening someone else\'s link afterwards changes nothing, and your first purchase binds you to that same sponsor on the contract. If you have not joined yet and the page shows the wrong name, open the right person\'s link and it updates. If you already joined under the wrong sponsor by mistake, message support before your first purchase and the admin can move you.' },
|
||||
{ re: /(chat|message (my )?(sponsor|upline|team|downline)|talk to (my )?sponsor|contact (my )?sponsor|ask (my )?sponsor|reach (my )?sponsor)/i,
|
||||
a: 'Yes, Members has a two-way Sponsor Chat. You can message your direct sponsor for help (from Overview or the chat button), and sponsors can message anyone in their line. If they are online you chat live; if not, your message waits in their on-site inbox and they get an email. Sponsors can set themselves unavailable in Profile (you can still leave a note, they just reply later) and mute a member if needed. It is separate from the once-a-day team broadcast.' },
|
||||
{ re: /((view|watch|see).{0,12}ads?|earn.{0,12}credits?|daily (set|ads|views))/i,
|
||||
a: 'In the Earn credits section of Members, each ad in the daily set opens full screen in its own tab, showing the advertiser\'s real site. A countdown runs while you watch (it pauses if you leave the tab), then you pass a quick click-the-icon check and the view counts. Finish the set, claim your daily credits, and spend them on your own banner or text campaigns. You never see your own ads, and viewer rewards are credits, never cash.' },
|
||||
{ re: /(credit|impression|cpm|what do i get|what am i buying)/i,
|
||||
a: 'Packages mint ad credits on-chain, and every new member also gets a small batch of welcome credits just for joining. One credit is one cent of ad delivery: banners, text ads, full-screen login ads, and solo ads across the network, managed from the campaign manager in Members. Only your campaigns can spend your credits.' },
|
||||
{ re: /(price|cost|package|how much is)/i,
|
||||
a: 'Packages run 5 to 250 dollars, priced in dollars and settled in POL at the live rate when you buy. The full ladder with live pricing is on the home page. Packages of $20 or more count toward qualification.' },
|
||||
{ re: /(which|what) (crypto|coin|token|currency|chain|network)|paid in what|get paid in|supported (crypto|coins|wallets)|do you (support|accept)/i,
|
||||
a: 'One coin, one network: POL, the native coin of Polygon. You pay for packages in POL and every payout arrives as POL in your own Polygon wallet, in the same transaction. No other coins, tokens or chains are used. Any Polygon wallet works (MetaMask, SafePal, Phantom, Coinbase Wallet), and you can buy POL with a card from Buy packages if you have never held crypto.' },
|
||||
{ re: /(which wallet|what wallet|best wallet|recommended wallet|set ?up (a )?wallet|buy (pol|crypto|polygon)|get (pol|crypto)|moonpay|card to crypto|no crypto|never (had|held|owned) crypto)/i,
|
||||
a: 'Preferred wallets: MetaMask (recommended, and the one for Qualified Start extra accounts), Phantom (turn Polygon on first: Settings, Active Networks), SafePal or Coinbase Wallet. Trust Wallet works but blocks a purchase that spends most of the POL in it, so keep about double the package cost there. To buy POL with a card: connect your wallet, open Buy packages, tap "Buy POL with a card". MoonPay opens with POL on Polygon and your own address filled in; pay by card, Apple Pay or Google Pay (first time needs an ID check, minimum order around $30), the POL lands in your wallet in minutes, then buy the package. The full step-by-step guide is in Training: Wallets and buying POL (' + SITE_URL + '/wallets, members only).' },
|
||||
{ re: /(safe|trust|rug|run away|company disappear)/i,
|
||||
a: 'The money never touches us. An immutable contract splits every purchase in the same transaction, holds zero balance, and has no pause switch or upgrade path. Read the plain-language review and the verified source at ' + SITE_URL + '/contract.' }
|
||||
a: 'That red "this transaction will drain your wallet" screen is Trust Wallet\'s own safety rule, not a problem with the purchase: it blocks any transaction that spends most of the POL in the wallet. Ways through: buy a smaller package first, add some POL so the purchase is well under half the balance, or connect a different wallet. SafePal, MetaMask and Phantom have no such block. Extra POL always stays yours. If the next try says WalletConnect disconnected, open the Wallet screen, disconnect, then connect again.' },
|
||||
{ re: /(which wallet|what wallet|best wallet|recommended wallet|set ?up (a )?wallet|buy (pol|crypto|polygon)|get (pol|crypto)|moonpay|card to crypto|no crypto|never (had|held|owned) crypto|metamask|safepal|phantom|coinbase wallet)/i,
|
||||
a: 'SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first under Settings, Active Networks) and any WalletConnect wallet work too. Trust Wallet works but blocks a purchase that spends most of its POL, so keep about double the package cost there. Never held crypto? Link your wallet, open Credits and tap Buy POL with a card: MoonPay opens with POL on Polygon and your own address filled in, you pay by card, Apple Pay or Google Pay (the first time needs an ID check), the POL lands in your wallet in minutes, then you buy the package. Keep a little extra POL for network fees.' },
|
||||
{ re: /(need (a )?wallet|crypto experience|how (do i|to) (join|sign ?up|register|sign in)|sign ?up|register|password|sign.?in code|six.?digit)/i,
|
||||
a: 'Join free with just your email at ' + SITE_URL + '/join. A six-digit code signs you in, there is no password, and no wallet is needed to use the links, pages and zones. The wallet step comes later, inside your Control Room, when you want to be paid or to buy a package.' },
|
||||
{ re: /(referral link|invite link|share link|join link|my link|refer(ring)? (people|friends|someone))/i,
|
||||
a: 'Your invite link is live the moment you sign in, free members included: ' + SITE_HOST + '/join/yourname. Promo tools lists it with the five angle versions (links, pages, zones, audiences, stack), each with a video and Copy and Share buttons; they are the same link with ?v= on the end, so every join and purchase credits you. One tip: switch on payouts (Credits screen, one transaction, no purchase needed) before your people start buying, because the contract locks each buyer to their sponsor at their first purchase.' },
|
||||
{ re: /(wrong sponsor|who is my sponsor|which sponsor|sponsor (cookie|link|credit|carr)|carry.?over|clicked (someone|another|two).*link|last (link|click)|first (link|click|touch)|change (my )?sponsor|same (team|sponsor|upline)|registry)/i,
|
||||
a: 'The invite link you opened most recently sets your sponsor, and the join page shows who you are joining under. It locks when you create your account, and your first purchase binds you to that sponsor on the contract. Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their sponsor carried over automatically from the network registry when no invite link was used, so the same people are above you here. Already joined under the wrong sponsor by mistake? Message support before your first purchase and the admin can move you.' },
|
||||
{ re: /(activat|switch(ed)? on payouts|payouts (on|off)|turn on payouts|get paid to my wallet|link (my |a )?wallet)/i,
|
||||
a: 'Payouts switch on when your wallet is registered on the contract. That happens two ways: buy any package, or use the free activation on the Credits screen, one transaction that costs only network gas. First link the wallet that should receive your payouts (one signature, no transaction), then activate. From then on the contract pays your share of every qualifying purchase in your line straight to that wallet. Buying is never required to be paid at level 1; a $25 or larger package is what makes you a qualifying buyer for your own sponsor and funds your own ads.' },
|
||||
{ re: /(which|what) (crypto|coin|token|currency|chain|network)|paid in what|get paid in|\bpol\b|polygon|matic/i,
|
||||
a: 'One coin, one network: POL, the native coin of Polygon. Packages are priced in dollars and settled in POL at the live rate, and every payout arrives as POL in your own Polygon wallet in the same transaction. No other coins, tokens or chains are used. Send POL on the Polygon network, never MATIC on Ethereum.' },
|
||||
{ re: /(control room|dashboard|where (do|can) i (find|see)|which screen|menu|navigation|more tools|\/tools)/i,
|
||||
a: 'Your Control Room has these screens: Links (spin links), Pages (the page builder), Zones (ad slots on your site plus Audiences), Ads (your campaigns and the daily ad set), Credits (buy packages, link your wallet, switch on payouts), Reports (every link in one view), Team (your line, three levels) and Wallet (what was paid to you). More, at ' + SITE_URL + '/tools, holds Promo tools, Training, the Pipeline follow-up board, My line and your Profile.' },
|
||||
{ re: /(holding tank|adopt|no sponsor|without a sponsor|orphan)/i,
|
||||
a: 'Members who join from the public site with no sponsor wait in the holding tank under More, My line. A member who has switched on payouts and bought their own qualifying package can adopt one, first come, with a 7-day window for the new member to link a wallet or buy; otherwise they return to the tank. Adopting sets the sponsor, and their first purchase then binds to the adopter on the contract.' },
|
||||
{ re: /(my line|downline|my team|who (is|are) (in|on) my|three levels|level 1\b)/i,
|
||||
a: 'Team shows your line as a working table, three levels deep: who joined through your link, who has switched on payouts, who has bought, and how many qualifying buyers each person has. The chip count is what opens your levels: two qualifying buyers ($25 or larger) open level 2, five open level 3.' },
|
||||
{ re: /(balance (went|going|keeps going) down|credits? (disappear|missing|gone|dropping|went down)|why (is|did) my (balance|credits)|in campaigns|set aside|reserved credits|available to spend)/i,
|
||||
a: 'One rule: your available balance is what is not committed to a live campaign. When you start a campaign its whole budget is set aside right then, so Available drops once and then sits still while the ad runs; the budget spends down inside that campaign on the Ads screen, where you can see delivered views and what is left. A paused campaign keeps its unspent budget set aside so it can resume. Nothing is lost when a balance reads low while a campaign is live.' },
|
||||
{ re: /(safe|trust (you|this|the site)|rug|run away|disappear|hold(s|ing)? (my|the) (money|funds))/i,
|
||||
a: 'The money never touches us. A verified, immutable contract on Polygon splits every purchase in the same transaction, holds no balance, and has no pause switch or upgrade path. Credits live on the platform and are advertising, not money. Read the plain-language review and the verified source at ' + SITE_URL + '/contract, and watch every payout land at ' + SITE_URL + '/ledger.' }
|
||||
];
|
||||
|
||||
// ---- facts for the AI fallback ----
|
||||
function systemPrompt() {
|
||||
return `You are the assistant on LinkSpin (${SITE_URL}), a membership advertising platform.
|
||||
return `You are the assistant on LinkSpin (${SITE_URL}), a link rotator, page builder and advertising network for marketers, a Crypto Team Build Network property.
|
||||
|
||||
FACTS:
|
||||
- Free to join with email only (6-digit code sign-in, no passwords). Wallet appears only at purchase or payout activation. Every new member gets a small welcome batch of ad credits — unlocked by the WELCOME TOUR on first sign-in: they visit their upline's line-banner sites (up to 3, 10 seconds each — the same 3 levels the contract pays), then claim the credits. Members with no upline banners get the credits instantly.
|
||||
- SPONSOR ATTRIBUTION: last touch. The invite link opened most recently sets the sponsor (30-day cookie), shown on the join page and again at the code step ("Joining under @name"). It locks when the account is created; the contract binds the buyer to that sponsor at their first purchase. Wrong sponsor before joining: open the right link. Already joined wrong: admin can move the account before the first purchase.
|
||||
- YOUR LINKS (top of Members > Promo tools): the plain invite link plus five angle links (?v=instant paid-in-seconds, ?v=adspend you-buy-ads-anyway, ?v=free costs-nothing-to-try, ?v=ledger no-back-office, ?v=two two-buyers-open-level-two), each with a who-it-is-for note, Copy and Share. Same credit either way; only the first page differs. Link stats (Coaching pane) shows views/joins/buyers per angle.
|
||||
- PROMO TOOLS (Members > Promo tools, pill menu): Social posts for X/Facebook/LinkedIn/Telegram-WhatsApp with post/share buttons; Text a friend (5 SMS-sized messages with Text it / WhatsApp / Telegram / Copy); Email swipes (short, standard, long, follow-up); Banners in every standard ad size plus 1080x1080, 1080x1920 and 1280x720 (download or copy URL); the member's Banner wall link; an Objection handling bank (truth + ready-to-send reply); a Videos tab (hook videos in production). Every piece carries the member's invite link; angle links add ?v=instant|adspend|free|ledger. Members who want copy in their own voice can use mybrandedvoice.com.
|
||||
- INVITE PAGES: a member's link ' + SITE_HOST + '/join/<username> opens a lead-capture page (email first, wallet later); add ?v=instant|adspend|free|ledger|two for an angle-matched headline. New free members get a short getting-started email series over the first week (unsubscribe link in every email; the admin edits the sequence in /admin > Settings).
|
||||
- WALLET DRAIN WARNING: Trust Wallet hard-blocks any purchase that spends most of the wallet's POL ("this transaction will drain your wallet", only "Stop and go back"). It is a balance-proportion heuristic, not a contract issue (there are no token approvals; a buy is one native-POL payable call). Advice: smaller package first, or add POL so the buy is well under half the balance, or use MetaMask/Phantom/SafePal (no hard block). The dashboard warns Trust Wallet users before sending when a buy would use more than ~55% of the balance; other wallets are not prompted. After a blocked attempt the WalletConnect session may be dead: Wallet tab > Disconnect > Connect again.
|
||||
- WALL OWNERSHIP LADDER: the public wall has 3 positions. Position 1 = the member's line banner. Positions 2 and 3 show upline banners (then house ads) UNTIL the member earns them: 2 qualifying buyers ($20+) unlock position 2, 5 unlock position 3; a fully qualified member's wall is 100% their own links/offers (set in Profile > Your wall: label, https link, optional banner image). Empty unlocked slots fall back to upline banners, then house ads.
|
||||
- LINE BANNER (free, set in Profile): every member can set a destination URL (must allow framing) plus an optional banner image. It is shown to their next THREE levels of new members during welcome tours (position 1 for directs, 2, 3 below), and on their public BANNER WALL at /wall/<username> — a shareable page showing their line ladder with their join link. Free viral traffic that compounds as the team grows; no credits spent.
|
||||
- Ad packages: Micro $5/500 credits, Activation $20/2,000, Builder $50/5,500, Growth $100/12,000, Leader $250/32,500. Dollar-priced, settled in POL (Polygon) at the live Chainlink rate. 1 credit = 1 cent of ad delivery.
|
||||
- Live formats: display banners (per impression), text ads (per impression), full-screen LOGIN ADS (per day: right after a member signs in they land on a sponsor interstitial — they click "Open Ad", the advertiser's page opens in a NEW tab, a countdown runs on the interstitial, and at zero a "Go to dashboard" button appears. Just a CTA link is enough; an optional banner image can be the clickable creative. No framing requirement since it opens in its own tab), WATCH-TO-EARN VIDEO ADS (advertiser uploads an MP4/WebM or gives a direct https .mp4/.webm link and picks a required watch length — 10s/30s/60s — which sets the per-view price; viewers watch in an escape-proof player under Earn credits > Watch videos, the watch time is enforced on the server clock, and they earn credits per completed watch; you never see your own videos), and solo ads. Banner ads also require a size (standard IAB sizes like 728x90, 300x250). Coming: featured rotation with disclosed rotation size, verified-visit packs.
|
||||
- WALLETS + BUYING POL (Training > Wallets and buying POL, /wallets, members only): preferred MetaMask (recommended; extra accounts for Qualified Start), Phantom (PHANTOM GOTCHA: Polygon is OFF by default; Settings > Active Networks > turn on Polygon, otherwise connect/buy fails or shows the wrong network; seen with Jim Watts' EB team 2026-09-13), SafePal, Coinbase Wallet; Trust works but blocks buys spending most of its POL (keep ~2x). MoonPay flow: connect wallet, Buy packages > "Buy POL with a card" opens MoonPay with POL on Polygon + the member's address prefilled; card/Apple Pay/Google Pay; first-time ID check; minimum order ~$30; buy package cost + 2-3 POL for fees; POL arrives in minutes; then buy. Exchanges: withdraw POL on the Polygon network. Never MATIC on Ethereum, never share the recovery phrase.
|
||||
- INTRO VIDEO ON THE WALL: Profile > social links has an "Intro video" field (YouTube, Vimeo or direct .mp4 link). It embeds on the member's public wall page (/wall/<username>) right under their bio, above the three-level line and the join button.
|
||||
- HOLDING TANK (Members > My line > Holding tank card): free members who joined with no sponsor wait there; a member who has switched on payouts AND bought their own $20+ package can Adopt one (first come, max 2 open adoptions, 7-day window; if the person never links a wallet or buys, they fall back into the tank; a person can be adopted twice at most). Adopting sets the sponsor, opens a chat and emails the member; their first purchase then binds to the adopter on-chain. Members can also "Release to tank" one of their own free referrals (pay it forward), but NOT someone they adopted less than 3 days ago: an adoption is a commitment, and a dropped adoption still counts toward that person's two-adoption lifetime limit. Releases are posted to the feed and Telegram like pickups. Admin sees the tank under Members.
|
||||
- DAILY CLAIM STREAK: finishing the daily ad set and claiming pays 5 credits on day 1, 7 on day 2, 10 from day 3, and 25 on every 7th consecutive day; miss a day and it restarts. After the set, verified visits (up to 20 a day, 1 credit each) keep earning, and the credits are meant to be spent on a campaign.
|
||||
- BLOG (public, ${SITE_HOST}/blog): Marty's coaching and teaching articles on building a line, advertising that pays, and daily habits; each article has its own page and can be shared; RSS at /blog/feed.xml. Members who want to write their own articles: not offered today.
|
||||
- ACHIEVEMENT BADGES ON TELEGRAM (2026-09-13): when a member unlocks Spark/Surge/Circuit/Nexus, their personalised badge image (username on the ribbon) is posted automatically to the team's Telegram payments topic and the main group, once per badge; members cannot trigger posts themselves (the 'Post to Telegram' button is admin-only); 'Share' opens a picker (X, Facebook, Telegram, WhatsApp, LinkedIn, Massifly (copies the post and opens the feed composer), the phone's own share menu, copy link, save image) that shares the member's public badge page ' + SITE_HOST + '/b/<username>/<badge>, which shows the badge and their join link.
|
||||
- PROMO TOOLKIT BY BADGE + AI COPY ENGINE (2026-09-14): Promo tools > AI Copy Engine shows the ladder: Free (links, posts, swipes, banners, wall, objections, shorts, badge pages), Spark (payouts on: one-tap campaign templates aimed at the member's link, printable handout with their QR at /handout/<username>), Surge (first qualifying buyer; the AI Copy Engine is live: posts, DMs, follow-ups, objection replies, emails, story posts, team broadcasts in the member's name with their link, honesty rules built in; 20 free generations a month), Circuit (60 free; Video Maker renders every promo video and short with the member's own end card and QR, hosted for download; split tester compares join angles by views, joins, buyers), Nexus (150 free; Leader Ops: three-level team triage with stalled flags and one-click nudges, AI-drafted team broadcasts, credit grants from the leader's earned pool to anyone in their line, co-branded join page showing the sponsor's bio, and the member's own partner code: welcome credits funded from the leader's pool at each redemption, plus a partner kit page /partners?ref=<username>&promo=CODE). After the free allowance each generation costs 10 ad credits from the earned pool. Credits are advertising, never money.
|
||||
- MEMBER UPDATE EMAILS (2026-09-14, admin only): Admin > Releases > Email an update to members: pick release notes, add an intro, choose an audience (newsletter opt-ins, opt-ins active in the last 30 days, or everyone including those who declined), preview, send a test to the admin, then send; plain text from no-reply@${SITE_HOST} with an opt-out link; the log shows sent/opted out/failed.
|
||||
- LINKED POSITIONS AND BADGES (2026-09-14): qualifying buyers on a member's linked positions count toward their achievement badges (Spark/Surge/Circuit/Nexus) and light their chip on their sponsor's line, and a badge once earned never regresses. CONTRACT RULE: levels 2 and 3 are paid to the MAIN wallet only when that wallet's own count of qualifying buyers reaches 2 and 5; buyers registered under a linked position count for that position, not the main wallet. Qualified Start positions buy UNDER the main wallet, so those buys raise the main count; a member whose old wallet was swapped out (its buyers stay with the old position) needs new $20+ buyers under the current main wallet before level 2 pays it. The contract still pays levels 2 and 3 to each position based on that position's OWN qualifying buyers, so the Qualifying buyers tile shows the main position's count with the linked positions' count underneath.
|
||||
- CREDITS VS POL (2026-09-15, Marty's stance): EVERY member earns CREDITS (viewing, videos, visits, inbox, sign-in bonus, badge bonuses); credits are ad delivery, not money. POL is paid by the contract to a member's wallet when referrals buy packages. ALWAYS describe activation as 'the $20 starter package plus payouts switched on' and lead every earning answer with it; do NOT volunteer that level 1 can pay without a purchase. If someone asks point-blank whether a purchase is required for level-1 payouts, answer truthfully in one sentence: the contract pays level 1 to any member whose payouts are switched on, and the $20 package is what makes them a qualifying buyer for their sponsor, funds their own ads, and unlocks badges, tools, the holding tank and wall positions. A $20+ purchase by a referral makes that referral a qualifying buyer for their sponsor; 2 and 5 open levels 2 and 3. Never claim the payout itself is gated by a purchase.
|
||||
- PIPELINE (coming soon, built 2026-09-15; opens when the site setting pipelineMode is on): a follow-up board on the dashboard, tab 'Pipeline' between My line and Buy packages. Columns: Talking to, Joined, Wallet linked, Payouts on, Bought, Building, Later. Prospects (from the My line prospect list) and directs are placed automatically from what they have actually done (coaching rung, on-chain buys); nobody drags cards. The sponsor adds a note, a follow-up date and a tag (hot, later, no response, not interested); a 'Follow up today' strip lists due cards; stalled cards (quiet 3+ days) are flagged; each card carries the message for its exact stage with 'Open chat with this message' (member chat) or copy. Until it opens, the tab shows a coming-soon card with the roadmap date.
|
||||
- PAYMENT + MISSED-PAYMENT NOTICES (2026-09-15): every payout that lands (who bought, level, share in POL and dollars, transaction link) and every missed payout is delivered BOTH by email and as an on-site inbox message from the company account, shown in the login pop-up and the Messages card, so it is waiting when the member signs in. MISSED-PAYOUT detail: when a level-2 or level-3 share passes a member by because that level is not open on their account, the member gets an email the same minute: who bought, the POL and dollar amount they missed, how many qualifying buyers they have versus the 2 or 5 needed, and the two ways to close the gap (bring buyers, or Qualified Start). Qualified members whose wallet rejected a transfer get a different email telling them to link a regular wallet.
|
||||
- LAUNCH WEEK SWIPES (2026-09-15): the founding-week checklist page (/launch) ends with four promoter emails members send to their OWN lists, one a day toward Monday's opening, with the member's invite link and the FOUNDER code (500 credits for anyone who joins before Mon 2026-09-21 9 AM Central) filled in, each with a Copy button. These are swipes for members, not emails the site sends.
|
||||
- LOGIN ADS CHARGE ONLY ON DAYS SHOWN (2026-09-15): the login ad daily fee (100 credits) is charged only for days the ad was actually shown at least once; with many login ads sharing the sign-ins, an ad that was not picked that day pays nothing. Featured links now count views (one per viewer per hour) as well as clicks.
|
||||
- SPONSOR HOLD (2026-09-14): if a member's account names a sponsor that cannot be paid right now (sponsor has not switched on payouts, or the chain lookup failed), the first purchase and the payouts activation are held with a message instead of silently crediting the company. Fix: the sponsor switches on payouts, or the member retries; the admin gets a Telegram alert.
|
||||
- NO-PAYOUT POSITIONS (2026-09-14): admin can list member ids (Settings > No-payout positions) whose wallets must never be paid again (e.g. a compromised key). Those positions stay linked for history and counting only: the buy-from picker disables them, a purchase from them is refused, and invite links that would place a new member under them (or under their upline chain) route to the fallback sponsor instead. The contract itself cannot change a member's wallet.
|
||||
- LINE AT A GLANCE, ALL LEVELS (2026-09-14): a gold chip on any level means that person made their $20+ buy (a qualifying buyer for their own sponsor); a small number on the chip is how many qualifying buyers of their own they have. My line rows say the same in words. Leaders use it to see who is one buyer short and encourage them.
|
||||
- MY LINE SPONSOR LINE (2026-09-14): every row on My line, all three levels, shows who sponsored that person ("sponsored by @name", or "you" for directs).
|
||||
- MY LINE ACTIVITY DROP-DOWN (2026-09-14): every row on My line, all three levels, has an Activity button that opens that person's activity: last seen, joined, stage and next step, ads viewed today and claim streak, campaigns active, link views in 30 days and joins, directs and qualifying buyers, wallet/payouts, badges, and a Working or Quiet verdict. Read-only, phone friendly.
|
||||
- GETTING STARTED CARD (2026-09-14): the top of every new member's Overview shows four steps (username, link wallet, switch on payouts, first package) with the current one explained and one button that opens the right tab and highlights the control (Wallet tab > Link wallet; then Activate payouts). Encouragement only: it can be hidden, and members who only want to view ads and earn credits are never blocked. It disappears once all four are done.
|
||||
- LEADERBOARD + REFERRAL CONTEST (2026-09-14): ${SITE_HOST}/leaderboard ranks members by ad packages sold to people they directly sponsor (dollar value, read from the chain; a member's own linked positions and second accounts never count). Periods: this week (Monday to Sunday, Central time), this month, all time. Weekly and monthly winners are recorded automatically at rollover, announced in Telegram, and the credit prizes set by the admin (a ladder: 1st 1,000 / 2nd 500 / 3rd 250 weekly, 5,000 / 2,500 / 1,000 monthly by default) are granted automatically to those positions; the prize text is shown on the page and on the Overview's Leaderboard card, which also shows the member's own rank. Prizes are credits or packages, never cash.
|
||||
- WHAT'S NEW / ROADMAP (2026-09-14): ' + SITE_HOST + '/whats-new lists release notes (what shipped, dated, tagged new/improved/fixed) and the roadmap (planned / building, with rough ETAs). The Overview has a "What's new" card with the latest three notes and what is being built; a dot marks notes since the member's last look. Written by the admin in Admin > Releases.
|
||||
- HOLDING TANK ALERTS: when new members land in the tank, a note at the top of every member's Overview names them (usernames) and a post goes to the team's Telegram payments topic; adopt from My line > Holding tank (your own $20 package required).
|
||||
- LEGACY WELCOME (former Faucet Wave / Tier One Ads members): they join through ${SITE_HOST}/from/faucetwave or ${SITE_HOST}/from/tieroneads and, if their email is on the legacy list, welcome-back credits are added automatically at signup (former advertisers 500, former earners 150; once per person; credits, not POL). They land in the holding tank like any member who joins without a sponsor.
|
||||
- PROMO CODES: partner site owners get a reusable code; a member redeems it on a join link (?promo=CODE) or in the Overview box "Have a promo code?" and receives free ad credits (amount set per code by the admin, one use per account; codes can cap uses or expire). Credits, not POL.
|
||||
- DORMANT-LEAD RESCUE: a FREE referral (no wallet, no purchase) with no message from their sponsor for 10 days triggers a warning email + dashboard flag to the sponsor ("unreached, tank in N days"); at 14 days (warning at least 4 days old) the lead moves to the holding tank and the sponsor is told. Sponsor resets the clock with a chat, a Nudge, or the "Contacted them" button (for phone/text contact). Leads whose sponsor link resolves to nobody go to the tank after a day. Nothing on-chain moves; anyone bound by a purchase never moves.
|
||||
- PIF (pay it forward) button: on a free direct or an adopted member who has linked a wallet, the sponsor taps PIF, enters an amount (suggested: the $20 package plus fees), and their OWN wallet app opens with the member's address prefilled; the POL goes wallet to wallet. The site never touches the funds; it only logs the transaction and tells the recipient with a Polygonscan link. The gift is theirs; nothing forces a purchase.
|
||||
- FOUNDING WEEK / PRE-LAUNCH (Training > Founding week checklist, /launch, members only): eight items read live from the account: username, wallet linked, payouts on, level 2 qualified (2 buyers of $20+, or Qualified Start with 2 linked positions), the leader play = level 3 (5 qualifying buyers, up to 5 linked positions; then buy from the main wallet), line banner, links + play chosen (self-marked), first two placed. Reason: unqualified levels pass up, so leaders qualify BEFORE their teams' teams buy. Countdown shows when admin sets launchAt. Never call the site 'pre-launch' publicly: it is live and paying.
|
||||
- COUNTRY TARGETING (2026-09-11): New campaign form has "Show to" tier checkboxes (Tier 1 = US, CA, GB, AU, NZ, IE, DE, FR, NL, SE, NO, DK, FI, CH, AT, BE by default; Tier 2 = rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO, etc.; Tier 3 = everyone else; lists editable in Admin > Settings geoTier1/geoTier2). Country comes from the viewer's IP (DB-IP lite). Applies to on-site delivery of every format; a narrowed banner/text ad is NOT sent to the partner network (which is worldwide). Unknown country never matches a narrowed campaign. Campaign rows show 'tier 1+2' chips and top viewer countries.
|
||||
- SCHEDULING (2026-09-11): any campaign except featured can take an optional start and end time (local time) in the New campaign form; solo ads label it "Send from" (inbox deliveries begin then). A scheduled campaign shows "scheduled" until it starts; at the end it shows "ended" and the unspent budget returns to Available. Banner/text scheduled campaigns join the partner network at their start time. There is NO dayparting (hours-of-day targeting) by design; the daily cap paces budgets. Each campaign row shows a small views-by-hour chart (on-site views, viewer's local time, last 7 days).
|
||||
- BALANCE RULE (members ask this a lot): a balance is what is NOT committed to a live campaign. Starting a campaign sets aside its whole budget at once (earned pool first, then purchased), so Available drops once and stays still while ads serve; the budget spends down inside Members > Campaigns. Dashboard shows Purchased available, Earned available, In live campaigns. A paused campaign keeps its unspent budget set aside so it can resume. A low balance with a live campaign is not lost credits. Refunds/comps of purchased money are credited off-chain as purchased-grade credits: shown under Purchased as "credited to you", fund anything incl. login ads. Viewing-earned credits never fund login ads.
|
||||
- Members EARN credits by attention: in the Earn credits section of Members, each ad in the daily set opens FULL SCREEN in its own tab, showing the advertiser's real website. A countdown runs while you watch (it pauses if you leave the tab), then a quick human check (click the named icon) must be passed before the view counts. Finish the daily set, claim a small daily credit batch. Earned credits spend on banner and text campaigns; attention earns advertising, referrals earn money, and viewer rewards are never cash. Advertisers get real, verified visits to their site.
|
||||
- Onsite SOLO ADS are live: a solo ad is a full message (subject + up to 2000 characters of formatted text + your link) delivered into members' on-site Inbox (Members > Inbox). The composer in Campaigns > Solo ad has a rich-text editor (bold, headings, lists, links), lets you ATTACH one image (PNG/JPG/WebP/GIF, up to 3MB) or one video (MP4/WebM, up to 25MB), and adds a call-to-action button with a custom label that opens the target URL. Cost 5 credits per guaranteed delivery, minimum 10 deliveries (50 credits). Each member receives a given solo at most once, and never the sender's own. Readers earn 2 credits per real read (10-second dwell on the open message, up to 5 rewarded reads/day) — claimed right from the message. Compose one in Campaigns > Solo ad.
|
||||
- Campaign target URLs are checked the moment they are submitted: the page must be reachable and must ALLOW framing (no X-Frame-Options deny/sameorigin, no blocking CSP frame-ancestors), because surf views show the real site full screen. Frame-blocking or dead URLs are rejected with the exact reason; the fix is a landing page that allows framing. Login-ad targets skip the frame check (they are click-through only).
|
||||
- SPONSOR CHAT (Members): a two-way, one-to-one chat. A member can start a conversation with their DIRECT sponsor; a sponsor can message anyone in their downline. Presence-aware — when both are online it is live, otherwise a message waits in the recipient's on-site inbox and sends an email. Each member has an availability toggle in Profile (default on; turning it off stops live chats but people can still leave a note) and can mute a specific person. This is separate from the once-a-day sponsor BROADCAST to the whole downline.
|
||||
- Every purchase is split by an immutable smart contract in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. No withdrawals exist; money lands in members' own wallets instantly.
|
||||
- Qualification: level 1 open to all; 2 buyers of $20+ unlock level 2; 5 unlock level 3. Unqualified shares pass up the sponsor line, checking up to 25 positions, else the platform receives them. Qualification cannot be bought and never expires.
|
||||
- Every member gets a share link immediately (site code, /join/<code>); the contract locks a buyer to their sponsor at the buyer's FIRST purchase, so members should switch on payouts before their referrals buy.
|
||||
- Transparency: live ledger at /ledger streams every chain event, and EVERY transaction row carries a clickable "verify" link — to the public block explorer when the chain has one, or to the built-in transaction viewer at /tx/<hash> (block, time, from/to, value, gas, decoded events, read live from the node). Plain-language contract review at /contract; the verified source is public.
|
||||
- The contract cannot be paused, upgraded, or drained. The operator can only manage the ad catalog ($1-$500 bounds, 24h price timelock) and rotate keys.
|
||||
- PRODUCT, all free with an email account: SPIN LINKS (the rotator: one short link, /r/<code>, rotates between destinations by weight; pause any destination; a fallback for when all are off; one-hop redirect; every click recorded with day, country, source, device and a daily-salted visitor hash; bots filtered on the server; click ids and sub ids such as clickid, subid, s1 to s4 pass through to the destination; split tests by tagging the same link with different sub ids; a demo spin on the home page needs no account; DAYPARTING is live: a 7x24 hours grid per spin and per destination, time zone by name or the local time of the visitor, presets, and 'my best hours' from the clicks of the member after 200 clicks; automatic HEALTH CHECKS are live: every destination is checked every 30 minutes, a dead or parked one is paused after three failing checks and resumed when it passes twice, the owner is told once, and Check now runs it on demand). PAGES (page builder: scan any offer URL, get a bridge, review or squeeze page; designs, palettes, layouts and niche presets with hero images; leads to the member's own list, CSV or webhook; published on the pages domain lookfirst.page; sales, advertorial and press-release layouts are coming). ZONES (an ad slot on the member's own site: one async script tag, nine sizes 728x90, 468x60, 300x250, 336x280, 250x250, 125x125, 160x600, 120x600, 320x50; waterfall = LinkSpin member campaign, then a network ad for 728x90 and 468x60, then the LinkSpin house banner; pays ad credits per VIEWABLE impression, half the banner on screen for one second, bots never, 50 credited views per visitor per zone per day; rates 1 credit per 5 viewable member-ad views and 1 per 10 network-ad views, 1 per 8 on a Verified zone; warm-up: a zone earns after its first 100 on-site views with at least 40 percent viewable and goes on hold below that; origin lock: paid ads serve only on the declared site and its subdomains, elsewhere the house banner shows and nothing is earned; up to 50 zones per account; PUBLISHER PROGRAM at /publishers for site owners, tiers Standard (default) and Verified (admin-reviewed site, better network rate)). AUDIENCES (first-party retargeting: "My visitors" collects everyone who viewed the member's pages and zones for 30 days; a pixel tag /p.js for other sites; campaigns can "show only to" or "never show to" an audience; nothing personal stored). PROMO TOOLS at /tools#promo (social posts, text-a-friend, email swipes, banners, objection bank, hook videos; five hook angles with videos: links, pages, zones, audiences, stack; angle links are the invite link plus ?v=). REPORTS (every link in one view). BLOG at /blog with RSS at /blog/feed.xml.
|
||||
- PACKAGES (priced in dollars, settled in POL at the live rate, 1 credit = 1 cent of ad delivery): $10 door = 1,000 credits, for trying the ads, does NOT count toward qualification; $25 Starter = 2,500; $50 Builder = 5,000; $100 Growth = 10,000; $250 Leader = 25,000; $500 Network = 50,000. Any package of $25 or more makes the buyer a qualifying buyer for their sponsor.
|
||||
- THE SPLIT, same transaction on Polygon, fixed in the contract: 50 percent direct sponsor, 20 percent level 2, 10 percent level 3, 10 percent + 10 percent to the two admin wallets. Level 1 pays from a referral's first qualifying purchase once the sponsor's payouts are on. Level 2 opens after two of the member's people buy a qualifying ($25 or larger) package, level 3 after five. An unfilled tier passes up the line to the next qualified member, then to the platform. Nothing is held, there are no withdrawals, no pending balances. Contract ${CONTRACT} on Polygon, verified on Polygonscan; plain-language review at ${SITE_URL}/contract; live ledger at ${SITE_URL}/ledger with a verify link on every row.
|
||||
- CREDITS VS POL: every member, free ones included, earns CREDITS (zones, the daily ad set with a claim streak, watch-to-earn videos, verified visits, a daily sign-in bonus). Credits buy the member's own banner and text ads (the login spot takes purchased credits) and NEVER cash out or convert to crypto. POL only reaches a wallet through the contract split when a package sells in the member's line. Never promise or estimate income.
|
||||
- AD FORMATS members buy with credits: banner ads (standard sizes), text ads, full-screen login ads (one sponsor a day, purchased credits), plus solo ads to member inboxes, watch-to-earn video, verified visits. Banner and text ads also run on member zones and the partner network.
|
||||
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first) and any WalletConnect wallet work; Trust Wallet blocks a buy that spends most of its POL. MoonPay card on-ramp from the Credits screen puts POL on Polygon into the member's own wallet.
|
||||
- SPONSOR: the invite link opened most recently sets the sponsor (30-day cookie), shown on the join page, locked when the account is created; the contract binds the buyer to that sponsor at the first purchase. CARRY-OVER: Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their InstantAdPay sponsor from the network registry automatically when no invite link was used. Wrong sponsor before the first purchase: the admin can move the account. Members should switch on payouts before their people buy.
|
||||
- CONTROL ROOM screens: Links, Pages, Zones (with Audiences), Ads, Credits, Reports, Team (three levels, who has payouts on, who bought, qualifying-buyer counts), Wallet (what was paid to this wallet, payout history). More at ${SITE_URL}/tools: Promo tools, Training, Pipeline (a follow-up board for prospects and directs), My line (including the holding tank: members who joined with no sponsor wait there and can be adopted by a member with payouts on and their own qualifying package), Profile.
|
||||
- Leaderboard at ${SITE_URL}/leaderboard ranks members by packages sold to direct referrals (weekly, monthly, all time; prizes are credits, never cash). Release notes and roadmap at ${SITE_URL}/whats-new.
|
||||
- InstantAdPay is the sister property in the same network, not this site. Do not describe InstantAdPay mechanics (holding-tank rescue emails, Five Dollar Friday, Wired Wednesday, games, mint passes, surf earn tab) as LinkSpin features.
|
||||
|
||||
RULES:
|
||||
- 1 to 4 sentences, plain text, no markdown, include full URLs when pointing at a page.
|
||||
- NEVER promise or estimate income. This is an advertising service with a referral program, never an investment. Be honest about risk: crypto transactions are irreversible, nobody earns unless real ad purchases happen.
|
||||
- No em dashes. If you do not know, say so and point to /contract or the ledger.`;
|
||||
- NEVER promise or estimate income. This is an advertising service with a referral program, never an investment. Be honest about risk: crypto transactions are irreversible, nobody earns unless real ad purchases happen in their line.
|
||||
- No em dashes. If you do not know, say so and point to ${SITE_URL}/contract or the ledger.`;
|
||||
}
|
||||
|
||||
function askAI(message, historyText) {
|
||||
@@ -158,7 +132,7 @@ async function answer(message, historyText) {
|
||||
const msg = String(message || '').trim();
|
||||
if (!msg) return { error: 'Say something first.' };
|
||||
for (const c of CANNED) if (c.re.test(msg)) return { reply: c.a, canned: true };
|
||||
if (!enabled()) return { reply: 'Good question. The quick answers I have cover packages, payouts, qualification, and joining; for anything deeper, the plain-language contract review at ' + SITE_URL + '/contract covers most of it.' };
|
||||
if (!enabled()) return { reply: 'Good question. The quick answers I have cover spin links, pages, zones, packages, the payout split, qualification and joining; for anything deeper, the plain-language contract review at ' + SITE_URL + '/contract and the publisher page at ' + SITE_URL + '/publishers cover most of it.' };
|
||||
try { return { reply: await askAI(msg, historyText) }; }
|
||||
catch (e) {
|
||||
console.error('chat AI failed', e.message);
|
||||
@@ -166,4 +140,4 @@ async function answer(message, historyText) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { init, answer, enabled };
|
||||
module.exports = { init, answer, enabled, CANNED };
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
// LinkSpin link-domain pool (2026-10-10): the short link domains in siteConfig().linkDomains, each assigned to a
|
||||
// CHANNEL (email / messaging / social / reserve) so a domain that burns on one channel never takes the others with
|
||||
// it, plus safety checks every six hours (Google Safe Browsing when GSB_API_KEY is set, URIBL + SURBL DNS lists, a
|
||||
// Telegram-like reachability probe). A domain flagged by GSB or listed by URIBL/SURBL is BURNED: it drops out of
|
||||
// live() (no new links or pages are handed out on it; existing /r/ codes keep resolving) and the admin is told once.
|
||||
// State: DATA_DIR/domains.json. Channel map: siteConfig().linkDomainChannels ("host:channel,host:channel" or an
|
||||
// object); unset = first domain email, second messaging, third social, fourth email, fifth reserve.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const dns = require('dns').promises;
|
||||
|
||||
let DATA_DIR = null, siteConfig = () => ({}), saveSite = () => {}, notify = () => {}, gsbKey = () => '';
|
||||
const CHANNELS = ['email', 'messaging', 'social', 'reserve'];
|
||||
const LABEL = { email: 'Email', messaging: 'Messaging', social: 'Social', reserve: 'Reserve' };
|
||||
const NOTE = { email: 'Email and safelist mailings', messaging: 'Telegram, WhatsApp and SMS', social: 'X, Facebook, forums and comments', reserve: 'Held back, never handed out' };
|
||||
const DEFAULT_ORDER = ['email', 'messaging', 'social', 'email', 'reserve'];
|
||||
const CHECK_EVERY = 6 * 60 * 60 * 1000;
|
||||
const J = { db: null, FILE: () => path.join(DATA_DIR, 'domains.json'),
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, domains: {} }; } if (!this.db.domains) this.db.domains = {}; },
|
||||
save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db, null, 1)); } catch (e) {} } };
|
||||
let timer = null;
|
||||
function init(opts) {
|
||||
DATA_DIR = opts.dataDir; siteConfig = opts.siteConfig || siteConfig; saveSite = opts.saveSite || saveSite; notify = opts.notify || notify;
|
||||
gsbKey = opts.gsbKey || (() => String(process.env.GSB_API_KEY || '').trim());
|
||||
J.load();
|
||||
if (opts.schedule !== false) { setTimeout(() => checkAll().catch(() => {}), 2 * 60 * 1000); timer = setInterval(() => checkAll().catch(() => {}), CHECK_EVERY); if (timer.unref) timer.unref(); }
|
||||
}
|
||||
const norm = h => String(h || '').trim().toLowerCase().replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace(/^www\./, '');
|
||||
// the configured domains, www stripped and deduped, in the order Marty listed them
|
||||
function configured() { const seen = new Set(); const out = []; for (const raw of String(siteConfig().linkDomains || '').split(',')) { const h = norm(raw); if (h && !seen.has(h)) { seen.add(h); out.push(h); } } return out; }
|
||||
function channelMap() {
|
||||
const raw = siteConfig().linkDomainChannels; const map = {};
|
||||
if (raw && typeof raw === 'object') { for (const [k, v] of Object.entries(raw)) if (CHANNELS.includes(v)) map[norm(k)] = v; }
|
||||
else for (const part of String(raw || '').split(',')) { const [k, v] = part.split(':').map(x => String(x || '').trim().toLowerCase()); if (k && CHANNELS.includes(v)) map[norm(k)] = v; }
|
||||
return map;
|
||||
}
|
||||
function channelOf(host, idx, map) { map = map || channelMap(); return map[host] || DEFAULT_ORDER[idx] || 'reserve'; }
|
||||
function stateOf(host) { return J.db.domains[host] || { checkedAt: 0, gsb: 'unknown', uribl: 'unknown', surbl: 'unknown', reach: 'unknown', burned: false, burnedAt: 0, reason: '' }; }
|
||||
// every configured domain with its channel and last check
|
||||
function all() { const map = channelMap(); return configured().map((host, i) => Object.assign({ host, channel: channelOf(host, i, map), label: LABEL[channelOf(host, i, map)], note: NOTE[channelOf(host, i, map)] }, stateOf(host))); }
|
||||
// the domains that may be handed out: not burned, not reserve (opts.includeReserve keeps reserve ones)
|
||||
function live(opts) { return all().filter(d => !d.burned && ((opts && opts.includeReserve) || d.channel !== 'reserve')).map(d => d.host); }
|
||||
// for the member Links screen: live hosts with the channel they are meant for
|
||||
function hosts() { return all().filter(d => !d.burned && d.channel !== 'reserve').map(d => ({ host: d.host, channel: d.channel, label: d.label, note: d.note })); }
|
||||
function isBurned(host) { return !!stateOf(norm(host)).burned; }
|
||||
function setChannel(host, channel) {
|
||||
host = norm(host); if (!configured().includes(host)) return { error: 'That domain is not in linkDomains.' };
|
||||
if (!CHANNELS.includes(channel)) return { error: 'Channel must be one of ' + CHANNELS.join(', ') + '.' };
|
||||
const map = channelMap(); const list = configured(); for (let i = 0; i < list.length; i++) if (!map[list[i]]) map[list[i]] = channelOf(list[i], i, map);
|
||||
map[host] = channel;
|
||||
saveSite({ linkDomainChannels: list.map(h => h + ':' + map[h]).join(',') });
|
||||
return { ok: true, domains: all() };
|
||||
}
|
||||
// -- checks
|
||||
function gsbLookup(host) {
|
||||
const key = gsbKey(); if (!key) return Promise.resolve('unknown');
|
||||
return new Promise(resolve => {
|
||||
const body = JSON.stringify({ client: { clientId: 'linkspin', clientVersion: '1.0' }, threatInfo: { threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING', 'UNWANTED_SOFTWARE'], platformTypes: ['ANY_PLATFORM'], threatEntryTypes: ['URL'], threatEntries: [{ url: 'https://' + host + '/' }, { url: 'http://' + host + '/' }] } });
|
||||
const rq = https.request({ hostname: 'safebrowsing.googleapis.com', path: '/v4/threatMatches:find?key=' + encodeURIComponent(key), method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 10000 }, res => {
|
||||
let d = ''; res.on('data', c => d += c); res.on('end', () => { if (res.statusCode !== 200) return resolve('unknown'); try { const j = JSON.parse(d || '{}'); resolve(Array.isArray(j.matches) && j.matches.length ? 'flagged' : 'clean'); } catch (e) { resolve('unknown'); } });
|
||||
});
|
||||
rq.on('timeout', () => { rq.destroy(); resolve('unknown'); }); rq.on('error', () => resolve('unknown')); rq.end(body);
|
||||
});
|
||||
}
|
||||
// an answer means listed, NXDOMAIN means clean, anything else is unknown. 127.0.0.1 is the lists' "query refused /
|
||||
// public resolver blocked" code, not a listing, so it is unknown too.
|
||||
async function dnsList(host, zone) {
|
||||
try { const a = await dns.resolve4(host + '.' + zone); if (!a.length) return 'clean'; if (a.every(ip => ip === '127.0.0.1')) return 'unknown'; return 'listed'; }
|
||||
catch (e) { return (e && (e.code === 'ENOTFOUND' || e.code === 'ENODATA')) ? 'clean' : 'unknown'; }
|
||||
}
|
||||
// did the domain answer a Telegram-like fetch of its front door (preview bots must be able to reach it)
|
||||
function reach(host) {
|
||||
return new Promise(resolve => {
|
||||
const rq = https.get({ hostname: host, path: '/', headers: { 'User-Agent': 'TelegramBot (like TwitterBot)', Accept: 'text/html,*/*' }, timeout: 8000 }, res => { res.resume(); resolve('ok:' + res.statusCode); });
|
||||
rq.on('timeout', () => { rq.destroy(); resolve('unknown'); }); rq.on('error', () => resolve('unknown'));
|
||||
});
|
||||
}
|
||||
async function check(host) {
|
||||
host = norm(host); if (!configured().includes(host)) return { error: 'That domain is not in linkDomains.' };
|
||||
const [gsb, uribl, surbl, rch] = await Promise.all([gsbLookup(host), dnsList(host, 'multi.uribl.com'), dnsList(host, 'multi.surbl.org'), reach(host)]);
|
||||
const prev = stateOf(host); const reasons = [];
|
||||
if (gsb === 'flagged') reasons.push('Google Safe Browsing flagged it'); if (uribl === 'listed') reasons.push('listed on URIBL'); if (surbl === 'listed') reasons.push('listed on SURBL');
|
||||
const burnedNow = reasons.length > 0;
|
||||
const rec = Object.assign({}, prev, { checkedAt: Date.now(), gsb, uribl, surbl, reach: rch });
|
||||
// a burned domain stays burned when the lists come clean again: lists flap, and putting it back is an admin decision (clear())
|
||||
if (burnedNow) { rec.reason = reasons.join(', '); if (!prev.burned) { rec.burned = true; rec.burnedAt = Date.now(); rec.notified = false; } }
|
||||
J.db.domains[host] = rec; J.save();
|
||||
if (rec.burned && !rec.notified) {
|
||||
rec.notified = true; J.save();
|
||||
const list = all(); const alive = list.filter(d => !d.burned && d.channel !== 'reserve').map(d => d.host);
|
||||
const ch = list.find(d => d.host === host); const text = '⚠️ <b>LinkSpin</b> · link domain <b>' + host + '</b> (' + (ch ? ch.label : '') + ' channel) is BURNED: ' + rec.reason + '. It is out of the pool for new links and pages; existing /r/ links still resolve. Live domains now: ' + (alive.join(', ') || 'none') + '. Admin > Link domains to review or clear.';
|
||||
try { await notify(text, host, rec); } catch (e) {}
|
||||
}
|
||||
return { ok: true, domain: Object.assign({ host }, rec) };
|
||||
}
|
||||
async function checkAll() { const out = []; for (const h of configured()) { try { out.push(await check(h)); } catch (e) { out.push({ host: h, error: e.message }); } } return out; }
|
||||
// admin override: a list came clean again or the flag was a mistake; the domain goes back into the pool
|
||||
function clear(host) { host = norm(host); const rec = stateOf(host); rec.burned = false; rec.burnedAt = 0; rec.reason = ''; rec.notified = false; J.db.domains[host] = rec; J.save(); return { ok: true, domains: all() }; }
|
||||
// admin can also pull a domain by hand (a complaint, a flap elsewhere) without waiting for a list
|
||||
function burn(host, why) { host = norm(host); if (!configured().includes(host)) return { error: 'That domain is not in linkDomains.' }; const rec = stateOf(host); rec.burned = true; rec.burnedAt = Date.now(); rec.reason = String(why || 'pulled by admin').slice(0, 200); rec.notified = true; J.db.domains[host] = rec; J.save(); return { ok: true, domains: all() }; }
|
||||
module.exports = { init, CHANNELS, LABEL, NOTE, all, live, hosts, isBurned, setChannel, check, checkAll, clear, burn, configured };
|
||||
+40
-1
@@ -62,4 +62,43 @@ function html(parsed, defaultButton) {
|
||||
const inputs = parsed.fields.map(f => '<input class="lsin" type="' + f.type + '" name="' + escAttr(f.name) + '" placeholder="' + escAttr(f.placeholder) + '"' + (f.value ? ' value="' + escAttr(f.value) + '"' : '') + (f.required || f.type === 'email' ? ' required' : '') + '>').join('\n');
|
||||
return [open, hidden, inputs, '<button type="submit" class="cta">' + escAttr((parsed.buttonText || '').trim() || defaultButton) + '</button>', '</form>'].join('\n');
|
||||
}
|
||||
module.exports = { EMBED_MAX_CHARS, problem, parse, html };
|
||||
// -- known autoresponder providers (2026-10-10): the allowlist is about CLARITY, not blocking. A recognised action host
|
||||
// gets "Recognised: AWeber"; anything else is kept as a plain post to <host> with a note that we cannot vouch for it.
|
||||
// Hosts match the action host or any subdomain of it; `path` (a regex source) narrows by action path, e.g. Sendy on any host.
|
||||
const PROVIDERS = [
|
||||
{ name: 'AWeber', hosts: ['aweber.com'] },
|
||||
{ name: 'GetResponse', hosts: ['getresponse.com', 'getresponse.net', 'gr8.com'] },
|
||||
{ name: 'Mailchimp', hosts: ['list-manage.com', 'mailchimp.com'] },
|
||||
{ name: 'Kit (ConvertKit)', hosts: ['convertkit.com', 'kit.com', 'ck.page'] },
|
||||
{ name: 'ActiveCampaign', hosts: ['activehosted.com', 'activecampaign.com'] },
|
||||
{ name: 'MailerLite', hosts: ['mailerlite.com', 'mailerlite.io'] },
|
||||
{ name: 'SendFox', hosts: ['sendfox.com'] },
|
||||
{ name: 'systeme.io', hosts: ['systeme.io'] },
|
||||
{ name: 'Drip', hosts: ['getdrip.com'] },
|
||||
{ name: 'Sendy', hosts: [], path: '(^|/)subscribe/?$' },
|
||||
{ name: 'Brevo', hosts: ['sibforms.com', 'brevo.com', 'sendinblue.com'] },
|
||||
{ name: 'Constant Contact', hosts: ['constantcontact.com', 'constantcontactpages.com'] },
|
||||
{ name: 'Klaviyo', hosts: ['klaviyo.com'] },
|
||||
{ name: 'Moosend', hosts: ['moosend.com'] },
|
||||
{ name: 'Benchmark Email', hosts: ['benchmarkemail.com'] },
|
||||
{ name: 'beehiiv', hosts: ['beehiiv.com'] },
|
||||
{ name: 'Substack', hosts: ['substack.com'] }
|
||||
];
|
||||
function actionOf(embed) {
|
||||
const forms = String(embed || '').match(/<form\b[\s\S]*?<\/form>/gi); if (!forms || !forms.length) return null;
|
||||
const tag = forms[0].match(/<form\b[^>]*>/i); const a = tag ? attr(tag[0], 'action') : null;
|
||||
if (!a || !/^https?:\/\//i.test(a)) return null;
|
||||
try { return new URL(a); } catch (e) { return null; }
|
||||
}
|
||||
// { host, known, name, label, note } for a pasted form, or null when there is no usable action
|
||||
function provider(embed) {
|
||||
const u = actionOf(embed); if (!u) return null;
|
||||
const host = u.hostname.toLowerCase().replace(/^www\./, '');
|
||||
for (const pr of PROVIDERS) {
|
||||
const hostHit = pr.hosts.some(h => host === h || host.endsWith('.' + h));
|
||||
const pathHit = pr.path ? new RegExp(pr.path, 'i').test(u.pathname) : false;
|
||||
if ((pr.hosts.length && hostHit) || (!pr.hosts.length && pathHit)) return { host, known: true, name: pr.name, label: 'Recognised: ' + pr.name, note: 'Submissions go to ' + host + '.' };
|
||||
}
|
||||
return { host, known: false, name: '', label: 'Unknown provider', note: 'The form is kept as a plain post to ' + host + '; we cannot vouch for it.' };
|
||||
}
|
||||
module.exports = { EMBED_MAX_CHARS, PROVIDERS, problem, parse, html, provider };
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// Destination health checks (LinkSpin, 2026-10-10): every 30 minutes each ACTIVE destination of every rotation
|
||||
// (and the fallback) is fetched with a browser-like UA, HEAD first then GET when the server refuses HEAD or when
|
||||
// the page is HTML (the body is what tells a parked page from a live one). States: ok, slow (over 6 s), dead
|
||||
// (network error, timeout, 404/410/5xx), parked (parking-page signatures). Three failing checks in a row pause
|
||||
// the destination (d.active = false, d.autoPaused = when); a paused one is re-checked every 6 hours and comes back
|
||||
// on its own after two clean passes, but only when LinkSpin paused it, never when the owner did. The last live
|
||||
// destination of a rotation with no fallback is never paused: a redirect to something beats a dead end.
|
||||
// frameBlocked is informational: LinkSpin links run inside traffic-exchange frames, so the owner wants to know.
|
||||
// At most 4 requests in flight at once. A small event log (Central-time day keys) sits at DATA_DIR/health-log.json.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let rotator = null, DATA_DIR = null, notify = null;
|
||||
const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Safari/537.36 LinkSpinHealth/1.0';
|
||||
const TIMEOUT = 10000, SLOW = 6000, MAX_REDIRECTS = 5, PARALLEL = 4, FAILS_TO_PAUSE = 3, PASSES_TO_RESUME = 2;
|
||||
const RECHECK_PAUSED = 6 * 3600 * 1000, MANUAL_GAP = 60 * 1000;
|
||||
const PARKED = /domain is for sale|this domain (?:is|may be) for sale|parked free|sedoparking|sedo\.com\/search|buy this domain|godaddy\.com\/parked|hugedomains|afternic|\bdan\.com\b|parkingcrew|bodis\.com|domain parking|this domain has expired|<title>\s*(?:default web page|welcome to nginx!?|apache2 .* default page|index of \/|website coming soon|domain default page)\s*<\/title>/i;
|
||||
const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
const L = { file: () => path.join(DATA_DIR, 'health-log.json'), db: null,
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.file(), 'utf8')); } catch (e) { this.db = { events: [] }; } },
|
||||
add(ev) { if (!this.db) this.load(); this.db.events.push(Object.assign({ ts: Date.now(), day: ctDay(Date.now()) }, ev)); if (this.db.events.length > 500) this.db.events = this.db.events.slice(-400); try { fs.writeFileSync(this.file(), JSON.stringify(this.db)); } catch (e) {} } };
|
||||
|
||||
function init(opts) { rotator = opts.rotator; DATA_DIR = opts.dataDir; notify = opts.notify || null; L.load(); }
|
||||
|
||||
// one request with a hard timeout; returns the Response or throws
|
||||
async function req(url, method, signalMs) {
|
||||
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), signalMs || TIMEOUT);
|
||||
try { return await fetch(url, { method, redirect: 'manual', signal: ac.signal, headers: { 'User-Agent': UA, Accept: 'text/html,application/xhtml+xml,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.8' } }); }
|
||||
finally { clearTimeout(t); }
|
||||
}
|
||||
// follow up to MAX_REDIRECTS by hand (so the chain is bounded and the final URL is known)
|
||||
async function follow(url, method) {
|
||||
let u = url, hops = 0, res;
|
||||
for (;;) {
|
||||
res = await req(u, method);
|
||||
if (res.status >= 300 && res.status < 400 && res.headers.get('location') && hops < MAX_REDIRECTS) {
|
||||
try { res.body && res.body.cancel && res.body.cancel().catch(() => {}); } catch (e) {}
|
||||
u = new URL(res.headers.get('location'), u).toString(); hops++; continue;
|
||||
}
|
||||
return { res, finalUrl: u, hops };
|
||||
}
|
||||
}
|
||||
// read at most 64 KB of a body
|
||||
async function head64k(res) {
|
||||
if (!res.body) return '';
|
||||
const reader = res.body.getReader(); const chunks = []; let n = 0;
|
||||
try { while (n < 65536) { const { done, value } = await reader.read(); if (done) break; chunks.push(value); n += value.length; } } catch (e) {}
|
||||
try { reader.cancel().catch(() => {}); } catch (e) {}
|
||||
return Buffer.concat(chunks.map(c => Buffer.from(c))).toString('utf8');
|
||||
}
|
||||
const frameBlocked = h => {
|
||||
const xfo = String(h.get('x-frame-options') || '').toLowerCase(); if (/deny|sameorigin/.test(xfo)) return true;
|
||||
const csp = String(h.get('content-security-policy') || '').toLowerCase(); const m = /frame-ancestors([^;]*)/.exec(csp);
|
||||
if (m) { const v = m[1].trim(); return !(v === '*' || /(^|\s)https?:(\s|$)|\*/.test(v)); }
|
||||
return false;
|
||||
};
|
||||
// classify one URL -> { state, code, ms, note, frameBlocked, finalUrl }
|
||||
async function check(url) {
|
||||
const t0 = Date.now();
|
||||
let out = { state: 'dead', code: 0, ms: 0, note: '', frameBlocked: false, finalUrl: url };
|
||||
try {
|
||||
let { res, finalUrl } = await follow(url, 'HEAD');
|
||||
let ms = Date.now() - t0; out.finalUrl = finalUrl;
|
||||
const ctype = () => String(res.headers.get('content-type') || '').toLowerCase();
|
||||
let body = '';
|
||||
if (res.status === 405 || res.status === 501 || res.status === 403 || (res.status >= 200 && res.status < 300 && /html/.test(ctype()))) {
|
||||
// the server refuses HEAD, or the page is HTML (we need the body to spot a parking page)
|
||||
try { res.body && res.body.cancel && res.body.cancel().catch(() => {}); } catch (e) {}
|
||||
const t1 = Date.now(); const g = await follow(url, 'GET'); res = g.res; out.finalUrl = g.finalUrl; ms = Date.now() - t1;
|
||||
if (/html/.test(ctype())) body = await head64k(res); else { try { res.body && res.body.cancel && res.body.cancel().catch(() => {}); } catch (e) {} }
|
||||
} else { try { res.body && res.body.cancel && res.body.cancel().catch(() => {}); } catch (e) {} }
|
||||
out.code = res.status; out.ms = ms; out.frameBlocked = frameBlocked(res.headers);
|
||||
if (res.status === 404 || res.status === 410 || res.status >= 500) { out.state = 'dead'; out.note = 'HTTP ' + res.status; }
|
||||
else if (body && PARKED.test(body)) { out.state = 'parked'; out.note = 'Parked page'; }
|
||||
else if (res.status >= 200 && res.status < 400) { out.state = ms > SLOW ? 'slow' : 'ok'; out.note = ms > SLOW ? 'Slow, ' + (ms / 1000).toFixed(1) + ' s' : ''; }
|
||||
else { out.state = 'ok'; out.note = 'HTTP ' + res.status + ' to our checker (a bot wall, most likely); visitors may still get through'; }
|
||||
} catch (e) {
|
||||
out.ms = Date.now() - t0; out.state = 'dead';
|
||||
out.note = (e && e.name === 'AbortError') ? 'No answer in 10 s' : ('Could not connect' + (e && e.cause && e.cause.code ? ' (' + e.cause.code + ')' : ''));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
const failing = s => s === 'dead' || s === 'parked';
|
||||
const when = ts => new Date(ts).toLocaleDateString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric' });
|
||||
|
||||
// apply a fresh result to a destination record: counters, auto-pause, auto-resume. Returns a change note or null.
|
||||
function apply(r, d, c) {
|
||||
const prev = d.health || {}; const now = Date.now();
|
||||
const fails = failing(c.state) ? (prev.fails || 0) + 1 : 0;
|
||||
const passes = failing(c.state) ? 0 : (prev.passes || 0) + 1;
|
||||
d.health = { state: c.state, code: c.code, ms: c.ms, checkedAt: now, fails, passes, note: c.note, frameBlocked: !!c.frameBlocked };
|
||||
if (d.active && fails >= FAILS_TO_PAUSE) {
|
||||
const others = r.destinations.filter(x => x !== d && x.active);
|
||||
if (!others.length && !r.fallback) { d.health.note = (c.note || c.state) + '. Kept live: it is the only destination and there is no fallback.'; return null; }
|
||||
d.active = false; d.autoPaused = now; d.health.passes = 0;
|
||||
L.add({ ev: 'pause', r: r.id, d: d.id, url: d.url, state: c.state, note: c.note });
|
||||
return { kind: 'paused', text: (c.state === 'parked' ? 'Parked page' : 'Dead page') + ', auto-paused ' + when(now) };
|
||||
}
|
||||
if (!d.active && d.autoPaused && passes >= PASSES_TO_RESUME) {
|
||||
d.active = true; delete d.autoPaused; d.health.fails = 0;
|
||||
L.add({ ev: 'resume', r: r.id, d: d.id, url: d.url, state: c.state });
|
||||
return { kind: 'resumed', text: 'Back up, resumed ' + when(now) };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async function tell(r, d, change) {
|
||||
if (!notify || !change || change.kind !== 'paused' || /^demo:/.test(r.owner)) return;
|
||||
const esc = s => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
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>'
|
||||
+ '<p><span style="font-family:monospace">' + esc(d.url) + '</span><br>' + esc(d.health.note || d.health.state) + '</p>'
|
||||
+ '<p>Visitors keep flowing to your other destinations' + (r.fallback ? ' and the fallback' : '') + '. If the page comes back, LinkSpin resumes it on its own after two clean checks. You can also fix the address or resume it yourself under Links.</p>';
|
||||
try { await notify(r.owner, 'A destination in ' + r.name + ' was paused', html); } catch (e) {}
|
||||
}
|
||||
// run a list of jobs, at most PARALLEL at once
|
||||
async function runAll(jobs) {
|
||||
let i = 0; const workers = new Array(Math.min(PARALLEL, jobs.length)).fill(0).map(async () => { while (i < jobs.length) { const j = jobs[i++]; try { await j(); } catch (e) {} } });
|
||||
if (workers.length) await Promise.all(workers);
|
||||
}
|
||||
let running = false;
|
||||
// the scheduled pass: active destinations + fallbacks every time; auto-paused destinations when 6 h have gone by
|
||||
async function tick() {
|
||||
if (running || !rotator) return { skipped: true }; running = true;
|
||||
const now = Date.now(); const jobs = []; let changed = false, n = 0;
|
||||
try {
|
||||
for (const r of rotator.rawRotations()) {
|
||||
for (const d of r.destinations) {
|
||||
const due = d.active || (d.autoPaused && (!d.health || now - (d.health.checkedAt || 0) >= RECHECK_PAUSED));
|
||||
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); });
|
||||
}
|
||||
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; });
|
||||
}
|
||||
await runAll(jobs);
|
||||
} finally { running = false; if (changed) rotator.save(); }
|
||||
return { checked: n };
|
||||
}
|
||||
// "Check now" for one rotation (owner-scoped, once a minute): every destination, paused ones too, plus the fallback
|
||||
const lastManual = new Map();
|
||||
async function checkRotation(owner, id) {
|
||||
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.' };
|
||||
lastManual.set(r.id, Date.now());
|
||||
const jobs = r.destinations.map(d => async () => { const c = await check(d.url); const ch = apply(r, d, c); if (ch) await tell(r, d, ch); });
|
||||
if (r.fallback) jobs.push(async () => { const c = await check(r.fallback); r.fallbackHealth = { state: c.state, code: c.code, ms: c.ms, checkedAt: Date.now(), note: c.note, frameBlocked: !!c.frameBlocked }; });
|
||||
await runAll(jobs); rotator.save();
|
||||
return { ok: true, rotation: rotator.pub(r) };
|
||||
}
|
||||
function recent() { if (!L.db) L.load(); return L.db.events.slice(-50).reverse(); }
|
||||
module.exports = { init, tick, check, checkRotation, recent };
|
||||
@@ -13,11 +13,11 @@ const render = require('./pagerender');
|
||||
const style = require('./pagestyle');
|
||||
const formrestyle = require('./formrestyle');
|
||||
|
||||
let DATA_DIR = null, ownHosts = () => [], keyFn = () => '';
|
||||
let DATA_DIR = null, ownHosts = () => [], keyFn = () => '', imageBase = () => '';
|
||||
const J = { db: null, FILE: () => path.join(DATA_DIR, 'pages.json'),
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, pages: [], leads: [], views: [] }; } for (const k of ['pages', 'leads', 'views']) if (!Array.isArray(this.db[k])) this.db[k] = []; },
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, pages: [], leads: [], views: [], images: [] }; } for (const k of ['pages', 'leads', 'views', 'images']) if (!Array.isArray(this.db[k])) this.db[k] = []; },
|
||||
save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db)); } catch (e) {} } };
|
||||
function init(opts) { DATA_DIR = opts.dataDir; ownHosts = opts.ownHosts || (() => []); keyFn = opts.openrouterKey || (() => ''); J.load(); }
|
||||
function init(opts) { DATA_DIR = opts.dataDir; ownHosts = opts.ownHosts || (() => []); keyFn = opts.openrouterKey || (() => ''); imageBase = opts.imageBase || (() => ''); J.load(); }
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const TYPES = ['bridge', 'review', 'squeeze'];
|
||||
const cleanUrl = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s"'<>]+$/i.test(s) && s.length <= 700 ? s : ''; };
|
||||
@@ -28,7 +28,8 @@ const strs = (arr, n, len) => (Array.isArray(arr) ? arr : String(arr || '').spli
|
||||
|
||||
function pub(p) {
|
||||
const views = J.db.views.filter(v => v.p === p.id); const leads = J.db.leads.filter(l => l.p === p.id).length;
|
||||
return { id: p.id, slug: p.slug, type: p.type, title: p.title, status: p.status, design: p.design, content: p.content, scan: p.scan || null, angle: p.angle || '', created: p.created, updated: p.updated, views: views.length, uniques: new Set(views.map(v => v.v)).size, clicks: views.filter(v => v.k === 'cta').length, leads };
|
||||
return { id: p.id, slug: p.slug, type: p.type, title: p.title, status: p.status, design: p.design, content: p.content, scan: p.scan || null, angle: p.angle || '', created: p.created, updated: p.updated, views: views.length, uniques: new Set(views.map(v => v.v)).size, clicks: views.filter(v => v.k === 'cta').length, leads,
|
||||
formProvider: p.type === 'squeeze' && p.content && p.content.formEmbed ? formrestyle.provider(p.content.formEmbed) : null };
|
||||
}
|
||||
async function list(owner) { return J.db.pages.filter(p => p.owner === norm(owner)).sort((a, b) => b.updated - a.updated).map(pub); }
|
||||
async function get(owner, id) { const p = J.db.pages.find(p => p.id === String(id) && p.owner === norm(owner)); return p ? pub(p) : null; }
|
||||
@@ -171,4 +172,85 @@ async function write(owner, id, body) {
|
||||
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 }; }
|
||||
module.exports = { init, TYPES, list, get, bySlug, create, update, html, view, lead, leads, csv, scan, write, totals };
|
||||
// -- 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' });
|
||||
async function summary(owner, days) {
|
||||
const mine = J.db.pages.filter(p => p.owner === norm(owner)); const ids = new Set(mine.map(p => p.id));
|
||||
const since = Date.now() - (Number(days) || 30) * 86400000;
|
||||
const views = J.db.views.filter(v => ids.has(v.p) && v.ts >= since); const leads = J.db.leads.filter(l => l.owner === norm(owner) && l.ts >= since);
|
||||
const shows = views.filter(v => v.k !== 'cta'), clicks = views.filter(v => v.k === 'cta');
|
||||
const dayMap = {}; const dayOf = k => dayMap[k] = dayMap[k] || { day: k, views: 0, u: new Set(), clicks: 0, leads: 0 };
|
||||
for (const v of shows) { const d = dayOf(ctDay(v.ts)); d.views++; d.u.add(v.v); } for (const v of clicks) dayOf(ctDay(v.ts)).clicks++; for (const l of leads) dayOf(ctDay(l.ts)).leads++;
|
||||
const byDay = Object.values(dayMap).sort((a, b) => a.day < b.day ? -1 : 1).map(d => ({ day: d.day, views: d.views, u: d.u.size, clicks: d.clicks, leads: d.leads }));
|
||||
const byPage = mine.map(p => { const vs = shows.filter(v => v.p === p.id); return { id: p.id, title: p.title, slug: p.slug, type: p.type, status: p.status, views: vs.length, uniques: new Set(vs.map(v => v.v)).size, clicks: clicks.filter(v => v.p === p.id).length, leads: leads.filter(l => l.p === p.id).length }; }).sort((a, b) => b.views - a.views);
|
||||
return { pages: mine.length, live: mine.filter(p => p.status === 'published').length, views: shows.length, uniques: new Set(shows.map(v => v.v)).size, clicks: clicks.length, leads: leads.length, byDay, byPage };
|
||||
}
|
||||
// -- hosted images (2026-10-10): png/jpg/webp up to 2 MB, 50 per member, stored under DATA_DIR/uploads/pages/<owner-hash>/<id>.<ext>
|
||||
// and served at /u/pages/<owner-hash>/<id>.<ext>. Re-encoded with sharp when that module is installed (it is not a
|
||||
// dependency today), otherwise magic bytes + size are checked and the file is stored as it came.
|
||||
const IMG_MAX = 50, IMG_BYTES = 2 * 1024 * 1024;
|
||||
const IMG_EXT = { 'image/png': 'png', 'image/jpeg': 'jpg', 'image/webp': 'webp' };
|
||||
const ownerHash = o => crypto.createHash('sha256').update(norm(o)).digest('hex').slice(0, 16);
|
||||
const imgDir = o => path.join(DATA_DIR, 'uploads', 'pages', ownerHash(o));
|
||||
let sharp = null; try { sharp = require('sharp'); } catch (e) { sharp = null; }
|
||||
function sniff(buf) {
|
||||
if (buf.length > 16 && buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47) return 'image/png';
|
||||
if (buf.length > 16 && buf[0] === 0xff && buf[1] === 0xd8 && buf[2] === 0xff) return 'image/jpeg';
|
||||
if (buf.length > 16 && buf.slice(0, 4).toString() === 'RIFF' && buf.slice(8, 12).toString() === 'WEBP') return 'image/webp';
|
||||
return null;
|
||||
}
|
||||
// the request body as { buf, ct }: a raw image body, multipart/form-data (first file part), or JSON { data: <base64 or data: URL> }
|
||||
function readUpload(req) {
|
||||
return new Promise((resolve) => {
|
||||
const ct = String(req.headers['content-type'] || '').toLowerCase(); const chunks = []; let n = 0; let done = false;
|
||||
const fail = msg => { if (!done) { done = true; resolve({ error: msg }); } };
|
||||
req.on('data', c => { n += c.length; if (n > IMG_BYTES * 1.4 + 4096) { req.destroy(); return fail('That image is over 2 MB. Make it smaller and try again.'); } chunks.push(c); });
|
||||
req.on('error', () => fail('Upload interrupted.'));
|
||||
req.on('end', () => {
|
||||
if (done) return; done = true; const raw = Buffer.concat(chunks);
|
||||
try {
|
||||
if (ct.startsWith('multipart/form-data')) {
|
||||
const bm = /boundary=("?)([^";]+)\1/i.exec(ct); if (!bm) return resolve({ error: 'Bad multipart body.' });
|
||||
const boundary = Buffer.from('--' + bm[2]); let pos = raw.indexOf(boundary);
|
||||
while (pos !== -1) {
|
||||
const hs = pos + boundary.length + 2; const he = raw.indexOf('\r\n\r\n', hs); if (he === -1) break;
|
||||
const head = raw.slice(hs, he).toString('latin1'); const next = raw.indexOf(boundary, he + 4); if (next === -1) break;
|
||||
const body = raw.slice(he + 4, next - 2); // strip the CRLF before the next boundary
|
||||
if (/filename=/i.test(head)) { const cm = /content-type:\s*([^\r\n;]+)/i.exec(head); return resolve({ buf: body, ct: cm ? cm[1].trim().toLowerCase() : (sniff(body) || '') }); }
|
||||
pos = next;
|
||||
}
|
||||
return resolve({ error: 'No file in the upload.' });
|
||||
}
|
||||
if (ct.startsWith('application/json')) {
|
||||
const j = JSON.parse(raw.toString('utf8') || '{}'); let data = String(j.data || j.image || ''); let mime = String(j.type || '').toLowerCase();
|
||||
const dm = /^data:([a-z0-9.+\/-]+);base64,/i.exec(data); if (dm) { mime = dm[1].toLowerCase(); data = data.slice(dm[0].length); }
|
||||
const buf = Buffer.from(data.replace(/\s+/g, ''), 'base64'); return resolve({ buf, ct: mime || sniff(buf) || '' });
|
||||
}
|
||||
return resolve({ buf: raw, ct: ct.split(';')[0].trim() });
|
||||
} catch (e) { resolve({ error: 'Could not read the upload.' }); }
|
||||
});
|
||||
});
|
||||
}
|
||||
async function uploadImage(owner, buf, ct) {
|
||||
if (!buf || !buf.length) return { error: 'No image data arrived.' };
|
||||
if (buf.length > IMG_BYTES) return { error: 'That image is over 2 MB. Make it smaller and try again.' };
|
||||
const real = sniff(buf); if (!real || !IMG_EXT[real]) return { error: 'Use a PNG, JPG or WebP image.' };
|
||||
if (ct && IMG_EXT[ct] && ct !== real) return { error: 'That file does not look like a real ' + IMG_EXT[ct].toUpperCase() + '.' };
|
||||
if (J.db.images.filter(i => i.owner === norm(owner)).length >= IMG_MAX) return { error: 'You have ' + IMG_MAX + ' images already. Delete one first.' };
|
||||
let out = buf, mime = real;
|
||||
if (sharp) { try { const img = sharp(buf, { failOn: 'error' }).rotate().resize({ width: 2000, height: 2000, fit: 'inside', withoutEnlargement: true }); out = mime === 'image/png' ? await img.png({ compressionLevel: 9 }).toBuffer() : mime === 'image/webp' ? await img.webp({ quality: 85 }).toBuffer() : await img.jpeg({ quality: 85, mozjpeg: true }).toBuffer(); } catch (e) { return { error: 'That image could not be read.' }; } }
|
||||
const id = crypto.randomBytes(6).toString('hex'); const ext = IMG_EXT[mime]; const dir = imgDir(owner);
|
||||
fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(path.join(dir, id + '.' + ext), out);
|
||||
const rec = { id, owner: norm(owner), h: ownerHash(owner), ext, mime, size: out.length, ts: Date.now() };
|
||||
J.db.images.push(rec); J.save(); return { ok: true, image: pubImage(rec) };
|
||||
}
|
||||
function pubImage(i) { return { id: i.id, url: imageBase() + '/u/pages/' + i.h + '/' + i.id + '.' + i.ext, path: '/u/pages/' + i.h + '/' + i.id + '.' + i.ext, size: i.size, ts: i.ts, type: i.mime }; }
|
||||
async function images(owner) { return J.db.images.filter(i => i.owner === norm(owner)).sort((a, b) => b.ts - a.ts).map(pubImage); }
|
||||
async function removeImage(owner, id) {
|
||||
const i = J.db.images.find(x => x.id === String(id) && x.owner === norm(owner)); if (!i) return { error: 'No such image.' };
|
||||
try { fs.unlinkSync(path.join(imgDir(owner), i.id + '.' + i.ext)); } catch (e) {}
|
||||
J.db.images = J.db.images.filter(x => x !== i); J.save(); return { ok: true, images: await images(owner) };
|
||||
}
|
||||
// the file behind /u/pages/<hash>/<id>.<ext>, only when the index knows it (never a raw directory read)
|
||||
function imageFile(hash, id, ext) { const i = J.db.images.find(x => x.h === String(hash) && x.id === String(id) && x.ext === String(ext)); return i ? { file: path.join(DATA_DIR, 'uploads', 'pages', i.h, i.id + '.' + i.ext), mime: i.mime } : null; }
|
||||
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 };
|
||||
|
||||
+10
-1
@@ -99,6 +99,7 @@
|
||||
<button data-pane="reports" type="button"><svg viewBox="0 0 24 24"><path d="M12 3l9 16H3z"/><path d="M12 10v4M12 17v.5"/></svg>Reports<span class="pill" id="repBadge" hidden></span></button>
|
||||
<button data-pane="traffic" type="button"><svg viewBox="0 0 24 24"><path d="M3 17l6-6 4 4 8-8"/><path d="M14 7h7v7"/></svg>Traffic</button>
|
||||
<button data-pane="zones" type="button"><svg viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18M8 15h8"/></svg>Zones</button>
|
||||
<button data-pane="domains" type="button"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/></svg>Link domains</button>
|
||||
<button data-pane="blog" type="button"><svg viewBox="0 0 24 24"><path d="M4 4h12l4 4v12H4z"/><path d="M8 12h8M8 16h8M8 8h4"/></svg>Blog</button>
|
||||
<button data-pane="releases" type="button"><svg viewBox="0 0 24 24"><path d="M4 6h16M4 12h10M4 18h7"/><circle cx="18" cy="17" r="3"/></svg>Releases</button>
|
||||
<button data-pane="pnl" type="button"><svg viewBox="0 0 24 24"><path d="M4 19V5M4 19h16"/><path d="M8 15l3-4 3 2 5-6"/></svg>P&L</button>
|
||||
@@ -294,6 +295,14 @@
|
||||
<p style="margin:0 0 6px;display:flex;gap:8px;align-items:center"><input class="tfilter small" data-for="znTable" placeholder="Filter zones" style="max-width:260px"><span class="tfilter-count muted small"></span></p><div class="tablewrap"><table class="adm-table" id="znTable"></table></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pane" id="pane-domains" hidden>
|
||||
<div class="card">
|
||||
<div class="card-head"><h3>Link domains</h3><span class="sub" id="dmSub"></span></div>
|
||||
<p class="muted small" style="margin:0 0 10px" id="dmRules">Every short link domain belongs to one channel so a burn on one channel never takes the others down: email (mailings and safelists), messaging (Telegram, WhatsApp, SMS), social (X, Facebook, forums) or reserve (held back, never handed out). Checks run every six hours: Google Safe Browsing (needs GSB_API_KEY on the server), URIBL and SURBL lists, and a Telegram-style reachability probe. A flagged or listed domain is burned: no new links or pages go on it, existing /r/ links still resolve, and you are told once.</p>
|
||||
<p style="margin:0 0 8px;display:flex;gap:8px;align-items:center;flex-wrap:wrap"><button class="btn small" id="dmCheckAll" type="button">Check all now</button><span class="muted small" id="dmGsb"></span></p>
|
||||
<div class="tablewrap"><table class="adm-table" id="dmTable"></table></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pane" id="pane-traffic" hidden>
|
||||
<div class="card">
|
||||
<div class="card-head"><h3>Where visitors come from</h3><span class="sub" id="trfSub"></span></div>
|
||||
@@ -495,6 +504,6 @@
|
||||
</div>
|
||||
|
||||
<script src="/assets/common.js?v=20261009a"></script>
|
||||
<script src="/assets/admin.js?v=20260929a"></script>
|
||||
<script src="/assets/admin.js?v=20261010a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+33
-5
@@ -44,8 +44,8 @@
|
||||
});
|
||||
|
||||
// ── panes ──
|
||||
const TITLES = { overview: 'Overview', house: 'House ads', campaigns: 'All campaigns', members: 'Members', reports: 'Reports', zones: 'Zones', traffic: 'Traffic', blog: 'Blog', releases: 'Releases and roadmap', pnl: 'Profit and loss', settings: 'Settings' };
|
||||
const loaders = { overview: loadOverview, house: loadHouse, campaigns: loadCampaigns, members: loadMembers, reports: loadReports, zones: loadZones, traffic: loadTraffic, blog: loadBlog, releases: loadReleases, pnl: loadPnl, settings: loadSettings };
|
||||
const TITLES = { overview: 'Overview', house: 'House ads', campaigns: 'All campaigns', members: 'Members', reports: 'Reports', zones: 'Zones', domains: 'Link domains', traffic: 'Traffic', blog: 'Blog', releases: 'Releases and roadmap', pnl: 'Profit and loss', settings: 'Settings' };
|
||||
const loaders = { overview: loadOverview, house: loadHouse, campaigns: loadCampaigns, members: loadMembers, reports: loadReports, zones: loadZones, domains: loadDomains, traffic: loadTraffic, blog: loadBlog, releases: loadReleases, pnl: loadPnl, settings: loadSettings };
|
||||
function setPane(name) {
|
||||
if (!TITLES[name]) name = 'overview';
|
||||
document.querySelectorAll('.pane').forEach(p => { p.hidden = p.id !== 'pane-' + name; });
|
||||
@@ -479,15 +479,43 @@
|
||||
if (d.error) throw new Error(d.error);
|
||||
const n = v => Number(v || 0).toLocaleString();
|
||||
$('znSub').textContent = n(d.totals.zones) + ' zones · ' + n(d.totals.views30) + ' views in 30 days · ' + n(d.totals.nas30) + ' network · ' + n(d.totals.credits) + ' credits paid';
|
||||
$('znRules').textContent = 'Paid ads (LinkSpin campaigns, then Network Ad Space) serve only when the tag runs on the declared site; anywhere else shows the house banner and earns nothing. A zone earns after its first ' + d.warmup + ' on-site views with at least ' + Math.round(d.holdRatio * 100) + '% viewable, and goes on hold below that. Rates: 1 credit per ' + d.rates.viewsPerCredit + ' LinkSpin views, 1 per ' + d.rates.nasViewsPerCredit + ' network views, ' + d.rates.capPerVisitorDay + ' credited views per visitor per zone per day. Pause a zone to serve house only (brand safety).';
|
||||
const pt = d.publishers || {};
|
||||
$('znRules').textContent = 'Paid ads (LinkSpin campaigns, then Network Ad Space) serve only when the tag runs on the declared site; anywhere else shows the house banner and earns nothing. A zone earns after its first ' + d.warmup + ' on-site views with at least ' + Math.round(d.holdRatio * 100) + '% viewable, and goes on hold below that. Rates: 1 credit per ' + d.rates.viewsPerCredit + ' LinkSpin views, 1 per ' + d.rates.nasViewsPerCredit + ' network views (1 per ' + d.rates.nasViewsPerCreditVerified + ' on a Verified zone), ' + d.rates.capPerVisitorDay + ' credited views per visitor per zone per day. Pause a zone to serve house only (brand safety). Tier: every zone starts Standard; set Verified after reviewing the site (real content, real visitors, tag in view).' + (pt.days ? ' Publisher program, last ' + pt.days + ' days: ' + n(pt.live) + ' live, ' + n(pt.viewable) + ' viewable, ' + n(pt.credits) + ' credits paid.' : '');
|
||||
const ago = t => t ? new Date(t).toLocaleString() : '';
|
||||
$('znTable').innerHTML = '<tr><th>Zone</th><th>Owner</th><th>Site</th><th>Size</th><th>Views</th><th>Viewable</th><th>Mix<br><span class="muted">LinkSpin / network / house / off-site</span></th><th>Clicks</th><th>Credits</th><th>Status</th><th>Last view</th><th></th></tr>'
|
||||
+ (d.zones.length ? d.zones.map(z => '<tr><td><b>' + esc(z.name) + '</b><br><span class="muted small">' + z.id + '</span></td><td>' + esc(z.owner) + '</td><td><a href="https://' + esc(z.site) + '" target="_blank" rel="noopener">' + esc(z.site) + '</a></td><td>' + z.size + '</td><td>' + n(z.views30) + '</td><td>' + (z.viewablePct == null ? '<span class="muted">-</span>' : z.viewablePct + '% ' + (z.grade || '')) + '</td><td>' + n(z.campaign30) + ' / ' + n(z.nas30) + ' / ' + n(z.house30) + ' / ' + n(z.offsite30) + '</td><td>' + n(z.clicks30) + '</td><td>' + n(z.credits) + '</td><td>' + esc(z.statusLabel) + (z.note ? '<br><span class="muted small">' + esc(z.note) + '</span>' : '') + '</td><td>' + ago(z.lastSeen) + '</td><td class="act"><button type="button" class="btn small ghost" data-znpause="' + z.id + '" data-on="' + (z.paused ? 0 : 1) + '">' + (z.paused ? 'Resume' : 'Pause') + '</button></td></tr>').join('') : '<tr><td colspan="12" class="muted">No zones yet.</td></tr>');
|
||||
const tierSel = z => '<select class="small" data-zntier="' + z.id + '" aria-label="Tier">' + (d.tiers || ['standard', 'verified']).map(t => '<option value="' + t + '"' + ((z.tier || 'standard') === t ? ' selected' : '') + '>' + t.charAt(0).toUpperCase() + t.slice(1) + '</option>').join('') + '</select>';
|
||||
$('znTable').innerHTML = '<tr><th>Zone</th><th>Owner</th><th>Site</th><th>Size</th><th>Tier</th><th>Views</th><th>Viewable</th><th>Mix<br><span class="muted">LinkSpin / network / house / off-site</span></th><th>Clicks</th><th>Credits</th><th>Status</th><th>Last view</th><th></th></tr>'
|
||||
+ (d.zones.length ? d.zones.map(z => '<tr><td><b>' + esc(z.name) + '</b><br><span class="muted small">' + z.id + '</span></td><td>' + esc(z.owner) + '</td><td><a href="https://' + esc(z.site) + '" target="_blank" rel="noopener">' + esc(z.site) + '</a></td><td>' + z.size + '</td><td>' + tierSel(z) + '</td><td>' + n(z.views30) + '</td><td>' + (z.viewablePct == null ? '<span class="muted">-</span>' : z.viewablePct + '% ' + (z.grade || '')) + '</td><td>' + n(z.campaign30) + ' / ' + n(z.nas30) + ' / ' + n(z.house30) + ' / ' + n(z.offsite30) + '</td><td>' + n(z.clicks30) + '</td><td>' + n(z.credits) + '</td><td>' + esc(z.statusLabel) + (z.note ? '<br><span class="muted small">' + esc(z.note) + '</span>' : '') + '</td><td>' + ago(z.lastSeen) + '</td><td class="act"><button type="button" class="btn small ghost" data-znpause="' + z.id + '" data-on="' + (z.paused ? 0 : 1) + '">' + (z.paused ? 'Resume' : 'Pause') + '</button></td></tr>').join('') : '<tr><td colspan="13" class="muted">No zones yet.</td></tr>');
|
||||
document.querySelectorAll('[data-znpause]').forEach(b => b.addEventListener('click', async () => {
|
||||
const pausing = b.dataset.on === '1';
|
||||
try { await api('/api/admin/zones/' + b.dataset.znpause, pausing ? { paused: true, note: 'Paused ' + new Date().toLocaleDateString() } : { paused: false, note: '' }, 'POST'); loadZones(); } catch (e) { IAP.status(e.message, 'bad'); }
|
||||
}));
|
||||
// publisher tier (2026-10-10): Verified zones earn network views at the better rate; saved through the zone update route
|
||||
document.querySelectorAll('[data-zntier]').forEach(s => s.addEventListener('change', async () => {
|
||||
try { await api('/api/admin/zones/' + s.dataset.zntier + '/tier', { tier: s.value }, 'POST'); IAP.status('Tier saved: ' + s.value, 'ok'); loadZones(); } catch (e) { IAP.status(e.message, 'bad'); loadZones(); }
|
||||
}));
|
||||
}
|
||||
// ── link domains: channel per domain, last safety check, burned flag; check now / clear / pull (2026-10-10) ──
|
||||
async function loadDomains() {
|
||||
const d = await api('/api/admin/domains');
|
||||
const list = d.domains || []; const live = list.filter(x => !x.burned && x.channel !== 'reserve').length, burned = list.filter(x => x.burned).length;
|
||||
$('dmSub').textContent = list.length + ' domain' + (list.length === 1 ? '' : 's') + ' · ' + live + ' live · ' + burned + ' burned';
|
||||
$('dmGsb').textContent = d.gsb ? 'Google Safe Browsing: on' : 'Google Safe Browsing: off (set GSB_API_KEY on the server to turn it on)';
|
||||
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>';
|
||||
$('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>'
|
||||
+ '<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>' + (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>' + ago(x.checkedAt) + '</td>'
|
||||
+ '<td class="act" style="white-space:nowrap"><button type="button" class="btn small ghost" data-dmcheck="' + esc(x.host) + '">Check now</button> ' + (x.burned ? '<button type="button" class="btn small sec" data-dmclear="' + esc(x.host) + '">Clear burn</button>' : '<button type="button" class="btn small sec" data-dmburn="' + esc(x.host) + '">Pull</button>') + '</td></tr>').join('')
|
||||
: '<tr><td colspan="9" class="muted">No link domains yet. Add them to the linkDomains site setting (comma list) first.</td></tr>');
|
||||
document.querySelectorAll('[data-dmch]').forEach(sel => sel.addEventListener('change', async () => { try { await api('/api/admin/domains', { action: 'channel', domain: sel.dataset.dmch, channel: sel.value }); IAP.status('Channel saved: ' + sel.dataset.dmch + ' is now ' + sel.value + '.', 'ok'); loadDomains(); } catch (e) { IAP.status(e.message, 'bad'); } }));
|
||||
document.querySelectorAll('[data-dmcheck]').forEach(b => b.addEventListener('click', busy(b, async () => { const r = await api('/api/admin/domains', { action: 'check', domain: b.dataset.dmcheck }); const x = r.domain || {}; IAP.status(b.dataset.dmcheck + ': Safe Browsing ' + x.gsb + ', URIBL ' + x.uribl + ', SURBL ' + x.surbl + ', reach ' + x.reach + (x.burned ? ' · BURNED' : ''), x.burned ? 'bad' : 'ok'); loadDomains(); })));
|
||||
document.querySelectorAll('[data-dmclear]').forEach(b => b.addEventListener('click', busy(b, async () => { await api('/api/admin/domains', { action: 'clear', domain: b.dataset.dmclear }); IAP.status(b.dataset.dmclear + ' is back in the pool.', 'ok'); loadDomains(); })));
|
||||
document.querySelectorAll('[data-dmburn]').forEach(b => b.addEventListener('click', busy(b, async () => { await api('/api/admin/domains', { action: 'burn', domain: b.dataset.dmburn, reason: 'pulled by admin ' + new Date().toLocaleDateString() }); IAP.status(b.dataset.dmburn + ' pulled from the pool.', 'ok'); loadDomains(); })));
|
||||
}
|
||||
$('dmCheckAll').addEventListener('click', busy($('dmCheckAll'), async () => { IAP.status('Checking every domain…', 'ok'); const r = await api('/api/admin/domains', { action: 'check' }); const bad = (r.domains || []).filter(x => x.burned).length; IAP.status('Checked ' + (r.results || []).length + ' domains' + (bad ? ', ' + bad + ' burned' : ', none burned') + '.', bad ? 'bad' : 'ok'); loadDomains(); }));
|
||||
// ── traffic: referring domains / sources, landing pages, angles, by day ──
|
||||
let trfDays = 30;
|
||||
document.querySelectorAll('#trfRange [data-days]').forEach(b => b.addEventListener('click', () => { trfDays = Number(b.dataset.days); document.querySelectorAll('#trfRange [data-days]').forEach(x => x.classList.toggle('on', x === b)); loadTraffic().catch(e => IAP.status(e.message, 'bad')); }));
|
||||
|
||||
+108
-10
@@ -7,9 +7,71 @@
|
||||
const clicks7 = r => r.hits7 || 0;
|
||||
const health = r => r.paused ? { cls: 'warn', t: 'PAUSED' } : !r.destinations.some(d => d.active) ? { cls: 'bad', t: 'NO LIVE DESTINATION' } : { cls: 'ok', t: 'LIVE' };
|
||||
|
||||
// ── dayparting: grid = 7 strings of 24 chars '1'/'0', index 0 = Sunday; null = always on ──
|
||||
const ALL = '1'.repeat(24), NONE = '0'.repeat(24);
|
||||
const rowOf = (a, b) => { let s = ''; for (let h = 0; h < 24; h++) s += h >= a && h < b ? '1' : '0'; return s; };
|
||||
const PRESETS = { always: null, business: [NONE, rowOf(8, 18), rowOf(8, 18), rowOf(8, 18), rowOf(8, 18), rowOf(8, 18), NONE], evenings: new Array(7).fill(rowOf(17, 23)), weekends: [ALL, NONE, NONE, NONE, NONE, NONE, ALL] };
|
||||
const ZONES = [['visitor', "Visitor's local time"], ['America/Chicago', 'Chicago (Central)'], ['America/New_York', 'New York (Eastern)'], ['America/Los_Angeles', 'Los Angeles (Pacific)'], ['Europe/London', 'London'], ['Europe/Berlin', 'Berlin'], ['Asia/Kolkata', 'India'], ['Asia/Manila', 'Manila'], ['Asia/Singapore', 'Singapore'], ['Australia/Sydney', 'Sydney']];
|
||||
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], ORDER = [1, 2, 3, 4, 5, 6, 0];
|
||||
const ranges = s => { const out = []; let a = -1; for (let h = 0; h <= 24; h++) { const on = h < 24 && s[h] === '1'; if (on && a < 0) a = h; if (!on && a >= 0) { out.push(a + '-' + h); a = -1; } } return out.join(', '); };
|
||||
function hoursText(hours) {
|
||||
if (!hours || hours.every(s => s === ALL)) return 'Always on';
|
||||
if (hours.every(s => s === hours[0])) return 'Every day ' + ranges(hours[0]);
|
||||
const wk = [1, 2, 3, 4, 5], we = [0, 6], off = s => !s.includes('1');
|
||||
if (wk.every(i => hours[i] === hours[1]) && we.every(i => off(hours[i]))) return 'Mon-Fri ' + ranges(hours[1]);
|
||||
if (wk.every(i => off(hours[i])) && hours[0] === hours[6]) return 'Weekends' + (hours[6] === ALL ? '' : ' ' + ranges(hours[6]));
|
||||
const n = hours.join('').split('1').length - 1; return 'Custom, ' + n + ' of 168 hours';
|
||||
}
|
||||
const tzText = tz => !tz || tz === 'visitor' ? "visitor's local time" : ((ZONES.find(z => z[0] === tz) || [])[1] || tz.split('/').pop().replace(/_/g, ' ')) + ' time';
|
||||
const hoursChip = (hours, tz) => hoursText(hours) + (hours ? ', ' + tzText(tz) : '');
|
||||
// the inline 7 x 24 editor. o = { hours, tz (undefined = no zone picker), heat (7x24 counts), best, onSave(hours, tz), onCancel }
|
||||
function hoursEditor(host, o) {
|
||||
let grid = (o.hours || new Array(7).fill(ALL)).map(s => s.split('')); let tz = o.tz || 'visitor';
|
||||
const other = tz !== 'visitor' && !ZONES.some(z => z[0] === tz);
|
||||
const max = o.heat ? Math.max(1, ...o.heat.map(d => Math.max(...d))) : 0;
|
||||
host.innerHTML = '<div class="he">'
|
||||
+ '<div class="he-presets"><span class="muted" style="font-size:11px">Presets</span>' + [['always', 'Always on'], ['business', 'Business, Mon-Fri 8-18'], ['evenings', 'Evenings, 17-23'], ['weekends', 'Weekends']].map(p => '<button class="btn sm" type="button" data-p="' + p[0] + '">' + p[1] + '</button>').join('')
|
||||
+ '<button class="btn sm" type="button" data-p="best"' + (o.best && o.best.ready ? '' : ' disabled') + '>Use my best hours</button></div>'
|
||||
+ (o.tz !== undefined ? '<div class="he-tz"><label class="lbl" style="margin:0">Time zone<select class="field" data-tz>' + ZONES.map(z => '<option value="' + z[0] + '"' + (z[0] === tz ? ' selected' : '') + '>' + esc(z[1]) + '</option>').join('') + '<option value="other"' + (other ? ' selected' : '') + '>Other (type a zone name)</option></select></label><input class="field mono" data-tzo type="text" placeholder="Area/City, like America/Denver"' + (other ? ' value="' + esc(tz) + '"' : ' hidden') + '></div>' : '<div class="muted" style="font-size:11px">Hours follow the link\'s time zone: ' + esc(tzText(o.rotTz)) + '.</div>')
|
||||
+ '<div class="he-wrap"><div class="he-grid" data-grid><span></span>' + new Array(24).fill(0).map((_, h) => '<span class="hl">' + (h < 10 ? '0' + h : h) + '</span>').join('')
|
||||
+ ORDER.map(wd => '<span class="dlb" data-day="' + wd + '" title="Flip the whole day">' + DAYS[wd] + '</span>' + new Array(24).fill(0).map((_, h) => '<span class="c" data-wd="' + wd + '" data-h="' + h + '"' + (o.heat && o.heat[wd][h] ? ' style="--heat:' + (0.12 + 0.55 * o.heat[wd][h] / max).toFixed(2) + '" title="' + o.heat[wd][h] + ' unique visitors, ' + DAYS[wd] + ' ' + h + ':00"' : ' title="' + DAYS[wd] + ' ' + h + ':00"') + '></span>').join('')).join('') + '</div></div>'
|
||||
+ '<div class="he-sum" data-sum></div>'
|
||||
+ '<div class="muted" style="font-size:11px" data-best>' + (o.best ? (o.best.ready ? 'Your best hours are the top quarter of weekday-hour cells by unique visitors over the last 30 days (' + fmt(o.best.hits) + ' clicks). Tinted cells show where your clicks land.' : '"Use my best hours" unlocks after ' + fmt(o.best.need) + ' clicks in 30 days; ' + fmt(o.best.hits) + ' so far.') : '') + '</div>'
|
||||
+ '<div class="acts"><button class="btn pri" type="button" data-save>Save hours</button><button class="btn" type="button" data-cancel>Cancel</button><span class="muted" style="font-size:11px">Hours are 0 to 23; 8-18 means 8:00 up to 18:00.</span></div></div>';
|
||||
const cells = {}; host.querySelectorAll('.c').forEach(c => { cells[c.dataset.wd + ':' + c.dataset.h] = c; if (o.heat && o.heat[c.dataset.wd][c.dataset.h]) c.classList.add('heat'); });
|
||||
const paint = () => { for (const k in cells) { const [wd, h] = k.split(':'); cells[k].classList.toggle('on', grid[wd][h] === '1'); } const hs = grid.map(d => d.join('')); host.querySelector('[data-sum]').innerHTML = esc(hoursText(hs.every(s => s === ALL) ? null : hs)) + (o.tz !== undefined ? ' <small>' + esc(tzText(tz)) + '</small>' : ''); };
|
||||
const set = (wd, h, v) => { grid[wd][h] = v; };
|
||||
let painting = null;
|
||||
const g = host.querySelector('[data-grid]');
|
||||
const cellAt = e => { const el = document.elementFromPoint(e.clientX, e.clientY); return el && el.classList.contains('c') && g.contains(el) ? el : null; };
|
||||
g.addEventListener('pointerdown', e => { const c = cellAt(e); if (!c) return; e.preventDefault(); painting = grid[c.dataset.wd][c.dataset.h] === '1' ? '0' : '1'; set(c.dataset.wd, c.dataset.h, painting); paint(); });
|
||||
g.addEventListener('pointermove', e => { if (painting == null) return; const c = cellAt(e); if (c && grid[c.dataset.wd][c.dataset.h] !== painting) { set(c.dataset.wd, c.dataset.h, painting); paint(); } });
|
||||
const stop = () => { painting = null; }; g.addEventListener('pointerup', stop); g.addEventListener('pointercancel', stop); g.addEventListener('pointerleave', stop);
|
||||
host.querySelectorAll('.dlb').forEach(l => l.addEventListener('click', () => { const wd = l.dataset.day; const v = grid[wd].every(x => x === '1') ? '0' : '1'; grid[wd] = new Array(24).fill(v); paint(); }));
|
||||
host.querySelectorAll('[data-p]').forEach(b => b.addEventListener('click', () => { const p = b.dataset.p; const src = p === 'best' ? (o.best && o.best.hours) : PRESETS[p]; grid = (src || new Array(7).fill(ALL)).map(s => s.split('')); paint(); }));
|
||||
const sel = host.querySelector('[data-tz]'), oth = host.querySelector('[data-tzo]');
|
||||
if (sel) { sel.addEventListener('change', () => { if (sel.value === 'other') { oth.hidden = false; oth.focus(); tz = oth.value.trim() || 'visitor'; } else { oth.hidden = true; tz = sel.value; } paint(); }); oth.addEventListener('input', () => { tz = oth.value.trim() || 'visitor'; paint(); }); }
|
||||
host.querySelector('[data-save]').addEventListener('click', () => { const hs = grid.map(d => d.join('')); o.onSave(hs.every(s => s === ALL) ? null : hs, o.tz !== undefined ? tz : undefined); });
|
||||
host.querySelector('[data-cancel]').addEventListener('click', () => o.onCancel && o.onCancel());
|
||||
host.heState = () => ({ hours: grid.map(d => d.join('')), tz }); // so a redraw can keep unsaved taps
|
||||
paint();
|
||||
}
|
||||
// ── health readouts ──
|
||||
const ago = ts => { 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 mdy = ts => new Date(ts).toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
||||
const healthCls = h => !h ? '' : h.state === 'ok' ? 'ok' : h.state === 'slow' ? 'warn' : 'bad';
|
||||
function healthLine(d) {
|
||||
const h = d.health; if (!h) return 'Not checked yet; the first check runs within 30 minutes';
|
||||
if (d.autoPaused) return (h.state === 'parked' ? 'Parked page' : h.state === 'dead' ? 'Dead page' : 'Back up') + ', auto-paused ' + mdy(d.autoPaused) + (h.state === 'ok' || h.state === 'slow' ? ', resumes after ' + (2 - (h.passes || 0)) + ' more clean check' + (2 - (h.passes || 0) === 1 ? '' : 's') : ', checked again every 6 hours');
|
||||
if (h.state === 'ok' || h.state === 'slow') return 'Checked ' + ago(h.checkedAt) + ', ' + h.code + ' in ' + fmt(h.ms) + ' ms' + (h.note ? ', ' + h.note : '');
|
||||
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 }
|
||||
|
||||
async function load(keep) {
|
||||
let r; try { r = await CR.get('/api/my/rotations'); } catch (e) { CR.sub('could not load'); return; }
|
||||
ROT = (r.rotations || []).slice().sort((a, b) => clicks7(b) - clicks7(a)); HOSTS = r.hosts || [];
|
||||
try { const lh = await api('/api/my/link-hosts'); LH = (lh && lh.hosts) || []; } catch (e) { LH = []; } // link domains by channel (domains.js, 2026-10-10)
|
||||
const tot7 = ROT.reduce((n, x) => n + clicks7(x), 0);
|
||||
CR.sub(ROT.length + ' link' + (ROT.length === 1 ? '' : 's') + ' · ' + fmt(tot7) + ' clicks in 7 days');
|
||||
renderList();
|
||||
@@ -37,36 +99,66 @@
|
||||
const h = health(r); $('dLive').innerHTML = '<span class="' + h.cls + '"><span class="dot"></span>' + h.t + '</span>';
|
||||
$('pauseBtn').textContent = r.paused ? 'Resume' : 'Pause';
|
||||
$('fallback').value = r.fallback || '';
|
||||
const fh = r.fallbackHealth; $('fallbackHealth').textContent = r.fallback ? (fh ? 'Fallback checked ' + ago(fh.checkedAt) + ': ' + (fh.state === 'ok' || fh.state === 'slow' ? fh.code + ' in ' + fmt(fh.ms) + ' ms' : (fh.note || fh.state)) + (fh.frameBlocked ? ', blocks frames' : '') : 'Fallback not checked yet') : '';
|
||||
$('hoursChip').textContent = hoursChip(r.hours, r.tz); $('hoursChip').classList.toggle('set', !!r.hours);
|
||||
renderTiles(r, STATS[id]);
|
||||
renderDest(r); renderShare(r);
|
||||
renderDest(r); renderShare(r); renderRotHours(r, STATS[id]);
|
||||
if (!quiet) window.scrollTo({ top: 0 });
|
||||
loadStats(r.id);
|
||||
}
|
||||
function renderDest(r) {
|
||||
const total = r.destinations.filter(d => d.active).reduce((n, d) => n + d.weight, 0) || 1;
|
||||
$('destRows').innerHTML = r.destinations.length ? r.destinations.map(d => { const share = d.active ? Math.round(d.weight / total * 100) : 0;
|
||||
return '<div class="rw" data-did="' + d.id + '"><div><div style="font-weight:700">' + esc(d.label || d.url.replace(/^https?:\/\//, '').slice(0, 60)) + '</div><div class="mono muted" style="font-size:11px;overflow-wrap:anywhere">' + esc(d.url) + '</div></div>'
|
||||
const auto = r.destinations.filter(d => d.autoPaused);
|
||||
const prevHost = $('destRows').querySelector('[data-he]'); const prev = prevHost && HE && Number(prevHost.dataset.he) === HE.did && prevHost.heState ? prevHost.heState() : null;
|
||||
$('autoNote').hidden = !auto.length;
|
||||
if (auto.length) $('autoNote').textContent = 'LinkSpin paused ' + (auto.length === 1 ? 'one destination' : auto.length + ' destinations') + ' automatically after three failed checks: ' + auto.map(d => (d.label || d.url.replace(/^https?:\/\//, '')).slice(0, 40)).join(', ') + '. It comes back on its own after two clean checks, or fix the address and press Resume.';
|
||||
$('destRows').innerHTML = r.destinations.length ? r.destinations.map(d => { const share = d.active ? Math.round(d.weight / total * 100) : 0; const h = d.health;
|
||||
return '<div class="rw" data-did="' + d.id + '"><div><div class="dl"><span class="hdot ' + healthCls(h) + '" title="' + esc(healthLine(d)) + '"></span><span style="font-weight:700">' + esc(d.label || d.url.replace(/^https?:\/\//, '').slice(0, 60)) + '</span>' + (d.hours ? '<button class="hchip set" type="button" data-hc="' + d.id + '" title="This destination has its own hours">' + esc(hoursText(d.hours)) + '</button>' : '') + (h && h.frameBlocked ? '<span class="tag warn" title="This page refuses to load inside a frame (X-Frame-Options or CSP). Traffic exchanges that frame your link will show it blank.">no frames</span>' : '') + '</div>'
|
||||
+ '<div class="mono muted" style="font-size:11px;overflow-wrap:anywhere">' + esc(d.url) + '</div><div class="muted" style="font-size:11px" data-hl="' + d.id + '">' + esc(healthLine(d)) + '</div></div>'
|
||||
+ '<div class="wrow"><div class="bar" style="width:70px"><i style="width:' + share + '%"></i></div><input class="field mono" type="number" min="1" max="100" value="' + d.weight + '" data-w="' + d.id + '" aria-label="Weight"><span class="mono muted" style="font-size:11px">' + share + '%</span></div>'
|
||||
+ '<span class="r num">' + fmt(d.hits || 0) + '</span><span class="r num">' + fmt(d.uniques || 0) + '</span>'
|
||||
+ '<span class="tag ' + (d.active ? 'ok' : 'dim') + '">' + (d.active ? 'LIVE' : 'PAUSED') + '</span>'
|
||||
+ '<span style="display:flex;gap:6px;justify-content:flex-end"><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">×</button></span></div>'; }).join('')
|
||||
+ '<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">×</button></span></div>'
|
||||
+ (HE && HE.rid === r.id && HE.did === d.id ? '<div class="rw edit" data-he="' + d.id + '"></div>' : ''); }).join('')
|
||||
: '<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';
|
||||
$('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';
|
||||
const openEditor = did => { const d = r.destinations.find(q => q.id === did); if (!d) return; HE = { rid: r.id, did }; renderDest(r); };
|
||||
$('destRows').querySelectorAll('[data-hc]').forEach(b => b.addEventListener('click', () => { if (HE && HE.rid === r.id && HE.did === Number(b.dataset.hc)) { HE = null; renderDest(r); } else openEditor(Number(b.dataset.hc)); }));
|
||||
const heHost = $('destRows').querySelector('[data-he]');
|
||||
if (heHost) { const d = r.destinations.find(q => q.id === Number(heHost.dataset.he)); const s = STATS[r.id];
|
||||
hoursEditor(heHost, { hours: prev ? prev.hours : d.hours, rotTz: r.tz, heat: s && s.best ? s.best.cells : null, best: s && s.best, onCancel: () => { HE = null; renderDest(r); },
|
||||
onSave: async hours => { try { await api('/api/my/rotations/' + r.id + '/dest/' + d.id, { hours }); HE = null; toast(hours ? 'Hours saved' : 'Destination is always on'); load(true); } catch (e) { toast(e.message, true); } } });
|
||||
if (heHost.scrollIntoView) heHost.scrollIntoView({ block: 'nearest' }); }
|
||||
$('destRows').querySelectorAll('[data-w]').forEach(i => i.addEventListener('change', async () => { try { await api('/api/my/rotations/' + r.id + '/dest/' + i.dataset.w, { weight: i.value }); toast('Weight saved'); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
$('destRows').querySelectorAll('[data-t]').forEach(b => b.addEventListener('click', async () => { const d = r.destinations.find(q => q.id === Number(b.dataset.t)); try { await api('/api/my/rotations/' + r.id + '/dest/' + d.id, { active: !d.active }); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
$('destRows').querySelectorAll('[data-x]').forEach(b => b.addEventListener('click', async () => { if (!await dialog({ title: 'Remove this destination?', text: 'Its click history stays in the stats.', ok: 'Remove', danger: true })) return; try { await api('/api/my/rotations/' + r.id + '/dest/' + b.dataset.x, { remove: true }); toast('Removed'); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
}
|
||||
let LH = [];
|
||||
function renderShare(r) {
|
||||
const url = linkUrl(r);
|
||||
const kit = [
|
||||
const byChannel = LH.filter(h => h.channel !== 'reserve').map(h => ['Best link for ' + (h.label || h.channel), 'https://' + h.host + '/r/' + r.code + (h.note ? ' (' + h.note + ')' : '')]);
|
||||
const kit = byChannel.concat([
|
||||
['Short post', 'One link, every page I promote, in turn. Take a look: ' + url],
|
||||
['Email or Telegram line', 'Here is the link I use for everything: ' + url + ' (it always sends you to the right page).'],
|
||||
['Tracker-ready link', url + '?clickid={clickid}&s1={source} (replace the braces with your network\'s macros)'],
|
||||
['Sub-id split test', url + '?s1=email-A and ' + url + '?s1=email-B (each shows up under Sources)'],
|
||||
];
|
||||
]);
|
||||
$('shareKit').innerHTML = kit.map(([t, body], i) => '<div class="panel" style="padding:10px 12px"><div style="display:flex;justify-content:space-between;align-items:center;gap:8px"><b>' + esc(t) + '</b><button class="btn sm" type="button" data-cp="' + i + '">Copy</button></div><div class="mono muted" style="font-size:12px;overflow-wrap:anywhere;margin-top:6px" id="kit-' + i + '">' + esc(body) + '</div></div>').join('');
|
||||
$('shareKit').querySelectorAll('[data-cp]').forEach(b => b.addEventListener('click', () => CR.copy($('kit-' + b.dataset.cp).textContent)));
|
||||
}
|
||||
// the rotation's own hours editor on the Hours tab. Not redrawn while the member is mid-edit (the 60 s refresh would eat their taps).
|
||||
let RH = null; // { rid, dirty }
|
||||
function renderRotHours(r, s) {
|
||||
const host = $('rotHours');
|
||||
if (RH && RH.rid === r.id && RH.dirty && host.firstChild) return;
|
||||
RH = { rid: r.id, dirty: false };
|
||||
hoursEditor(host, { hours: r.hours, tz: r.tz || 'visitor', heat: s && s.best ? s.best.cells : null, best: s && s.best,
|
||||
onCancel: () => { RH = null; renderRotHours(r, STATS[r.id]); },
|
||||
onSave: async (hours, tz) => { try { await api('/api/my/rotations/' + r.id, { hours, tz }); RH = null; toast(hours ? 'Hours saved' : 'Link is always on'); load(true); } catch (e) { toast(e.message, true); } } });
|
||||
host.addEventListener('pointerdown', () => { if (RH) RH.dirty = true; }, { once: true });
|
||||
host.addEventListener('change', () => { if (RH) RH.dirty = true; }, { once: true });
|
||||
$('offNote').textContent = s ? ((s.offHours ? fmt(s.offHours) + ' click' + (s.offHours === 1 ? '' : 's') + ' arrived outside the link\'s hours and went to the fallback (all time, ' + fmt(r.offHours30 || 0) + ' in 30 days).' : 'No clicks have gone to the off-hours fallback yet.')) : '';
|
||||
}
|
||||
const kv = rows => rows && rows.length ? rows.map(x => '<span style="overflow-wrap:anywhere">' + esc(x.k) + '</span><span class="bar"><i style="width:' + Math.round(x.n / (rows[0].n || 1) * 100) + '%"></i></span><span class="r num">' + fmt(x.n) + '</span>').join('') : '<span class="muted">nothing yet</span><span></span><span></span>';
|
||||
function renderTiles(r, s) {
|
||||
let series = null, delta = null;
|
||||
@@ -84,7 +176,7 @@
|
||||
async function loadStats(id) {
|
||||
let s = STATS[id]; if (!s) { try { s = await CR.get('/api/my/rotations/' + id + '/stats'); } catch (e) { return; } STATS[id] = s; setTimeout(() => { delete STATS[id]; }, 60000); }
|
||||
if (SEL !== id) return;
|
||||
{ const r = ROT.find(x => x.id === id); if (r) renderTiles(r, s); }
|
||||
{ const r = ROT.find(x => x.id === id); if (r) { renderTiles(r, s); if (!(RH && RH.rid === id && RH.dirty)) renderRotHours(r, s); } }
|
||||
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 · ' + n + '"></i>').join('');
|
||||
$('srcRows').innerHTML = kv(s.source); $('geoRows').innerHTML = kv(s.country); $('subRows').innerHTML = kv(s.subs); $('convRows').innerHTML = kv(s.conversions);
|
||||
const dev = s.device || []; const dt = dev.reduce((n, x) => n + x.n, 0) || 1; $('devRow').textContent = dev.length ? dev.map(x => x.k + ' ' + Math.round(x.n / dt * 100) + '%').join(' · ') : '';
|
||||
@@ -128,7 +220,13 @@
|
||||
$('addBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; const url = $('addUrl').value.trim(); if (!url) { $('addUrl').focus(); return; } try { await api('/api/my/rotations/' + r.id + '/dest', { url, label: $('addLabel').value, weight: $('addWeight').value }); $('addUrl').value = ''; $('addLabel').value = ''; toast('Destination added'); load(true); } catch (e) { toast(e.message, true); } });
|
||||
$('addUrl').addEventListener('keydown', e => { if (e.key === 'Enter') $('addBtn').click(); });
|
||||
$('fallback').addEventListener('change', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; try { await api('/api/my/rotations/' + r.id, { fallback: $('fallback').value.trim() }); toast('Fallback saved'); load(true); } catch (e) { toast(e.message, true); } });
|
||||
$('tabs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { $('tabs').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); ['dest', 'hours', 'sources', 'report', 'share'].forEach(t => { $('tab-' + t).hidden = t !== b.dataset.tab; }); }));
|
||||
const showTab = name => { $('tabs').querySelectorAll('button').forEach(x => x.classList.toggle('on', x.dataset.tab === name)); ['dest', 'hours', 'sources', 'report', 'share'].forEach(t => { $('tab-' + t).hidden = t !== name; }); };
|
||||
$('tabs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => showTab(b.dataset.tab)));
|
||||
$('hoursChip').addEventListener('click', () => { showTab('hours'); const h = $('rotHours'); if (h.scrollIntoView) h.scrollIntoView({ block: 'start', behavior: 'smooth' }); });
|
||||
$('checkBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; const b = $('checkBtn'); b.disabled = true; b.textContent = 'Checking';
|
||||
try { const out = await api('/api/my/rotations/' + r.id + '/health'); const i = ROT.findIndex(x => x.id === r.id); if (i >= 0 && out.rotation) ROT[i] = out.rotation; const fresh = out.rotation || r; renderDest(fresh); select(r.id, true);
|
||||
const bad = fresh.destinations.filter(d => d.health && (d.health.state === 'dead' || d.health.state === 'parked')).length; toast('Checked ' + fresh.destinations.length + ' destination' + (fresh.destinations.length === 1 ? '' : 's') + (bad ? ', ' + bad + ' failing' : ', all answering')); }
|
||||
catch (e) { toast(e.message, true); } b.disabled = false; b.textContent = 'Check now'; });
|
||||
$('pbNew').addEventListener('click', () => pbForm(null));
|
||||
$('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches;
|
||||
CR.requireSession(() => { load(); loadPb(); setInterval(() => { if (!document.hidden) load(true); }, 60000); });
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@
|
||||
function nextMove(d) {
|
||||
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.buyerCount === 0) return 'Payouts are on and your link is live. Your next milestone: your first buyer of $20 or more. Every direct pays you 50 percent from their very first package.';
|
||||
if (d.buyerCount === 1) return 'One qualifying buyer down, one to go. Your next $20+ buyer unlocks level 2: 20 percent of everything your people’s people buy.';
|
||||
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 === 1) return 'One qualifying buyer down, one to go. Your next $25+ buyer unlocks level 2: 20 percent of everything your people’s people buy.';
|
||||
if (d.buyerCount < 5) return 'Level 2 is open. ' + (5 - d.buyerCount) + ' more qualifying buyer(s) unlock level 3 and the full three-level flow.';
|
||||
return 'Fully qualified. Every level pays you, and you catch the pass-ups that under-qualified positions below you let slip. Keep sharing and keep your campaigns running.';
|
||||
}
|
||||
|
||||
@@ -2,12 +2,48 @@
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
|
||||
let PAGES = [], SEL = null, SCAN = null, TYPE = 'bridge', HOSTS = [], BASE = '';
|
||||
let STYLES = { palettes: [], designs: [], layouts: [], niches: [] };
|
||||
let STYLES = { palettes: [], designs: [], layouts: [], niches: [] }, PROVIDERS = [], IMAGES = [], IMG_MAX = 50, IMG_BYTES = 2 * 1024 * 1024;
|
||||
// which autoresponder a pasted form posts to (same list the server keeps in formrestyle.js, handed over as `providers`)
|
||||
function providerOf(embed) {
|
||||
const f = /<form\b[^>]*>/i.exec(String(embed || '')); if (!f) return null;
|
||||
const am = /\baction\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/i.exec(f[0]); const action = am ? (am[1] || am[2] || am[3]) : '';
|
||||
if (!/^https?:\/\//i.test(action)) return null;
|
||||
let u; try { u = new URL(action); } catch (e) { return null; }
|
||||
const host = u.hostname.toLowerCase().replace(/^www\./, '');
|
||||
for (const pr of PROVIDERS) { const hostHit = (pr.hosts || []).some(h => host === h || host.endsWith('.' + h)); const pathHit = pr.path ? new RegExp(pr.path, 'i').test(u.pathname) : false; if ((pr.hosts && pr.hosts.length && hostHit) || (!(pr.hosts && pr.hosts.length) && pathHit)) return { host, known: true, name: pr.name }; }
|
||||
return { host, known: false, name: '' };
|
||||
}
|
||||
function providerNote(embed) {
|
||||
const el = $('providerNote'); if (!el) return; const src = String(embed || '').trim();
|
||||
if (!src) { el.hidden = true; el.innerHTML = ''; return; }
|
||||
const pr = providerOf(src); el.hidden = false;
|
||||
if (!pr) { el.innerHTML = '<span class="warn">No https:// form action found yet.</span> Paste the whole <form> block your provider gives you.'; return; }
|
||||
el.innerHTML = pr.known ? '<span class="ok"><span class="dot"></span>Recognised: ' + esc(pr.name) + '</span> <span class="muted">Submissions go to ' + esc(pr.host) + '.</span>'
|
||||
: '<span class="warn"><span class="dot"></span>Unknown provider</span> <span class="muted">The form is kept as a plain post to <b>' + esc(pr.host) + '</b>; we cannot vouch for it. It still has to pass the form check when you save.</span>';
|
||||
}
|
||||
// the member's hosted images: a strip of thumbnails under the image field, click to use, x to delete
|
||||
function drawImages() {
|
||||
const box = $('imgStrip'); if (!box) return;
|
||||
box.innerHTML = (IMAGES.length ? IMAGES.map(i => '<span class="im" data-url="' + esc(i.url) + '" title="Use this image"><img src="' + esc(i.url) + '" alt="" loading="lazy"><button type="button" class="x" data-del="' + i.id + '" title="Delete this image">×</button></span>').join('') : '<span class="muted" style="font-size:11px">No uploads yet. PNG, JPG or WebP up to 2 MB, ' + IMG_MAX + ' per account.</span>')
|
||||
+ (IMAGES.length ? '<span class="muted mono" style="font-size:11px;align-self:center">' + IMAGES.length + '/' + IMG_MAX + '</span>' : '');
|
||||
box.querySelectorAll('.im').forEach(s => s.addEventListener('click', e => { if (e.target.closest('[data-del]')) return; const f = $('f-image'); if (f) { f.value = s.dataset.url; f.dispatchEvent(new Event('input')); toast('Image URL filled in. Save to keep it.'); } }));
|
||||
box.querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async e => { e.stopPropagation(); if (!await dialog({ title: 'Delete this image?', text: 'Pages that still point at it will show no image.', ok: 'Delete', danger: true })) return; try { const r = await api('/api/my/pages/images/' + b.dataset.del, { remove: true }); IMAGES = r.images || []; drawImages(); } catch (er) { toast(er.message, true); } }));
|
||||
}
|
||||
async function uploadFile(file) {
|
||||
if (!file) return; if (!/^image\/(png|jpeg|webp)$/.test(file.type)) return toast('Use a PNG, JPG or WebP image.', true);
|
||||
if (file.size > IMG_BYTES) return toast('That image is over 2 MB. Make it smaller and try again.', true);
|
||||
const btn = $('imgUpload'); if (btn) { btn.disabled = true; btn.textContent = 'Uploading…'; }
|
||||
try {
|
||||
const r = await (await fetch('/api/my/pages/upload', { method: 'POST', headers: { 'Content-Type': file.type }, body: file })).json(); if (r.error) throw new Error(r.error);
|
||||
IMAGES.unshift(r.image); drawImages(); const f = $('f-image'); if (f) { f.value = r.image.url; f.dispatchEvent(new Event('input')); } toast('Uploaded. Save to keep it on the page.');
|
||||
} catch (e) { toast(e.message, true); }
|
||||
if (btn) { btn.disabled = false; btn.textContent = 'Upload image'; }
|
||||
}
|
||||
CR.mount({ active: 'pages', title: 'Pages', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ New page</button>' });
|
||||
const pageUrl = p => (BASE || ('https://' + (HOSTS[0] || location.host) + '/p/')) + p.slug;
|
||||
async function load(keepSel) {
|
||||
let r; try { r = await CR.get('/api/my/pages'); } catch (e) { CR.sub('could not load'); return; }
|
||||
PAGES = r.pages || []; HOSTS = r.hosts || []; BASE = r.pageBase || ''; if (r.styles) STYLES = r.styles;
|
||||
PAGES = r.pages || []; HOSTS = r.hosts || []; BASE = r.pageBase || ''; if (r.styles) STYLES = r.styles; PROVIDERS = r.providers || []; IMAGES = r.images || []; if (r.imageMax) IMG_MAX = r.imageMax; if (r.imageBytes) IMG_BYTES = r.imageBytes;
|
||||
const pubd = PAGES.filter(p => p.status === 'published').length;
|
||||
CR.sub(PAGES.length + ' page' + (PAGES.length === 1 ? '' : 's') + ' · ' + pubd + ' live');
|
||||
const views = PAGES.reduce((n, p) => n + p.views, 0), leads = PAGES.reduce((n, p) => n + p.leads, 0), clicks = PAGES.reduce((n, p) => n + p.clicks, 0);
|
||||
@@ -45,7 +81,13 @@
|
||||
$('edPublish').textContent = p.status === 'published' ? 'Unpublish' : 'Publish'; $('edPreview').href = '/p/' + p.slug + '?preview=1';
|
||||
$('edUrl').hidden = p.status !== 'published'; $('edUrl').textContent = pageUrl(p);
|
||||
const c = p.content || {}; const v = k => k === 'ctaText' ? (c.cta && c.cta.text) || '' : k === 'ctaUrl' ? (c.cta && c.cta.url) || '' : Array.isArray(c[k]) ? c[k].join('\n') : (c[k] == null ? '' : c[k]);
|
||||
$('edFields').innerHTML = F[p.type].map(([k, label, ta]) => '<label class="lbl">' + esc(label) + (ta ? '<textarea class="field" id="f-' + k + '">' + esc(v(k)) + '</textarea>' : '<input class="field' + (/Url|image/i.test(k) ? ' mono' : '') + '" id="f-' + k + '" value="' + esc(v(k)) + '">') + '</label>').join('');
|
||||
$('edFields').innerHTML = F[p.type].map(([k, label, ta]) => '<label class="lbl">' + esc(label) + (ta ? '<textarea class="field" id="f-' + k + '">' + esc(v(k)) + '</textarea>' : '<input class="field' + (/Url|image/i.test(k) ? ' mono' : '') + '" id="f-' + k + '" value="' + esc(v(k)) + '">') + '</label>'
|
||||
// hosted images: an Upload button beside the image field (this image is the hero on bridge/review and the card image on squeeze) + the member's strip
|
||||
+ (k === 'image' ? '<div class="imgrow"><button class="btn sm" type="button" id="imgUpload">Upload image</button><input type="file" id="imgFile" accept="image/png,image/jpeg,image/webp" hidden><span class="muted" style="font-size:11px">PNG, JPG or WebP up to 2 MB. Uploading fills the URL above.</span></div><div class="imgstrip" id="imgStrip"></div>' : '')
|
||||
// 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('');
|
||||
if ($('imgUpload')) { $('imgUpload').addEventListener('click', () => $('imgFile').click()); $('imgFile').addEventListener('change', () => { uploadFile($('imgFile').files[0]); $('imgFile').value = ''; }); drawImages(); }
|
||||
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.
|
||||
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 ns = $('niche'); ns.innerHTML = '<option value="">None (set it yourself)</option>' + STYLES.niches.map(n => '<option value="' + n.key + '"' + (d.niche === n.key ? ' selected' : '') + '>' + esc(n.label) + ' \u00b7 ' + esc(n.blurb) + '</option>').join(''); ns.onchange = () => setLook({ niche: ns.value });
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
const promo = String(q.get('promo') || '').toUpperCase().replace(/[^A-Z0-9_-]/g, '').slice(0, 24);
|
||||
const ref = String(q.get('ref') || '').toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20); // a member's own partner kit (Nexus): the deal lands under them
|
||||
const hello = document.getElementById('pkHello');
|
||||
if (hello && name) { hello.textContent = name + ', this page is for you. Your spot directly under the company at the top is reserved; activate with the $20 package to claim it.'; hello.style.display = 'block'; }
|
||||
if (hello && name) { hello.textContent = name + ', this page is for you. Your spot directly under the company at the top is reserved; activate with the $25 Starter package to claim it.'; hello.style.display = 'block'; }
|
||||
const cta = document.getElementById('pkCta');
|
||||
if (cta) {
|
||||
const p = new URLSearchParams(); if (name) p.set('name', name); if (promo) p.set('promo', promo);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// links carry ?v=<angle> and open the matching hook on the join page (join.js knows: instant, adspend, free, ledger, two).
|
||||
// Copy rules: LinkSpin facts only (rewritten 2026-10-08, the earlier text was InstantAdPay's ladder with the name swapped):
|
||||
// packages $10 (door, does not qualify) · $25 · $50 · $100 · $250 · $500, one credit = one cent of delivery, no bonus credits;
|
||||
// a $20+ package makes a qualifying buyer, 2 open level 2, 5 open level 3; split 50 / 20 / 10 + 20 to the platform;
|
||||
// a $25+ package makes a qualifying buyer (the $10 door does not), 2 open level 2, 5 open level 3; split 50 / 20 / 10 + 10 + 10 to the two admin wallets;
|
||||
// seven ad formats: banner, text, login, solo, video, featured, verified visits. No income promises, never a POL figure,
|
||||
// no em dashes.
|
||||
window.IAPPromo = (function () {
|
||||
@@ -53,7 +53,7 @@ window.IAPPromo = (function () {
|
||||
{ q: 'Do I need my own website?', truth: 'No. The rotator and the pages live on LinkSpin\'s link domains, so a member with no site can promote any offer with a spin link and a bridge page. A zone (the ad slot that pays credits) is the one thing that needs a site of your own to paste the script on.', say: 'No site needed. Your spin link and your bridge pages live on LinkSpin\'s domains. If you do have a site, you can also drop in an ad slot that pays you credits, but that part is optional. {{LINK:stack}}' },
|
||||
{ q: 'Why would anyone buy ads here?', truth: 'The members are marketers who already buy traffic. Viewers earn credits only after a server-timed dwell, so impressions are real people. Solo ads reach member inboxes with a guaranteed delivery count, verified visits are one unique member per visit, and banner and text ads also run in member zones on real websites.', say: 'Because the people on it are marketers, and they get paid to actually look. Every view is dwell-timed on the server, solo ads land in real inboxes with a guaranteed count, and verified visits are one real person each. You can watch your own campaign serve: {{LINK:zones}}' },
|
||||
{ q: 'I do not know anyone to refer.', truth: 'Referrals are optional. Members can use the rotator, the pages and a zone, view ads, earn credits and advertise with no line at all. When they do refer, every direct buyer pays them 50 percent from the very first qualifying package.', say: 'You do not have to refer anyone. Join free, use the tools, earn credits by viewing, run ads. If one person ever joins through you and buys a $25 package, half of it hits your wallet in that transaction. That is the whole referral side, and it is optional. {{LINK:stack}}' },
|
||||
{ q: 'How much can I make?', truth: 'No income is guaranteed or implied. Sponsor commissions are 50 / 20 / 10 across three levels on packages that actually sell; level 2 needs 2 qualifying buyers ($20 or more) and level 3 needs 5. Results depend on the member\'s effort, and crypto carries risk of loss. Never quote a figure.', say: 'Nobody can tell you that, and I would not trust anyone who did. What I can tell you is exactly how it is split: 50 percent to the direct sponsor, 20 and 10 to the next two levels, paid the moment a package sells, all public. What that adds up to depends entirely on what you build. {{LINK}}' }
|
||||
{ q: 'How much can I make?', truth: 'No income is guaranteed or implied. Sponsor commissions are 50 / 20 / 10 across three levels on packages that actually sell; level 2 needs 2 qualifying buyers ($25 or more) and level 3 needs 5. Results depend on the member\'s effort, and crypto carries risk of loss. Never quote a figure.', say: 'Nobody can tell you that, and I would not trust anyone who did. What I can tell you is exactly how it is split: 50 percent to the direct sponsor, 20 and 10 to the next two levels, paid the moment a package sells, all public. What that adds up to depends entirely on what you build. {{LINK}}' }
|
||||
];
|
||||
|
||||
function fillLink(text, link) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Publisher program page (2026-10-10): fills the "Network right now" strip and every rate number from
|
||||
// /api/public/publishers (server-side totals, cached a minute), and points Start at the Zones screen when the visitor
|
||||
// is already signed in (otherwise the join page, zones angle). Display only; nothing here changes an account.
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id);
|
||||
const fmt = n => Number(n || 0).toLocaleString();
|
||||
const ago = t => { if (!t) return ''; const d = Date.now() - t; if (d < 90e3) return 'updated just now'; if (d < 3600e3) return 'updated ' + Math.round(d / 60e3) + ' min ago'; return 'updated ' + Math.round(d / 3600e3) + ' h ago'; };
|
||||
async function strip() {
|
||||
let d; try { d = await (await fetch('/api/public/publishers')).json(); } catch (e) { $('stUpdated').textContent = 'live numbers unavailable right now'; $('stDot').classList.add('off'); return; }
|
||||
$('stLive').textContent = fmt(d.live); $('stViews').textContent = fmt(d.viewable7); $('stCredits').textContent = fmt(d.credits7);
|
||||
$('stUpdated').textContent = (d.zones ? fmt(d.zones) + ' zone' + (d.zones === 1 ? '' : 's') + ' installed · ' : '') + ago(d.updated);
|
||||
if (!d.live) $('stDot').classList.add('off');
|
||||
const r = Object.assign({}, d.rates || {}); r.warmup = d.warmup; r.holdPct = Math.round((d.holdRatio || 0.4) * 100);
|
||||
document.querySelectorAll('[data-rate]').forEach(el => { const v = r[el.dataset.rate]; if (v != null && v !== '') el.textContent = fmt(v); });
|
||||
}
|
||||
// signed in already? then Start opens the Zones screen with the first-run card; the join page otherwise
|
||||
async function start() {
|
||||
try { localStorage.setItem('ls.publisher', '1'); } catch (e) {}
|
||||
let signedIn = false; try { signedIn = (await fetch('/api/my/zones', { cache: 'no-store' })).status === 200; } catch (e) {}
|
||||
if (!signedIn) return;
|
||||
document.querySelectorAll('[data-start]').forEach(a => { a.href = '/zones?start=1'; if (/^Start/.test(a.textContent)) a.textContent = 'Open Zones: add your site'; });
|
||||
document.querySelectorAll('[data-join]').forEach(a => { a.href = '/links'; a.textContent = 'Control Room'; });
|
||||
}
|
||||
strip(); start();
|
||||
setInterval(strip, 60000);
|
||||
})();
|
||||
@@ -32,6 +32,27 @@
|
||||
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.';
|
||||
$('convRows').innerHTML = kv(s.conversions || [], 0);
|
||||
// -- 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 map = {}; (rows || []).forEach(r => { map[r.day] = r; });
|
||||
const ser = keys.map(k => ({ day: k, a: map[k] ? f(map[k]) : 0, b: map[k] ? g(map[k]) : 0 }));
|
||||
const max = Math.max(1, ...ser.map(x => Math.max(x.a, x.b))); const any = ser.some(x => x.a || x.b);
|
||||
const el = $(barsId); el.style.gridTemplateColumns = 'repeat(' + keys.length + ',minmax(0,1fr))'; el.classList.add('stack');
|
||||
el.innerHTML = ser.map(x => '<i class="' + (x.a ? '' : 'dim') + '" style="height:' + Math.round(x.a / max * 100) + '%" title="' + x.day + ' · ' + x.a + ' / ' + x.b + '">' + (x.b ? '<b style="height:' + Math.round(x.b / x.a * 100 || 0) + '%"></b>' : '') + '</i>').join('');
|
||||
$(axisId).innerHTML = any ? '<span>' + keys[0] + '</span><span>' + keys[Math.floor(keys.length / 2)] + '</span><span>' + keys[keys.length - 1] + '</span>' : '<span class="muted">' + empty + '</span>';
|
||||
};
|
||||
const mini = rows => rows.map(([k, v]) => '<div class="m"><span class="k">' + esc(k) + '</span><span class="v">' + v + '</span></div>').join('');
|
||||
const pg = s.pages || { byDay: [], byPage: [] };
|
||||
// bar = views, inner bar = leads (leads as a share of that day's views; a day with leads but no views still shows)
|
||||
dayBars('pgBars', 'pgAxis', pg.byDay, d => Math.max(d.views, d.leads), d => d.leads, 'no page views yet');
|
||||
$('pgBars').querySelectorAll('i b').forEach(b => { b.style.background = 'var(--sig)'; });
|
||||
$('pgTiles').innerHTML = mini([['Views', fmt(pg.views)], ['Unique', fmt(pg.uniques)], ['Clicks through', fmt(pg.clicks)], ['Leads', fmt(pg.leads)]]);
|
||||
$('pgRows').innerHTML = (pg.byPage || []).length ? pg.byPage.map(x => '<div class="rw"><a href="/pages" style="text-decoration:none;color:var(--ink)"><b>' + esc(x.title) + '</b><br><span class="mono muted" style="font-size:11px">' + esc(x.type) + ' · ' + (x.status === 'published' ? '<span class="ok">live</span>' : 'draft') + '</span></a><span class="r num">' + fmt(x.views) + '</span><span class="r num">' + fmt(x.uniques) + '</span><span class="r num">' + fmt(x.clicks) + '</span><span class="r num">' + fmt(x.leads) + '</span></div>').join('') : '<div class="rw"><span class="muted">No pages yet. <a href="/pages">Make one</a>.</span></div>';
|
||||
const zn = s.zones || { byDay: [], byZone: [] };
|
||||
// bar = all views, lighter inner share = the ones that were NOT viewable
|
||||
dayBars('znBars', 'znAxis', zn.byDay, d => d.views, d => d.views - d.viewable, 'no zone views yet');
|
||||
$('znTiles').innerHTML = mini([['Views', fmt(zn.views)], ['Viewable', fmt(zn.viewable) + (zn.views ? ' <small class="muted" style="font-size:11px">' + Math.round(zn.viewable / zn.views * 100) + '%</small>' : '')], ['Clicks', fmt(zn.clicks)], ['Credits earned', fmt(zn.credits)]]);
|
||||
$('znRows').innerHTML = (zn.byZone || []).length ? zn.byZone.map(x => '<div class="rw"><a href="/zones" style="text-decoration:none;color:var(--ink)"><b>' + esc(x.name) + '</b><br><span class="mono muted" style="font-size:11px">' + esc(x.site) + ' · ' + esc(x.size) + (x.paused ? ' · <span class="warn">paused</span>' : x.active ? '' : ' · off') + '</span></a><span class="r num">' + fmt(x.views) + '</span><span class="r num">' + fmt(x.viewable) + (x.viewablePct != null ? ' <span class="muted" style="font-size:10px">' + x.viewablePct + '%</span>' : '') + '</span><span class="r num">' + fmt(x.clicks) + '</span><span class="r num">' + fmt(x.credits) + '</span></div>').join('') : '<div class="rw"><span class="muted">No zones yet. <a href="/zones">Add one</a>.</span></div>';
|
||||
}
|
||||
CR.requireSession(load);
|
||||
})();
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
const tag = z => '<script async src="https://' + HOST + '/z.js" data-zone="' + z.id + '"></script>';
|
||||
async function load() {
|
||||
let r; try { r = await CR.get('/api/my/zones'); } catch (e) { CR.sub('could not load'); return; }
|
||||
Z = r.zones || []; HOST = r.host || HOST; SIZES = r.sizes || []; RATE = r.rates || {};
|
||||
Z = r.zones || []; HOST = r.host || HOST; SIZES = r.sizes || []; RATE = r.rates || {}; RATE.warmup = r.warmup || 100;
|
||||
const t = Z.reduce((a, z) => { a.v += z.views30; a.ok += z.viewable30; a.k += z.clicks30; a.c += z.credits; return a; }, { v: 0, ok: 0, k: 0, c: 0 });
|
||||
CR.sub(Z.length + ' zone' + (Z.length === 1 ? '' : 's') + ' · ' + fmt(t.v) + ' views in 30 days');
|
||||
$('tiles').innerHTML = [['Views served, 30 d', fmt(t.v)], ['Viewable', t.v ? Math.round(t.ok / t.v * 100) + '%' : '0%'], ['Clicks out', fmt(t.k)], ['Credits earned', fmt(t.c)]].map(([k, v], i) => '<div class="tile' + (i === 3 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
|
||||
$('rateNote').textContent = 'You earn 1 credit per ' + (RATE.viewsPerCredit || 5) + ' viewable views of a LinkSpin campaign and 1 per ' + (RATE.nasViewsPerCredit || 10) + ' viewable views of a network ad, capped at ' + (RATE.capPerVisitorDay || 50) + ' credited views per visitor per zone per day. House banners are not paid. Bots never count.';
|
||||
$('rateNote').textContent = 'You earn 1 credit per ' + (RATE.viewsPerCredit || 5) + ' viewable views of a LinkSpin campaign and 1 per ' + (RATE.nasViewsPerCredit || 10) + ' viewable views of a network ad (1 per ' + (RATE.nasViewsPerCreditVerified || 8) + ' on a Verified zone), capped at ' + (RATE.capPerVisitorDay || 50) + ' credited views per visitor per zone per day. House banners are not paid. Bots never count. Every zone starts Standard; a reviewed site can be marked Verified by the admin.';
|
||||
firstRun();
|
||||
const q = g => '<span class="q ' + (g === 'A' ? 'ok' : g === 'B' ? 'warn' : g === 'C' ? 'bad' : 'muted') + '">' + [1, 2, 3, 4, 5].map(i => '<i class="' + (g === 'A' ? (i <= 5 ? 'on' : '') : g === 'B' ? (i <= 3 ? 'on' : '') : g === 'C' ? (i <= 1 ? 'on' : '') : '') + '"></i>').join('') + '</span>' + (g || '');
|
||||
$('rows').innerHTML = Z.length ? Z.map(z => '<div class="rw' + (z.id === SEL ? ' on' : '') + '"><div><b>' + esc(z.name) + '</b>' + (z.site ? ' <span class="muted">· ' + esc(z.site) + '</span>' : '') + '<br><span class="mono muted" style="font-size:11px">' + z.id + ' · ' + (z.lastSeen ? 'last view ' + ago(z.lastSeen) : 'no views yet') + (z.views30 ? ' · mix: ' + fmt(z.campaign30 || 0) + ' LinkSpin / ' + fmt(z.nas30 || 0) + ' network / ' + fmt(z.house30 || 0) + ' house' : '') + '</span></div><span class="mono">' + z.size + '</span><span class="r num">' + fmt(z.views30) + '</span><span class="r num">' + (z.viewablePct == null ? '<span class="muted">·</span>' : z.viewablePct + '%') + '</span><span class="r num">' + fmt(z.credits) + '</span><span class="mono" style="font-size:11px">' + (z.grade ? q(z.grade) : '<span class="muted">no data</span>') + ' <span class="tag ' + (z.status === 'earning' ? 'ok' : z.status === 'warming' ? '' : 'warn') + '">' + esc(z.statusLabel || '') + '</span>' + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap"><button class="btn sm" type="button" data-tag="' + z.id + '">Tag</button><button class="btn sm" type="button" data-tog="' + z.id + '">' + (z.active ? 'Off' : 'On') + '</button><button class="btn sm danger" type="button" data-del="' + z.id + '" aria-label="Remove">×</button></span></div>').join('')
|
||||
$('rows').innerHTML = Z.length ? Z.map(z => '<div class="rw' + (z.id === SEL ? ' on' : '') + '"><div><b>' + esc(z.name) + '</b>' + (z.site ? ' <span class="muted">· ' + esc(z.site) + '</span>' : '') + (z.tier === 'verified' ? ' <span class="tag ok">Verified</span>' : '') + '<br><span class="mono muted" style="font-size:11px">' + z.id + ' · ' + (z.lastSeen ? 'last view ' + ago(z.lastSeen) : 'no views yet') + (z.views30 ? ' · mix: ' + fmt(z.campaign30 || 0) + ' LinkSpin / ' + fmt(z.nas30 || 0) + ' network / ' + fmt(z.house30 || 0) + ' house' : '') + '</span></div><span class="mono">' + z.size + '</span><span class="r num">' + fmt(z.views30) + '</span><span class="r num">' + (z.viewablePct == null ? '<span class="muted">·</span>' : z.viewablePct + '%') + '</span><span class="r num">' + fmt(z.credits) + '</span><span class="mono" style="font-size:11px">' + (z.grade ? q(z.grade) : '<span class="muted">no data</span>') + ' <span class="tag ' + (z.status === 'earning' ? 'ok' : z.status === 'warming' ? '' : 'warn') + '">' + esc(z.statusLabel || '') + '</span>' + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap"><button class="btn sm" type="button" data-tag="' + z.id + '">Tag</button><button class="btn sm" type="button" data-tog="' + z.id + '">' + (z.active ? 'Off' : 'On') + '</button><button class="btn sm danger" type="button" data-del="' + z.id + '" aria-label="Remove">×</button></span></div>').join('')
|
||||
: '<div class="rw"><span class="muted">No zones yet. Add one, paste the tag on your site, and the banner is live.</span></div>';
|
||||
$('foot').textContent = 'viewable = at least half the banner on screen for one second, reported by the tag · quality: A 60%+ viewable, B 40%+, C below · paid ads serve only on the declared site; a zone earns after its first 100 on-site views with 40%+ viewable and goes on hold below that';
|
||||
$('rows').querySelectorAll('[data-tag]').forEach(b => b.addEventListener('click', () => showTag(b.dataset.tag)));
|
||||
@@ -21,11 +22,30 @@
|
||||
$('rows').querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async () => { if (!await dialog({ title: 'Remove this zone?', text: 'The tag on your site stops showing ads. Credits already earned stay.', ok: 'Remove', danger: true })) return; try { await api('/api/my/zones/' + b.dataset.del, { remove: true }); SEL = null; $('tagPanel').hidden = true; load(); } catch (e) { toast(e.message, true); } }));
|
||||
if (SEL && Z.find(z => z.id === SEL)) showTag(SEL);
|
||||
}
|
||||
function showTag(id) { const z = Z.find(x => x.id === id); if (!z) return; SEL = id; $('tagPanel').hidden = false; $('tagTitle').textContent = 'Embed tag · ' + z.name; $('tagCode').textContent = tag(z); $('tagNote').textContent = 'Paste it where the banner should appear (' + z.size + '). It sizes itself and never loads more than one ad. Tip: do not wrap it in an element whose class or id contains "ad", "banner" or "sponsor" (ad blockers hide those), and if you test with an ad blocker on, pause it for your own site first.'; $('tagCopy').onclick = () => CR.copy(tag(z)); $('tagCheck').onclick = async () => { await load(); const zz = Z.find(x => x.id === id); toast(zz && zz.lastSeen && Date.now() - zz.lastSeen < 3600e3 ? 'Live: last view ' + ago(zz.lastSeen) : 'No view in the last hour. Is the tag on a page people open?', !(zz && zz.lastSeen && Date.now() - zz.lastSeen < 3600e3)); }; }
|
||||
$('newBtn').addEventListener('click', async () => {
|
||||
function showTag(id) { const z = Z.find(x => x.id === id); if (!z) return; SEL = id; $('tagPanel').hidden = false; $('tagTitle').textContent = 'Embed tag · ' + z.name; $('tagCode').textContent = tag(z); $('tagNote').textContent = 'Paste it where the banner should appear (' + z.size + '). It sizes itself and never loads more than one ad. Tip: do not wrap it in an element whose class or id contains "ad", "banner" or "sponsor" (ad blockers hide those), and if you test with an ad blocker on, pause it for your own site first.'; $('tagCopy').onclick = () => { CR.copy(tag(z)); COPIED = true; LS.set('ls.zoneTagCopied', '1'); firstRun(); }; $('tagCheck').onclick = async () => { await load(); const zz = Z.find(x => x.id === id); toast(zz && zz.lastSeen && Date.now() - zz.lastSeen < 3600e3 ? 'Live: last view ' + ago(zz.lastSeen) : 'No view in the last hour. Is the tag on a page people open?', !(zz && zz.lastSeen && Date.now() - zz.lastSeen < 3600e3)); }; }
|
||||
async function addZone() {
|
||||
const v = await dialog({ title: 'Add a zone', text: 'One zone per spot on a page. Paid ads only serve on the site you name here; anywhere else the tag shows the house banner.', fields: [{ k: 'name', label: 'Name', placeholder: 'My blog · sidebar', max: 60 }, { k: 'site', label: 'Site it lives on (required)', placeholder: 'myblog.com', max: 80 }, { k: 'size', label: 'Size: ' + (SIZES.join(', ') || '728x90, 468x60, 300x250, 160x600, 320x50'), value: '728x90', mono: true }], ok: 'Create' });
|
||||
if (!v) return; try { const r = await api('/api/my/zones', v); SEL = r.zone.id; toast('Zone created. Copy the tag.'); load(); } catch (e) { toast(e.message, true); }
|
||||
});
|
||||
}
|
||||
$('newBtn').addEventListener('click', addZone);
|
||||
// ---- first-run card (publisher onboarding, 2026-10-10): site, size, copy the tag, check it is live. Shows while the
|
||||
// account has no zone with a view, or when /zones?start=1 (the /publishers Start button) asks for it; Hide remembers.
|
||||
const START = /[?&]start=1\b/.test(location.search); const LS = { get: k => { try { return localStorage.getItem(k); } catch (e) { return null; } }, set: (k, v) => { try { localStorage.setItem(k, v); } catch (e) {} } };
|
||||
let COPIED = LS.get('ls.zoneTagCopied') === '1';
|
||||
function firstRun() {
|
||||
const fr = $('firstRun'); if (!fr) return;
|
||||
const live = Z.some(z => z.lastSeen); const hidden = LS.get('ls.zonesFirstRunHidden') === '1';
|
||||
if ((hidden || live) && !START) { fr.hidden = true; return; }
|
||||
fr.hidden = false;
|
||||
const step = !Z.length ? 1 : (!COPIED && !live) ? 3 : !live ? 4 : 5; // 1-2 site+size, 3 copy, 4 check, 5 done
|
||||
const steps = [['Your site', 'The domain the tag will live on, exactly as the address bar shows it. Paid ads serve only there.'], ['Size', 'The banner size of the spot. 728x90 and 468x60 also get network ads.'], ['Copy the tag', 'Paste it where the banner should appear: a widget, a template, an HTML block.'], ['Check it is live', 'Open your page once, then press the button. The warm-up counter starts with that first view.']];
|
||||
$('frSteps').innerHTML = steps.map(([t, d], i) => { const n = i + 1; const done = n < step || (n <= 2 && step > 2) || step === 5; const now = !done && (n === step || (step === 1 && n === 2)); return '<li class="' + (done ? 'done' : now ? 'now' : '') + '"><b><i>' + (done ? '✓' : n) + '</i>' + t + '</b><span class="muted">' + d + '</span></li>'; }).join('');
|
||||
$('frTitle').textContent = step === 5 ? 'Your site is live' : 'Add your site';
|
||||
$('frIntro').textContent = step === 5 ? 'The tag is serving. The zone earns after its first ' + (RATE.warmup || 100) + ' on-site views with 40% or more viewable; the status column tells you where it stands. Add another spot any time.' : step >= 3 ? 'Zone created. Copy the tag, paste it on ' + esc(Z[0].site) + ', then check it is live.' : 'Four steps and your site is carrying the network. Paid ads serve only on the site you name, and every viewable impression pays you ad credits.';
|
||||
const go = $('frGo'); go.textContent = step === 1 ? 'Add your site' : step === 3 ? 'Show the tag' : step === 4 ? 'Check it is live' : 'Add another zone';
|
||||
go.onclick = () => { if (step === 1 || step === 5) return addZone(); showTag(Z[0].id); if (step === 4) $('tagCheck').click(); };
|
||||
$('frHide').onclick = () => { LS.set('ls.zonesFirstRunHidden', '1'); fr.hidden = true; };
|
||||
}
|
||||
// ---- audiences (first-party retargeting)
|
||||
const ptag = a => '<script async src="https://' + HOST + '/p.js" data-aud="' + a.id + '"></script>';
|
||||
async function loadAudiences() {
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<div class="ph"><h2>The rules it enforces</h2><span class="meta">constants · no setters exist</span></div>
|
||||
<div class="pb" style="padding-top:6px">
|
||||
<div class="rule"><b>Split</b><span>50% to the buyer's sponsor, 20% to level 2, 10% to level 3, 10% + 10% to two platform wallets. Compiled into the bytecode. No function exists to change them.</span></div>
|
||||
<div class="rule"><b>Qualifying</b><span>Level 2 pays a member after two of their referrals buy a package of $20 or more. Level 3 after five. Qualification is earned by referred buyers and cannot be bought.</span></div>
|
||||
<div class="rule"><b>Qualifying</b><span>Level 2 pays a member after two of their referrals buy a package of $25 or more. Level 3 after five. Qualification is earned by referred buyers and cannot be bought.</span></div>
|
||||
<div class="rule"><b>Pass-ups</b><span>A share with no qualified member at that level climbs to the next qualified member above, up to 25 steps, then to the platform. Nothing waits in a balance.</span></div>
|
||||
<div class="rule"><b>Failed sends</b><span>Payouts are pushed with a strict gas allowance. A wallet that cannot receive is treated as unqualified and its share passes up. The purchase never reverts and never holds funds. Use a normal wallet address for payouts; some exotic smart-contract wallets cost more gas to receive than the allowance.</span></div>
|
||||
<div class="rule"><b>Pricing</b><span>Packages are priced in dollars. The POL amount comes from the Chainlink POL/USD feed at the moment you buy; a small overpayment refunds in the same transaction. A feed older than an hour falls back to the last good price for up to a day, then new purchases pause until it returns.</span></div>
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
<p class="lead">Every free way to earn ad credits, the claim streak, and the one thing that makes the credits worth anything: spending them on a campaign.</p>
|
||||
</section>
|
||||
|
||||
<div class="rule"><b>This page is about credits, which every member earns.</b> POL, the crypto the contract pays to your wallet when your referrals buy packages, is separate: activate with the $20 starter package and switch on payouts, and level 1 pays 50 percent of every package your directs buy.</div>
|
||||
<div class="rule"><b>This page is about credits, which every member earns.</b> POL, the crypto the contract pays to your wallet when your referrals buy packages, is separate: activate with the $25 Starter package and switch on payouts, and level 1 pays 50 percent of every package your directs buy.</div>
|
||||
<div class="rule"><b>One credit is one cent of ad delivery.</b> Credits are not money and cannot be withdrawn. They buy impressions, clicks and visits for your own campaigns across LinkSpin and the partner network. Payouts in POL come only from packages people in your line buy.</div>
|
||||
|
||||
<h2>1. The daily set</h2>
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@
|
||||
<p>Members buy ad packages to run banner, text and login ads across the viewer, every member zone and the partner network. Each purchase is split in the same transaction on Polygon. Nothing is held. Nothing is promised later. The contract is public and cannot be changed.</p>
|
||||
<ul>
|
||||
<li>Your direct sponsor gets half of every package you buy, instantly.</li>
|
||||
<li>Level 2 opens after two of your people buy a $20 or larger package. Level 3 after five.</li>
|
||||
<li>Level 2 opens after two of your people buy a $25 or larger package. Level 3 after five.</li>
|
||||
<li>A share with no qualified member passes up the line, then to the platform. It never waits in a balance.</li>
|
||||
<li>The $10 door is for trying the ads. It does not count toward opening levels, and we say so.</li>
|
||||
</ul>
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@
|
||||
|
||||
<div class="lw-rule">
|
||||
<b>The one rule that makes this week matter: unqualified levels pass up.</b>
|
||||
Level 2 pays you only after two of your people have bought a $20 or more package. Level 3 only after five. If your team's team starts buying before you are qualified, those 20% and 10% payments climb to the next qualified member above you, or to the platform, and they never come back. Qualify first, then open the doors.
|
||||
Level 2 pays you only after two of your people have bought a $25 or more package. Level 3 only after five. If your team's team starts buying before you are qualified, those 20% and 10% payments climb to the next qualified member above you, or to the platform, and they never come back. Qualify first, then open the doors.
|
||||
</div>
|
||||
|
||||
<ol class="chk" id="chk"></ol>
|
||||
|
||||
+28
-4
@@ -23,7 +23,26 @@
|
||||
.dhead{display:flex;align-items:center;gap:14px;padding:12px 24px;border-bottom:1px solid var(--line);background:var(--panel);flex-wrap:wrap}
|
||||
.dhead h2{font-family:var(--display);font-size:24px;font-weight:700;letter-spacing:.02em;margin:0}
|
||||
.dbody{padding:16px 24px;display:grid;gap:14px}
|
||||
.dest .hd,.dest .rw{grid-template-columns:minmax(0,2fr) 150px 80px 80px 110px 90px}
|
||||
.dest .hd,.dest .rw{grid-template-columns:minmax(0,2fr) 150px 80px 80px 110px 130px}
|
||||
.dest .rw.edit{grid-template-columns:1fr;background:var(--panel-2)}
|
||||
.dest .dl{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
||||
.hdot{display:inline-block;width:9px;height:9px;border-radius:50%;background:var(--line-strong);flex:none;vertical-align:middle}
|
||||
.hdot.ok{background:var(--ok);box-shadow:0 0 0 2px rgba(14,138,92,.2)} .hdot.warn{background:#D98B0C;box-shadow:0 0 0 2px rgba(217,139,12,.2)} .hdot.bad{background:var(--bad);box-shadow:0 0 0 2px rgba(185,28,28,.2)}
|
||||
.hchip{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10px;font-weight:700;color:var(--ink-2);border:1px solid var(--line-strong);border-radius:999px;padding:2px 8px;white-space:nowrap;background:#fff;cursor:pointer;letter-spacing:.02em}
|
||||
.hchip.set{color:var(--sig-2);border-color:rgba(255,106,26,.5);background:var(--sig-soft)}
|
||||
.he{display:grid;gap:10px}
|
||||
.he-presets{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
|
||||
.he-tz{display:flex;gap:8px;align-items:center;flex-wrap:wrap} .he-tz select{width:auto;min-width:180px} .he-tz input{width:200px}
|
||||
.he-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;padding-bottom:6px}
|
||||
.he-grid{display:grid;grid-template-columns:36px repeat(24,22px);gap:2px;touch-action:pan-x;user-select:none;-webkit-user-select:none;width:max-content}
|
||||
.he-grid .hl{font-family:var(--mono);font-size:9px;font-weight:700;color:var(--muted);text-align:center;align-self:end;line-height:1}
|
||||
.he-grid .dlb{font-family:var(--mono);font-size:11px;font-weight:700;color:var(--ink-2);align-self:center;cursor:pointer}
|
||||
.he-grid .c{width:22px;height:22px;border-radius:3px;background:var(--panel-2);border:1px solid var(--line);cursor:pointer;box-sizing:border-box}
|
||||
.he-grid .c.heat{background:rgba(31,111,235,var(--heat))}
|
||||
.he-grid .c.on{background:var(--sig);border-color:var(--sig-2)}
|
||||
.he-sum{font-weight:700} .he-sum small{font-weight:500;color:var(--muted)}
|
||||
.he .acts{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
||||
.note{border:1px solid rgba(194,65,12,.4);background:var(--warn-soft);color:var(--warn);border-radius:8px;padding:8px 12px;font-size:12px}
|
||||
.wrow{display:flex;align-items:center;gap:8px} .wrow input{width:56px}
|
||||
.empty{padding:40px 24px;color:var(--muted);text-align:center;display:grid;gap:10px;justify-items:center}
|
||||
.two{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:16px}
|
||||
@@ -52,7 +71,9 @@
|
||||
<span class="code" id="dUrl"></span>
|
||||
<button class="btn sm" type="button" id="copyBtn">Copy</button>
|
||||
<span class="mono" id="dLive"></span>
|
||||
<button class="hchip" type="button" id="hoursChip" title="Hours this link is on">Always on</button>
|
||||
<span class="grow"></span>
|
||||
<button class="btn sm" type="button" id="checkBtn" title="Check every destination right now">Check now</button>
|
||||
<button class="btn sm" type="button" id="renameBtn">Rename</button>
|
||||
<button class="btn sm" type="button" id="pauseBtn">Pause</button>
|
||||
<button class="btn sm danger" type="button" id="delBtn">Delete</button>
|
||||
@@ -67,6 +88,7 @@
|
||||
<button type="button" data-tab="share">Share kit</button>
|
||||
</div>
|
||||
<div id="tab-dest">
|
||||
<div class="note" id="autoNote" hidden style="margin-bottom:10px"></div>
|
||||
<div class="tbl dest">
|
||||
<div class="hd"><span>Destination</span><span>Weight</span><span class="r">Clicks</span><span class="r">Unique</span><span>Status</span><span></span></div>
|
||||
<div id="destRows"></div>
|
||||
@@ -81,11 +103,13 @@
|
||||
<button class="btn pri" type="button" id="addBtn">Add</button>
|
||||
</div>
|
||||
<div class="muted">Macros in a destination are filled per visitor: <span class="mono">{clickid} {subid} {s1}…{s5} {source} {country} {device} {lsid}</span>. Example: <span class="mono">https://tracker.example/?cid={clickid}&src={source}</span></div>
|
||||
<label class="lbl">Fallback, used when every destination is paused or the link is paused<input class="field mono" id="fallback" type="url" placeholder="https://"></label>
|
||||
<label class="lbl">Fallback, used when every destination is paused, the link is paused, or the link is outside its hours<input class="field mono" id="fallback" type="url" placeholder="https://"></label>
|
||||
<div class="muted mono" id="fallbackHealth" style="font-size:11px"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tab-hours" hidden>
|
||||
<div class="panel"><h2>Clicks by hour, UTC, all time</h2><div class="bars" id="hourBars" style="grid-template-columns:repeat(24,minmax(0,1fr))"></div><div class="axis"><span>00</span><span>06</span><span>12</span><span>18</span><span>23</span></div><div class="muted">Hour rules (open a destination only at set hours) come in the next pass; this is where they will live.</div></div>
|
||||
<div class="panel"><h2>Hours this link is on</h2><div class="muted">Outside these hours visitors go to the fallback. Each destination can have its own hours too (the clock button on its row). Tap a cell to flip it, drag to paint, or start from a preset.</div><div id="rotHours"></div></div>
|
||||
<div class="panel" style="margin-top:12px"><h2>Clicks by hour, UTC, all time</h2><div class="bars" id="hourBars" style="grid-template-columns:repeat(24,minmax(0,1fr))"></div><div class="axis"><span>00</span><span>06</span><span>12</span><span>18</span><span>23</span></div><div class="muted" id="offNote"></div></div>
|
||||
</div>
|
||||
<div id="tab-sources" hidden>
|
||||
<div class="two">
|
||||
@@ -112,6 +136,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261008c"></script>
|
||||
<script src="/assets/links.js?v=20260929d"></script>
|
||||
<script src="/assets/links.js?v=20261010b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+6
-6
@@ -207,7 +207,7 @@
|
||||
<div class="card" id="lineTreeCard">
|
||||
<div class="card-head"><h3>Your line at a glance</h3><span class="sub" id="treeSub"></span></div>
|
||||
<div id="lineTree" class="line-tree"><p class="muted small">Loading your line…</p></div>
|
||||
<p class="small muted" id="treeLegend" style="margin:10px 0 0;line-height:2"><span class="lt-node qualified" style="font-size:11px;padding:2px 8px">name</span> bought a $20+ package: counts as a qualifying buyer for their sponsor (on level 1, that is you) · <span class="lt-node" style="font-size:11px;padding:2px 8px">name<i class="lt-n">2</i></span> their own qualifying buyers · <span class="lt-node" style="font-size:11px;padding:2px 8px">name</span> joined, no $20+ buy yet · <span class="lt-node open" style="font-size:11px;padding:2px 8px">+ open</span> spot still open</p>
|
||||
<p class="small muted" id="treeLegend" style="margin:10px 0 0;line-height:2"><span class="lt-node qualified" style="font-size:11px;padding:2px 8px">name</span> bought a $25+ package: counts as a qualifying buyer for their sponsor (on level 1, that is you) · <span class="lt-node" style="font-size:11px;padding:2px 8px">name<i class="lt-n">2</i></span> their own qualifying buyers · <span class="lt-node" style="font-size:11px;padding:2px 8px">name</span> joined, no $25+ buy yet · <span class="lt-node open" style="font-size:11px;padding:2px 8px">+ open</span> spot still open</p>
|
||||
</div>
|
||||
<div class="card" id="badgeCard" hidden>
|
||||
<div class="card-head"><h3>Your achievements</h3><span class="sub">unlock as you build</span></div>
|
||||
@@ -273,7 +273,7 @@
|
||||
<div class="card">
|
||||
<h3>Your line</h3>
|
||||
<p class="muted small">Everyone who joined through your link, newest first. When they buy their
|
||||
first package of $20 or more, they count toward your qualification.</p>
|
||||
first package of $25 or more, they count toward your qualification.</p>
|
||||
<div id="rosterWrap"><p class="muted small" id="rosterEmpty">Nobody yet. Your link is ready above; share it and this list starts filling.</p></div>
|
||||
</div>
|
||||
<div class="card" id="tankCard">
|
||||
@@ -394,12 +394,12 @@
|
||||
</div>
|
||||
<div class="card" id="qsCard">
|
||||
<h3>Qualified Start: your own positions</h3>
|
||||
<p class="muted small">Qualification is earned by buyers you refer, and it is never for sale. But nothing stops you from being your own first buyers, openly. Link a second wallet of your own as a <b>position</b> under your account. When it buys a $20 or larger package, the contract counts it as a qualifying buyer, half the purchase comes straight back to your main wallet, and the credits it mints pool with yours. Two positions open level 2 the same day. Five open level 3.</p>
|
||||
<p class="muted small">Qualification is earned by buyers you refer, and it is never for sale. But nothing stops you from being your own first buyers, openly. Link a second wallet of your own as a <b>position</b> under your account. When it buys a $25 or larger package, the contract counts it as a qualifying buyer, half the purchase comes straight back to your main wallet, and the credits it mints pool with yours. Two positions open level 2 the same day. Five open level 3.</p>
|
||||
<ol class="small" style="margin:0 0 12px 18px;padding:0;line-height:1.6">
|
||||
<li>Link your main wallet and switch on payouts (Wallet tab) so positions can register under you.</li>
|
||||
<li>In your wallet app, create or switch to a <b>different account</b> (MetaMask: account menu, Add account. Trust or SafePal: switch wallet). Put enough POL in it for a $20 package plus gas.</li>
|
||||
<li>In your wallet app, create or switch to a <b>different account</b> (MetaMask: account menu, Add account. Trust or SafePal: switch wallet). Put enough POL in it for a $25 package plus gas.</li>
|
||||
<li>Click <b>Add a position</b>, pick that account in the picker, and sign once.</li>
|
||||
<li>Choose it under <b>Buy from</b> above and buy a $20 or larger package.</li>
|
||||
<li>Choose it under <b>Buy from</b> above and buy a $25 or larger package.</li>
|
||||
</ol>
|
||||
<p><button class="btn" id="qsAddBtn" type="button">Add a position</button>
|
||||
<span class="small muted" id="qsHint"></span></p>
|
||||
@@ -954,7 +954,7 @@
|
||||
</div>
|
||||
<div class="card" id="posCard" hidden>
|
||||
<h3>Your positions</h3>
|
||||
<p class="muted small">Extra wallets you own, registered under your main member. Their credits pool with yours and each one that buys $20 or more counts toward your qualification.</p>
|
||||
<p class="muted small">Extra wallets you own, registered under your main member. Their credits pool with yours and each one that buys $25 or more counts toward your qualification.</p>
|
||||
<div id="posList" class="small"></div>
|
||||
<p style="margin:10px 0 0"><a class="btn sec small" href="#buy">Add or buy from a position</a></p>
|
||||
</div>
|
||||
|
||||
+4
-1
@@ -26,6 +26,9 @@
|
||||
.ed{display:grid;gap:10px} .ed textarea{min-height:90px;resize:vertical}
|
||||
.pal{display:flex;gap:6px} .pal button{width:28px;height:28px;border-radius:50%;border:2px solid transparent;cursor:pointer} .pal button.on{border-color:var(--ink)}
|
||||
.leads .rw{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) 110px}
|
||||
.imgrow{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:-4px 0 0}
|
||||
.imgstrip{display:flex;gap:6px;flex-wrap:wrap;align-items:flex-start;min-height:12px}.imgstrip .im{position:relative;width:64px;height:48px;border:1px solid var(--line);border-radius:7px;overflow:hidden;cursor:pointer;background:var(--panel-2);display:block}.imgstrip .im img{width:100%;height:100%;object-fit:cover;display:block}.imgstrip .im:hover{border-color:var(--accent)}
|
||||
.imgstrip .x{position:absolute;top:2px;right:2px;width:18px;height:18px;border-radius:50%;border:0;background:rgba(0,0,0,.65);color:#fff;font:700 13px/18px var(--body);padding:0;cursor:pointer}.imgstrip .x:hover{background:var(--bad,#c0392b)}
|
||||
@media (max-width:900px){.ws{grid-template-columns:1fr}.side{border-left:0;border-top:1px solid var(--line)}.body{padding:12px 16px}.types{grid-template-columns:1fr}}
|
||||
</style>
|
||||
</head>
|
||||
@@ -70,6 +73,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261008c"></script>
|
||||
<script src="/assets/pages-screen.js?v=20261008b"></script>
|
||||
<script src="/assets/pages-screen.js?v=20261010a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+13
-11
@@ -51,6 +51,7 @@
|
||||
<p>You know I've been running ad sites for years, the kind your members already know: buy a package, run banners and text ads, click for credits. Two of mine, Faucet Wave and Tier One Ads, ran on a licensed script. The vendor went out of business, their license server went dark, and it crippled licenses that were fully paid. The sites died overnight and nothing I could do would bring them back.</p>
|
||||
<p>So I built LinkSpin from scratch as part of the Crypto Team Build Network. No vendor, no license server, and the part that always went wrong on ad sites, the money, is handled by a verified smart contract on Polygon instead of by me. When a package sells, the contract splits the payment and sends it in the same transaction. I never hold member funds, so there is no back office, no payday, and nothing anyone can switch off.</p>
|
||||
<p class="muted">Marty Bostick · Crypto Team Build Network</p>
|
||||
<p class="muted small">Run a site but no downline builder? The <a href="/publishers">publisher program</a> is the simpler offer: one script tag, ad credits for every viewable impression, a free account is enough.</p>
|
||||
|
||||
<h2>What LinkSpin is</h2>
|
||||
<p>An advertising platform where the ad spend in your line pays you. Members join free with an email address, no password and no wallet on day one. They earn credits by viewing ads and can run their first campaign for zero dollars. When they want more reach they buy an ad package, and every package that sells is split by the contract the moment it sells.</p>
|
||||
@@ -67,17 +68,18 @@
|
||||
<div><div class="n">50%</div>direct sponsor</div>
|
||||
<div><div class="n">20%</div>level 2</div>
|
||||
<div><div class="n">10%</div>level 3</div>
|
||||
<div><div class="n">20%</div>platform</div>
|
||||
<div><div class="n">10% + 10%</div>two admin wallets</div>
|
||||
</div>
|
||||
<p class="muted small">On a $20 package: $10 to the direct sponsor, $4 to level 2, $2 to level 3, $4 to the platform. If a level has no qualified member, that share passes up to the next qualified person above.</p>
|
||||
<p>Qualification is earned, never bought. Every direct buyer pays their sponsor 50% from their very first package. Two qualifying buyers, people who bought a $20 or larger package, open level 2. Five open level 3. Until a level opens, its share climbs to the next qualified member above, which is why the plan rewards the people who actually build.</p>
|
||||
<p class="muted small">On a $25 package: $12.50 to the direct sponsor, $5 to level 2, $2.50 to level 3, $2.50 to each of the two admin wallets. If a level has no qualified member, that share passes up to the next qualified person above, then to the platform.</p>
|
||||
<p>Qualification is earned, never bought. Every direct buyer pays their sponsor 50% from their very first package. Two qualifying buyers, people who bought a $25 or larger package, open level 2. Five open level 3. Until a level opens, its share climbs to the next qualified member above, which is why the plan rewards the people who actually build.</p>
|
||||
<table>
|
||||
<tr><th>Package</th><th>Price</th><th>Credits</th></tr>
|
||||
<tr><td>Micro</td><td>$5</td><td>500</td></tr>
|
||||
<tr><td>Activation, the qualifying buy</td><td>$20</td><td>2,000</td></tr>
|
||||
<tr><td>Builder</td><td>$50</td><td>5,500</td></tr>
|
||||
<tr><td>Growth</td><td>$100</td><td>12,000</td></tr>
|
||||
<tr><td>Leader</td><td>$250</td><td>32,500</td></tr>
|
||||
<tr><td>Door, for trying the ads (does not qualify)</td><td>$10</td><td>1,000</td></tr>
|
||||
<tr><td>Starter, the first qualifying buy</td><td>$25</td><td>2,500</td></tr>
|
||||
<tr><td>Builder</td><td>$50</td><td>5,000</td></tr>
|
||||
<tr><td>Growth</td><td>$100</td><td>10,000</td></tr>
|
||||
<tr><td>Leader</td><td>$250</td><td>25,000</td></tr>
|
||||
<tr><td>Network</td><td>$500</td><td>50,000</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>What your members get</h2>
|
||||
@@ -95,7 +97,7 @@
|
||||
<div class="get">
|
||||
<h3>What you get for listing it in your builder</h3>
|
||||
<ul>
|
||||
<li><b>Your spot at the top.</b> You join directly under the company at the top, no sponsor in between. All it takes to claim that spot is activating your account with at least the $20 package, and that locks you in at the top of your own line from day one.</li>
|
||||
<li><b>Your spot at the top.</b> You join directly under the company at the top, no sponsor in between. All it takes to claim that spot is activating your account with at least the $25 Starter package, and that locks you in at the top of your own line from day one.</li>
|
||||
<li><b>Your own promo code.</b> A reusable code that adds free ad credits for every member who redeems it, on your builder link or in the dashboard. I set the credit amount, an optional cap and an optional expiry. One redemption per account, every redemption logged, and you can see uses any time.</li>
|
||||
<li><b>Your own line.</b> Every member who comes through your builder link lands under you. Each one who buys pays you 50% of their first package and every package after it, and their buyers open your level 2 and level 3 shares.</li>
|
||||
<li><b>Ready-made creatives.</b> Banners in every builder size (468x60, 728x90, 300x250, 160x600, 120x600, 1200x630), text ad copy, email swipes and a program description you can paste into your listing.</li>
|
||||
@@ -110,7 +112,7 @@
|
||||
<li>Send me your username and the site you are listing it on. I mint your code with the credit amount we agree on.</li>
|
||||
<li>Add LinkSpin to your downline builder with your link plus the code: <code id="pkExample">{{SITE_URL}}/join/yourname?promo=YOURCODE</code>. Members who click it land under you and their credits apply the moment their account exists.</li>
|
||||
<li>Use the banners and text ads from the kit. Members who already have an account can type the code into the "Have a promo code?" box on their Overview.</li>
|
||||
<li>Link a wallet, switch on payouts, and activate with at least the $20 package. That claims your spot at the top and makes you a qualifying buyer in your own right.</li>
|
||||
<li>Link a wallet, switch on payouts, and activate with at least the $25 Starter package. That claims your spot at the top and makes you a qualifying buyer in your own right.</li>
|
||||
</ol>
|
||||
|
||||
<div class="cta">
|
||||
@@ -129,6 +131,6 @@
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261009a"></script>
|
||||
<script src="/assets/partners.js?v=20260914a"></script>
|
||||
<script src="/assets/partners.js?v=20261010a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+5
-5
@@ -79,9 +79,9 @@
|
||||
<div class="card play">
|
||||
<header><h2>Opening move · Qualified Start</h2><span class="tag">works with any play</span></header>
|
||||
<p class="muted"><b>Fits:</b> anyone who would rather start qualified than wait for their first two buyers.</p>
|
||||
<p>Qualification is earned by buyers, never bought. But you can be your own first buyers, openly. Under <a href="/credits">Buy packages</a>, link a second wallet you own as a <b>position</b>. When it buys a $20 package the contract counts it as a qualifying buyer, half the purchase comes straight back to your main wallet, and its credits pool with yours. Two positions open level 2 the same day; five open level 3. Then run whichever play fits you with the ladder already climbed. The three Qualified Start videos in <a href="/tools#training">Training</a> show every click.</p>
|
||||
<p>Qualification is earned by buyers, never bought. But you can be your own first buyers, openly. Under <a href="/credits">Buy packages</a>, link a second wallet you own as a <b>position</b>. When it buys a $25 or larger package the contract counts it as a qualifying buyer, half the purchase comes straight back to your main wallet, and its credits pool with yours. Two positions open level 2 the same day; five open level 3. Then run whichever play fits you with the ladder already climbed. The three Qualified Start videos in <a href="/tools#training">Training</a> show every click.</p>
|
||||
<div class="meta">
|
||||
<div><div class="k">Net cost</div>Level 2: about $20 net for $40 of ad credits. Level 3: about $50 net for $100 of credits. Plus a little POL for gas in each wallet.</div>
|
||||
<div><div class="k">Net cost</div>Level 2: about $25 net for $50 of ad credits. Level 3: about $63 net for $125 of credits. Plus a little POL for gas in each wallet.</div>
|
||||
<div><div class="k">Say it plainly</div>Your own money, your own wallets, a faster start. Never an income promise: qualification only pays on future purchases in your line.</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -107,7 +107,7 @@
|
||||
<p class="muted"><b>Fits:</b> someone with a small circle who would rather coach two people well than pitch twenty.</p>
|
||||
<p>Two qualifying buyers open level 2, wall position 2, the Circuit badge and 50 bonus credits. From there every person your two bring in pays you 20%, and every person those people bring in pays you 10% once you reach five. Your effort goes into two relationships instead of a funnel.</p>
|
||||
<ol>
|
||||
<li><b>Get two directs to a $20+ package.</b> Sit with them on the buy if you have to. Trust Wallet needs a POL cushion; SafePal or MetaMask are smoother.</li>
|
||||
<li><b>Get two directs to a $25+ package.</b> Sit with them on the buy if you have to. Trust Wallet needs a POL cushion; SafePal or MetaMask are smoother.</li>
|
||||
<li><b>Coach them to their two.</b> Sponsor chat daily for the first week. One broadcast a day to your directs with a single ask each time.</li>
|
||||
<li><b>Set your line banner to your team's meeting place</b> (a Telegram group, a training page). Every new member three levels down meets it on their welcome tour.</li>
|
||||
<li><b>Keep adding directs until you have five.</b> This is the catch: level 3 only opens on five qualifying directs of your own. Two deep, coached well, earns a healthy 20% level. It does not open the 10% level.</li>
|
||||
@@ -173,9 +173,9 @@
|
||||
<li>Main wallet linked (Wallet tab, one free signature).</li>
|
||||
<li>Payouts switched on (Wallet tab, one free transaction).</li>
|
||||
<li>Extra wallet accounts created in your wallet app: IAP Position 2, 3, 4, 5.</li>
|
||||
<li>Each extra account funded with enough POL for a $20 package plus gas.</li>
|
||||
<li>Each extra account funded with enough POL for a $25 package plus gas.</li>
|
||||
<li>Buy packages: Add a position, tick only the new account, sign once.</li>
|
||||
<li>Buy from: choose the position, Buy $20, confirm in the wallet.</li>
|
||||
<li>Buy from: choose the position, Buy $25, confirm in the wallet.</li>
|
||||
<li>Repeat. Two positions open level 2. Five open level 3 and the Nexus badge.</li>
|
||||
</ol>
|
||||
<h2>First 30 days, any play</h2>
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title>Publisher program | LinkSpin</title>
|
||||
<meta name="description" content="Put one script tag on your site and get paid in ad credits for every viewable impression. Nine sizes, member ads first, then network ads. A free account is enough.">
|
||||
<link rel="canonical" href="{{SITE_URL}}/publishers">
|
||||
<meta property="og:title" content="LinkSpin publisher program: your site carries the network, your ads ride free">
|
||||
<meta property="og:description" content="One script tag. Nine sizes. Every viewable impression pays ad credits you spend on your own ads across LinkSpin and the network.">
|
||||
<meta property="og:url" content="{{SITE_URL}}/publishers">
|
||||
<meta property="og:image" content="{{SITE_URL}}/banners/linkspin-og-1200x630.png">
|
||||
<meta name="theme-color" content="#0B1424">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<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="/assets/pub.css?v=20261007b">
|
||||
<style>
|
||||
.strip .n{font-family:var(--display);font-size:22px;color:var(--chrome-ink);letter-spacing:.04em;line-height:1}
|
||||
.strip .st{display:flex;align-items:baseline;gap:8px}
|
||||
.sizes{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px}
|
||||
.sz{padding:14px;display:flex;flex-direction:column;gap:10px;min-height:130px}
|
||||
.sz .box{height:62px;display:flex;align-items:center;justify-content:center}
|
||||
.sz .box i{display:block;background:repeating-linear-gradient(135deg,var(--accent-soft) 0 4px,#fff 4px 8px);border:1.5px solid var(--accent-dim);border-radius:2px}
|
||||
.sz .lab{display:flex;justify-content:space-between;align-items:center;gap:6px;flex-wrap:wrap}
|
||||
.sz .lab b{font:700 14px var(--mono)}
|
||||
.steps{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;counter-reset:step}
|
||||
.step{padding:18px 18px 20px;display:flex;flex-direction:column;gap:8px}
|
||||
.step::before{counter-increment:step;content:counter(step);font:700 26px var(--display);color:var(--sig);line-height:1}
|
||||
.step h3{margin:0;font-size:18px}
|
||||
.step p{margin:0;color:var(--ink-2);font-size:14px}
|
||||
.rates{width:100%;border-collapse:collapse;font-size:14px}
|
||||
.rates th,.rates td{text-align:left;padding:10px 12px;border-bottom:1px solid var(--line)}
|
||||
.rates th{font:700 10.5px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
|
||||
.rates td.n{font:700 15px var(--mono);white-space:nowrap}
|
||||
.yesno{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
|
||||
.yesno ul{margin:0;padding-left:18px;color:var(--ink-2);display:flex;flex-direction:column;gap:8px;font-size:15px}
|
||||
.tag.v{border-color:rgba(255,106,26,.45);color:var(--sig-2);background:var(--sig-soft)}
|
||||
.code{display:block;background:var(--inset);border:1px solid var(--chrome-line);border-radius:6px;color:#8CC8FF;font:500 12px var(--mono);padding:12px 14px;line-height:1.6;overflow-wrap:anywhere}
|
||||
.faq details{border:1px solid var(--line);border-radius:8px;background:var(--panel);padding:0 18px}
|
||||
.faq summary{cursor:pointer;font-weight:700;padding:14px 0;list-style:none;display:flex;justify-content:space-between;gap:12px}
|
||||
.faq summary::-webkit-details-marker{display:none}
|
||||
.faq summary::after{content:"+";font:700 18px var(--mono);color:var(--accent-hi);flex:none}
|
||||
.faq details[open] summary::after{content:"\2212"}
|
||||
.faq details p{margin:0 0 16px;color:var(--ink-2);font-size:15px}
|
||||
.faq{display:flex;flex-direction:column;gap:10px}
|
||||
@media (max-width:980px){.steps{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
||||
@media (max-width:640px){.steps,.yesno{grid-template-columns:1fr}.strip .n{font-size:18px}.rates{font-size:13px;table-layout:fixed}.rates th,.rates td{padding:8px 6px;overflow-wrap:anywhere}.rates td.n{white-space:normal;font-size:13px}}
|
||||
</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>
|
||||
<nav class="nav" aria-label="Page">
|
||||
<a href="#what">What a zone is</a><a href="#sizes">Sizes</a><a href="#pays">What pays</a><a href="#install">Install</a><a href="#tiers">Tiers</a><a href="#faq">FAQ</a>
|
||||
</nav>
|
||||
<span class="grow"></span>
|
||||
<a href="/join" class="btn ghost" data-join>Sign in</a>
|
||||
<a href="/join?v=zones" class="btn pri" data-start>Start</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="hero" id="top">
|
||||
<div class="wrap">
|
||||
<div class="copy">
|
||||
<span class="eyebrow">Publisher program · for site owners</span>
|
||||
<h1 class="disp">Your site has empty space.<br><em>Put it to work for your own ads.</em></h1>
|
||||
<p class="lede">Paste one script tag and your site carries the LinkSpin network: member ads first, then network ads, then our house banner. Every viewable impression pays you ad credits, and credits buy your own ads across LinkSpin and the network at one cent each. A free account is enough. You never need to buy anything.</p>
|
||||
<div class="ctas">
|
||||
<a href="/join?v=zones" class="btn pri" data-start>Start: add your site</a>
|
||||
<a href="#pays" class="btn">See what pays</a>
|
||||
</div>
|
||||
<div class="checks">
|
||||
<span class="check"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>Viewable impressions only</span>
|
||||
<span class="check"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>Bots never count</span>
|
||||
<span class="check"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>One script tag, nine sizes</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tile hi demo">
|
||||
<div class="ph"><h2>The tag</h2><span class="meta">async · one ad per load</span></div>
|
||||
<div class="pb" style="display:flex;flex-direction:column;gap:12px">
|
||||
<code class="code"><script async src="https://{{SITE_HOST}}/z.js" data-zone="ls-xxxxxx"></script></code>
|
||||
<p class="note" style="margin:0">That is the whole install. The zone id comes from your Control Room when you add a zone. The tag sizes itself to the size you picked, loads after your page, and shows exactly one ad.</p>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap"><span class="tag t">member ads</span><span class="tag t">network ads</span><span class="tag">house banner</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="strip" id="live" aria-live="polite">
|
||||
<div class="wrap">
|
||||
<span><span class="dot" id="stDot"></span><b>Network right now</b></span>
|
||||
<span class="st"><span class="n" id="stLive">·</span> zones live</span>
|
||||
<span class="st"><span class="n" id="stViews">·</span> viewable impressions, 7 days</span>
|
||||
<span class="st"><span class="n" id="stCredits">·</span> credits paid to publishers, 7 days</span>
|
||||
<span class="grow"></span>
|
||||
<span id="stUpdated">loading</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="sec" id="what">
|
||||
<div class="wrap">
|
||||
<div class="sec-h"><h2 class="disp">What a zone is</h2><span class="eyebrow">one slot · one tag · one ad at a time</span></div>
|
||||
<div class="grid3">
|
||||
<article class="tile card">
|
||||
<svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/></svg>
|
||||
<h3 class="disp">An ad slot on your site</h3>
|
||||
<p>A zone is one spot on a page where a banner goes. You name it, tell us the site it lives on, pick a size, and paste the tag there. Run as many zones as you have spots, up to 50 per account.</p>
|
||||
</article>
|
||||
<article class="tile card">
|
||||
<svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M6 12h12M8 18h8"/></svg>
|
||||
<h3 class="disp">The waterfall</h3>
|
||||
<p>Every load asks for a LinkSpin member campaign first, the same pool our ad viewer serves. If none fits, a network ad fills the spot. If nothing paid is available, the LinkSpin house banner shows so your layout never has a hole.</p>
|
||||
<div class="foot-row"><span class="tag t">1 · member ads</span><span class="tag t">2 · network ads</span><span class="tag">3 · house</span></div>
|
||||
</article>
|
||||
<article class="tile card">
|
||||
<svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg>
|
||||
<h3 class="disp">Locked to your site</h3>
|
||||
<p>Paid ads serve only on the site you declared for that zone, including its subdomains. If the tag turns up anywhere else, or the browser sends no referrer, the house banner shows and nothing is earned. That protects advertisers, and it protects your earnings from anyone copying your tag.</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="sec" id="sizes">
|
||||
<div class="wrap">
|
||||
<div class="sec-h"><h2 class="disp">Nine sizes</h2><span class="eyebrow">standard banner sizes · pick one per zone</span></div>
|
||||
<div class="sizes" id="sizeGrid">
|
||||
<div class="tile sz"><div class="box"><i style="width:182px;height:23px"></i></div><div class="lab"><b>728x90</b><span class="tag t">network ads too</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:117px;height:15px"></i></div><div class="lab"><b>468x60</b><span class="tag t">network ads too</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:75px;height:62px"></i></div><div class="lab"><b>300x250</b><span class="muted" style="font-size:12px">medium rectangle</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:84px;height:70px"></i></div><div class="lab"><b>336x280</b><span class="muted" style="font-size:12px">large rectangle</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:62px;height:62px"></i></div><div class="lab"><b>250x250</b><span class="muted" style="font-size:12px">square</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:31px;height:31px"></i></div><div class="lab"><b>125x125</b><span class="muted" style="font-size:12px">button</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:16px;height:60px"></i></div><div class="lab"><b>160x600</b><span class="muted" style="font-size:12px">skyscraper</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:12px;height:60px"></i></div><div class="lab"><b>120x600</b><span class="muted" style="font-size:12px">tall column</span></div></div>
|
||||
<div class="tile sz"><div class="box"><i style="width:160px;height:25px"></i></div><div class="lab"><b>320x50</b><span class="muted" style="font-size:12px">mobile bar</span></div></div>
|
||||
</div>
|
||||
<p class="note" style="margin:0;max-width:80ch">Member campaigns run in every size. Network ads fill the 728x90 and 468x60 sizes today. A size with no paid ad available shows the house banner, which is not paid, so put your zones where the big sizes fit if you can.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="sec" id="pays">
|
||||
<div class="wrap">
|
||||
<div class="sec-h"><h2 class="disp">What pays, and what does not</h2><span class="eyebrow">viewable impressions · counted by the tag · bots excluded</span></div>
|
||||
<div class="yesno">
|
||||
<div class="tile card">
|
||||
<h3 class="disp" style="color:var(--ok)">Pays</h3>
|
||||
<ul>
|
||||
<li><b>A viewable impression:</b> at least half the banner on screen for one second, reported by the tag on a real visit to your declared site.</li>
|
||||
<li><b>Member campaign views</b> at 1 credit per <span data-rate="viewsPerCredit">5</span> viewable views.</li>
|
||||
<li><b>Network ad views</b> at 1 credit per <span data-rate="nasViewsPerCredit">10</span> viewable views on a Standard zone, 1 per <span data-rate="nasViewsPerCreditVerified">8</span> on a Verified zone.</li>
|
||||
<li><b>Clicks</b> go to the advertiser's page in a new tab. You are paid for the view; clicks are a bonus for the advertiser, not a fee to you.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tile card">
|
||||
<h3 class="disp" style="color:var(--warn)">Does not pay</h3>
|
||||
<ul>
|
||||
<li><b>Bots and crawlers.</b> Known agents are dropped before the ad is even picked.</li>
|
||||
<li><b>Impressions nobody saw.</b> A banner below the fold that is never scrolled into view is served but not paid.</li>
|
||||
<li><b>The house banner</b> and any view on a site other than the one you declared.</li>
|
||||
<li><b>Repeat views past the cap:</b> <span data-rate="capPerVisitorDay">50</span> credited views per visitor per zone per day. Reloading a page all day does not add up.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tile" style="padding:0">
|
||||
<div class="ph"><h3>Warm-up and hold</h3><span class="meta">quality gate · same rule for every zone</span></div>
|
||||
<div class="pb" style="display:flex;flex-direction:column;gap:10px">
|
||||
<p style="margin:0;color:var(--ink-2)">A new zone serves ads at once but starts earning after its first <b data-rate="warmup">100</b> on-site views, and only if at least <b><span data-rate="holdPct">40</span>%</b> of them were viewable. If the viewable share later drops under that line, the zone goes on hold: it keeps serving, but stops earning until the share recovers. Your Zones screen shows the state of every zone in plain words: Warming up, Earning, or On hold.</p>
|
||||
<table class="rates" aria-label="Rates">
|
||||
<tr><th>What was viewed</th><th>Standard zone</th><th>Verified zone</th></tr>
|
||||
<tr><td>A LinkSpin member campaign</td><td class="n">1 credit per <span data-rate="viewsPerCredit">5</span> views</td><td class="n">1 credit per <span data-rate="viewsPerCredit">5</span> views</td></tr>
|
||||
<tr><td>A network ad</td><td class="n">1 credit per <span data-rate="nasViewsPerCredit">10</span> views</td><td class="n">1 credit per <span data-rate="nasViewsPerCreditVerified">8</span> views</td></tr>
|
||||
<tr><td>The house banner, an off-site view, a bot</td><td class="n muted">nothing</td><td class="n muted">nothing</td></tr>
|
||||
</table>
|
||||
<p class="note" style="margin:0">Rates are platform settings and are shown live here. Whole credits are added to your account as the meter fills; the running count carries over between days.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="sec" id="credits">
|
||||
<div class="wrap">
|
||||
<div class="two">
|
||||
<div class="text">
|
||||
<h2 class="disp">What credits buy</h2>
|
||||
<p>One credit is one cent of ad delivery. Credits you earn from zones spend the same way credits from a package do: on banner and text ads shown across the LinkSpin ad viewer, every member zone, and the partner network. Your ads, your pages, your offers, in front of people who are already clicking on ads.</p>
|
||||
<ul>
|
||||
<li>A free account is enough. Nothing to buy, ever, to run zones or to spend what they earn.</li>
|
||||
<li>Credits are advertising, not money. They never cash out and are never converted to crypto.</li>
|
||||
<li>The only crypto on LinkSpin is the contract split when a member buys a package, paid to sponsor wallets in the same transaction. Zones are outside that entirely.</li>
|
||||
<li>You can also set up <b>audiences</b>: everyone who viewed your zones is remembered for 30 days, so your own campaigns can target or exclude your visitors.</li>
|
||||
</ul>
|
||||
<div class="ctas"><a href="/join?v=zones" class="btn pri" data-start>Add your site</a><a href="/" class="btn">What else LinkSpin does</a></div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="ph"><h3>A month on one blog, as an example of the math</h3><span class="meta">illustration, not a promise</span></div>
|
||||
<div class="pb" style="display:flex;flex-direction:column;gap:8px;font-size:14px;color:var(--ink-2)">
|
||||
<div style="display:flex;justify-content:space-between;gap:12px"><span>Viewable member-ad views in a month</span><b class="mono">4,000</b></div>
|
||||
<div style="display:flex;justify-content:space-between;gap:12px"><span>Credits earned at 1 per 5</span><b class="mono">800</b></div>
|
||||
<div style="display:flex;justify-content:space-between;gap:12px"><span>Worth, at one cent of delivery each</span><b class="mono">$8.00 of your own ads</b></div>
|
||||
<p class="note" style="margin:6px 0 0">Your numbers depend on your traffic, your placement, and which ads are available. The platform shows you real counts per zone, every day, so you never have to guess.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="sec" id="install">
|
||||
<div class="wrap">
|
||||
<div class="sec-h"><h2 class="disp">Install in four steps</h2><span class="eyebrow">about five minutes · no code beyond paste</span></div>
|
||||
<div class="steps">
|
||||
<div class="tile step"><h3 class="disp">Free account</h3><p>Join with your email. A six-digit code signs you in; there is no password and no wallet step. If you already have a LinkSpin account, you are done with this step.</p></div>
|
||||
<div class="tile step"><h3 class="disp">Add a zone</h3><p>Open Zones in your Control Room and press Add a zone. Name it after the spot, enter the site it lives on exactly as the browser shows it (like <b>myblog.com</b>), and pick a size.</p></div>
|
||||
<div class="tile step"><h3 class="disp">Paste the tag</h3><p>Press Tag, copy it, and paste it where the banner should appear: a theme widget, a template file, or a page builder's HTML block. Repeat for each spot with its own zone.</p></div>
|
||||
<div class="tile step"><h3 class="disp">Check it is live</h3><p>Open the page on your site, then press Check it is live in your Control Room. It confirms the last view and shows the ad mix. The warm-up counter starts with that first view.</p></div>
|
||||
</div>
|
||||
<div class="tile" style="padding:0">
|
||||
<div class="ph"><h3>About the site you enter</h3><span class="meta">origin lock</span></div>
|
||||
<div class="pb" style="display:flex;flex-direction:column;gap:8px;color:var(--ink-2);font-size:15px">
|
||||
<p style="margin:0">The site on a zone is where paid ads are allowed to serve. Enter the domain people see in the address bar, without https:// and without a path. <b>www</b> is ignored, and every subdomain of the site counts, so <b>myblog.com</b> covers www.myblog.com and news.myblog.com. A different site needs its own zone.</p>
|
||||
<p style="margin:0">Two tips: do not wrap the tag in an element whose class or id contains "ad", "banner" or "sponsor", because ad blockers hide those. And if you test with an ad blocker on, pause it for your own site first; otherwise you will not see the banner and may think the tag failed.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="sec" id="tiers">
|
||||
<div class="wrap">
|
||||
<div class="sec-h"><h2 class="disp">Two tiers</h2><span class="eyebrow">every zone starts Standard · Verified is reviewed by us</span></div>
|
||||
<div class="two">
|
||||
<article class="tile card">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;gap:10px"><h3 class="disp">Standard</h3><span class="tag">default</span></div>
|
||||
<p>Every new zone. Member campaigns at 1 credit per <span data-rate="viewsPerCredit">5</span> viewable views, network ads at 1 per <span data-rate="nasViewsPerCredit">10</span>. The warm-up, hold and cap rules apply. No application, no waiting.</p>
|
||||
</article>
|
||||
<article class="tile card hi">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;gap:10px"><h3 class="disp">Verified</h3><span class="tag v">reviewed site</span></div>
|
||||
<p>For sites we have looked at: real content, real visitors, the tag placed where people see it. A Verified zone earns the higher network share, 1 credit per <span data-rate="nasViewsPerCreditVerified">8</span> network views, and keeps everything else the same. Once a zone has been earning for a while, ask for a review from your Control Room or by email, and the admin sets the tier.</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="sec" id="faq">
|
||||
<div class="wrap">
|
||||
<div class="sec-h"><h2 class="disp">Questions site owners ask</h2></div>
|
||||
<div class="faq">
|
||||
<details><summary>Do I have to buy anything?</summary><p>No. A free account runs zones, earns credits and spends them on your own ads. Packages exist for members who want more reach than they earn, and buying one is never required.</p></details>
|
||||
<details><summary>Why is my zone showing the LinkSpin banner?</summary><p>The house banner shows whenever nothing paid is available for that size, or when the tag is running somewhere other than the site you declared, or when the page sends no referrer. Check the site on the zone matches your address bar, and give member campaigns time to rotate in. Member campaigns fill every size; network ads fill the two leaderboard sizes.</p></details>
|
||||
<details><summary>What counts as a viewable impression?</summary><p>At least half of the banner inside the visible part of the browser window for one full second, reported by the tag from a real browser. Views from known bots are dropped before anything is counted, and credited views are capped at <span data-rate="capPerVisitorDay">50</span> per visitor per zone per day.</p></details>
|
||||
<details><summary>Can I run zones on more than one site?</summary><p>Yes. Each zone is tied to one site. Add a zone per site, and as many zones per site as you have spots, up to 50 zones per account.</p></details>
|
||||
<details><summary>Can I cash the credits out?</summary><p>No. Credits are advertising and only ever buy ad delivery. The only money that moves on LinkSpin is the contract split when a member buys a package, and it goes straight to sponsor wallets on Polygon. Zones are not part of that split.</p></details>
|
||||
<details><summary>What do you learn about my visitors?</summary><p>Nothing personal. The tag records the zone, the time, a one-day anonymous visitor token, whether the banner was seen and whether it was clicked. Visitors to your zones also join your own retargeting audience for 30 days, which only your campaigns can use.</p></details>
|
||||
<details><summary>Will the tag slow my pages or load more than one ad?</summary><p>The script loads async, after your content, and fetches exactly one creative per load. It does not run pop-ups, redirects or audio.</p></details>
|
||||
<details><summary>How do I get a zone Verified?</summary><p>Run it Standard until it is earning, then ask for a review. We look for a live site with real content and real visitors, the tag placed where people actually see it, and a healthy viewable share. The admin flips the tier; your Zones screen shows it.</p></details>
|
||||
<details><summary>What if my viewable share drops?</summary><p>Your zone goes on hold under <span data-rate="holdPct">40</span>% viewable: it keeps serving but stops earning. Move the tag above the fold or into a spot visitors reach, and it comes back on its own as the share recovers. Nothing already earned is taken back.</p></details>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="last">
|
||||
<div class="wrap">
|
||||
<div>
|
||||
<h2 class="disp">Add your site</h2>
|
||||
<p>Free account by email, a zone in a minute, the tag on your page a minute after that. Your Zones screen walks you through it.</p>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;gap:12px">
|
||||
<div class="ctas"><a href="/join?v=zones" class="btn pri" data-start>Start: add your site</a><a href="/partners" class="btn">Run a downline builder? See the partner kit</a></div>
|
||||
<p class="note" style="margin:0">LinkSpin sells advertising. Publishers earn ad credits, not money; credits never cash out. No income is promised anywhere on this platform, and the figures on this page are illustrations of how credits are counted, not projections.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer class="foot">
|
||||
<div class="wrap">
|
||||
<span class="word">Link<b>Spin</b></span>
|
||||
<a href="/">Home</a>
|
||||
<a href="/contract">The contract</a>
|
||||
<a href="/ledger">Live ledger</a>
|
||||
<a href="/blog">Blog</a>
|
||||
<a href="/terms">Terms</a>
|
||||
<a href="/privacy">Privacy</a>
|
||||
<span class="grow"></span>
|
||||
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="/assets/publishers.js?v=20261010a"></script>
|
||||
</body>
|
||||
</html>
|
||||
+27
-2
@@ -14,7 +14,12 @@
|
||||
.kv{display:grid;grid-template-columns:minmax(0,1fr) 60px 70px;gap:8px;font-size:12px;align-items:center}
|
||||
.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:#fff}
|
||||
.top .hd,.top .rw{grid-template-columns:minmax(0,1fr) 80px 80px 80px}
|
||||
@media (max-width:900px){.two,.grid2{grid-template-columns:1fr}.body{padding:12px 16px}}
|
||||
.sect{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
|
||||
.ph{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px}.legend{display:flex;gap:14px;font-size:11px;color:var(--ink-2)}.legend i{display:inline-block;width:10px;height:10px;vertical-align:middle;margin-right:5px}
|
||||
.bars.stack i{position:relative}.bars.stack i b{position:absolute;left:0;right:0;bottom:0;display:block;background:var(--line);border-radius:2px 2px 0 0}.bars i.ghost{background:var(--line)}
|
||||
.mini{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-top:10px}.mini .m{background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:8px 10px;display:grid;gap:2px}.mini .m .k{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.mini .m .v{font-family:var(--display);font-weight:700;font-size:20px;color:var(--ink);font-variant-numeric:tabular-nums}
|
||||
.pages .hd,.pages .rw,.zones .hd,.zones .rw{grid-template-columns:minmax(0,1fr) 60px 60px 60px 60px;gap:8px}
|
||||
@media (max-width:900px){.two,.grid2,.sect{grid-template-columns:1fr}.body{padding:12px 16px}.mini{grid-template-columns:repeat(2,minmax(0,1fr))}.pages .hd,.pages .rw,.zones .hd,.zones .rw{grid-template-columns:minmax(0,1fr) 48px 48px 48px 48px;gap:6px;padding:10px 12px;font-size:12px}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -36,9 +41,29 @@
|
||||
<div class="panel"><h2>Conversions</h2><div class="kv" id="convRows"></div><div class="muted">Joins, wallets and purchases matched to a click on one of your links, plus anything a partner reported by postback.</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Pages: views, uniques, clicks through and leads on the member's bridge / review / squeeze pages (2026-10-10) -->
|
||||
<div class="sec">Pages</div>
|
||||
<div class="two sect">
|
||||
<div class="panel">
|
||||
<div class="ph"><h2>Page views by day</h2><div class="legend"><span><i style="background:var(--accent)"></i>views</span><span><i style="background:var(--sig)"></i>leads</span></div></div>
|
||||
<div class="bars" id="pgBars" style="height:150px"></div><div class="axis" id="pgAxis"></div>
|
||||
<div class="mini" id="pgTiles"></div>
|
||||
</div>
|
||||
<div class="panel"><h2>By page</h2><div class="tbl pages"><div class="hd"><span>Page</span><span class="r">Views</span><span class="r">Unique</span><span class="r">Clicks</span><span class="r">Leads</span></div><div id="pgRows"></div></div><div class="muted" style="margin-top:8px">Views exclude bots. Clicks are people who pressed the button on the page. Leads came in through the page's own form. <a href="/pages">Open Pages</a></div></div>
|
||||
</div>
|
||||
<!-- Zones: ad-slot impressions on the member's own sites and the credits they earned (2026-10-10) -->
|
||||
<div class="sec">Zones</div>
|
||||
<div class="two sect">
|
||||
<div class="panel">
|
||||
<div class="ph"><h2>Zone views by day</h2><div class="legend"><span><i style="background:var(--accent)"></i>viewable</span><span><i style="background:var(--line)"></i>not seen</span></div></div>
|
||||
<div class="bars" id="znBars" style="height:150px"></div><div class="axis" id="znAxis"></div>
|
||||
<div class="mini" id="znTiles"></div>
|
||||
</div>
|
||||
<div class="panel"><h2>By zone</h2><div class="tbl zones"><div class="hd"><span>Zone</span><span class="r">Views</span><span class="r">Viewable</span><span class="r">Clicks</span><span class="r">Credits</span></div><div id="znRows"></div></div><div class="muted" style="margin-top:8px">A view counts when the tag loads; viewable means at least half the banner was on screen for a second. Credits are the zone's all-time earnings. <a href="/zones">Open Zones</a></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261008c"></script>
|
||||
<script src="/assets/reports.js?v=20260929c"></script>
|
||||
<script src="/assets/reports.js?v=20261010a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+11
-1
@@ -15,11 +15,21 @@
|
||||
.zl .rw>*{min-width:0}.zl .rw .pill,.zl .rw .tag{white-space:normal;line-height:1.3}.zl .rw .acts{display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap}
|
||||
.q{display:inline-flex;gap:2px;vertical-align:middle;margin-right:6px} .q i{display:block;width:4px;height:10px;background:var(--line)} .q i.on{background:currentColor}
|
||||
@media (max-width:900px){.two{grid-template-columns:1fr}.zl .hd{display:none}.zl .rw{grid-template-columns:1fr 1fr}.body{padding:12px 16px}}
|
||||
.fr{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,2fr);gap:18px;align-items:start}
|
||||
.fr-steps{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
|
||||
.fr-steps li{border:1px solid var(--line);border-radius:8px;padding:12px;display:grid;gap:4px;font-size:13px}
|
||||
.fr-steps li b{display:flex;align-items:center;gap:8px}
|
||||
.fr-steps li b i{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:50%;border:1.5px solid var(--line-strong);font:700 11px var(--mono);font-style:normal;flex:none}
|
||||
.fr-steps li.now{border-color:var(--sig);background:var(--sig-soft)} .fr-steps li.now b i{background:var(--sig);border-color:var(--sig);color:#fff}
|
||||
.fr-steps li.done{opacity:.75} .fr-steps li.done b i{background:var(--ok);border-color:var(--ok);color:#fff}
|
||||
@media (max-width:1100px){.fr{grid-template-columns:1fr}.fr-steps{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
||||
@media (max-width:640px){.fr-steps{grid-template-columns:1fr}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="body">
|
||||
<div class="panel" id="firstRun" hidden><div class="fr"><div><h2 id="frTitle">Add your site</h2><div class="ink2" id="frIntro">Four steps and your site is carrying the network. Paid ads serve only on the site you name, and every viewable impression pays you ad credits.</div><div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:12px"><button class="btn pri sm" type="button" id="frGo">Add your site</button><button class="btn sm ghost" type="button" id="frHide">Hide this</button><a class="btn sm ghost" href="/publishers" target="_blank" rel="noopener">How the program works</a></div></div><ol class="fr-steps" id="frSteps"></ol></div></div>
|
||||
<div class="tiles" id="tiles"></div>
|
||||
<div class="two">
|
||||
<div class="tbl zl"><div class="hd"><span>Zone</span><span>Size</span><span class="r">Views</span><span class="r">Viewable</span><span class="r">Credits</span><span>Quality</span><span></span></div><div id="rows"></div><div class="ft" id="foot"></div></div>
|
||||
@@ -32,6 +42,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261008c"></script>
|
||||
<script src="/assets/zones-screen.js?v=20261008b"></script>
|
||||
<script src="/assets/zones-screen.js?v=20261010a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+88
-11
@@ -2,7 +2,10 @@
|
||||
// code and a list of destinations with weights. /r/<code> picks one by weight, records the hit
|
||||
// (day, country, source, device, a daily-salted visitor hash so uniques are honest, bot filter)
|
||||
// and redirects in one hop. Destinations can be paused; a fallback catches the empty case.
|
||||
// Health checks (a dead or parked destination is paused automatically) come in a later pass.
|
||||
// Health checks (a dead or parked destination is paused automatically) live in health.js (2026-10-10).
|
||||
// Dayparting (2026-10-10): rotation.hours / destination.hours = null (always on) or 7 strings of 24 chars
|
||||
// '1'/'0', index 0 = Sunday like JS getDay(); rotation.tz = IANA zone name or 'visitor' (the visitor's
|
||||
// country picks a representative zone). Zones are stored by NAME, never as an offset.
|
||||
// JSON store on the volume for the test area; the MySQL twin follows the engine's dual-mode pattern.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@@ -22,16 +25,79 @@ const newCode = () => { const a = 'abcdefghjkmnpqrstuvwxyz23456789'; let s = '';
|
||||
const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i;
|
||||
const cleanUrl = u => { let s = String(u || '').trim(); if (s && !/^[a-z][a-z0-9+.-]*:\/\//i.test(s) && /^[^\s\/]+\.[^\s]+/.test(s)) s = 'https://' + s; return /^https?:\/\/[^\s]+$/i.test(s) && s.length <= 500 ? s : null; };
|
||||
|
||||
// ── dayparting ──────────────────────────────────────────────────────────────────────────────────────────────
|
||||
// representative zone per country for tz = 'visitor' (top ~60 by traffic); unknown or no country -> Central
|
||||
const COUNTRY_TZ = { US: 'America/Chicago', CA: 'America/Toronto', MX: 'America/Mexico_City', BR: 'America/Sao_Paulo', AR: 'America/Argentina/Buenos_Aires', CL: 'America/Santiago', CO: 'America/Bogota', PE: 'America/Lima', VE: 'America/Caracas',
|
||||
GB: 'Europe/London', IE: 'Europe/Dublin', PT: 'Europe/Lisbon', ES: 'Europe/Madrid', FR: 'Europe/Paris', DE: 'Europe/Berlin', NL: 'Europe/Amsterdam', BE: 'Europe/Brussels', CH: 'Europe/Zurich', AT: 'Europe/Vienna', IT: 'Europe/Rome', PL: 'Europe/Warsaw', CZ: 'Europe/Prague', HU: 'Europe/Budapest', SE: 'Europe/Stockholm', NO: 'Europe/Oslo', DK: 'Europe/Copenhagen', FI: 'Europe/Helsinki', GR: 'Europe/Athens', RO: 'Europe/Bucharest', BG: 'Europe/Sofia', UA: 'Europe/Kyiv', RU: 'Europe/Moscow', TR: 'Europe/Istanbul', RS: 'Europe/Belgrade', HR: 'Europe/Zagreb', SK: 'Europe/Bratislava', LT: 'Europe/Vilnius', LV: 'Europe/Riga', EE: 'Europe/Tallinn',
|
||||
ZA: 'Africa/Johannesburg', NG: 'Africa/Lagos', KE: 'Africa/Nairobi', EG: 'Africa/Cairo', MA: 'Africa/Casablanca', GH: 'Africa/Accra',
|
||||
IN: 'Asia/Kolkata', PK: 'Asia/Karachi', BD: 'Asia/Dhaka', LK: 'Asia/Colombo', NP: 'Asia/Kathmandu', PH: 'Asia/Manila', ID: 'Asia/Jakarta', MY: 'Asia/Kuala_Lumpur', SG: 'Asia/Singapore', TH: 'Asia/Bangkok', VN: 'Asia/Ho_Chi_Minh', HK: 'Asia/Hong_Kong', TW: 'Asia/Taipei', CN: 'Asia/Shanghai', JP: 'Asia/Tokyo', KR: 'Asia/Seoul', AE: 'Asia/Dubai', SA: 'Asia/Riyadh', IL: 'Asia/Jerusalem', IR: 'Asia/Tehran', KZ: 'Asia/Almaty',
|
||||
AU: 'Australia/Sydney', NZ: 'Pacific/Auckland' };
|
||||
const DEFAULT_TZ = 'America/Chicago';
|
||||
const WD = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 };
|
||||
const row = (from, to) => { let s = ''; for (let h = 0; h < 24; h++) s += h >= from && h < to ? '1' : '0'; return s; };
|
||||
const ALL = row(0, 24), NONE = row(0, 0);
|
||||
const PRESETS = { always: null, business: [NONE, row(8, 18), row(8, 18), row(8, 18), row(8, 18), row(8, 18), NONE], evenings: new Array(7).fill(row(17, 23)), weekends: [ALL, NONE, NONE, NONE, NONE, NONE, ALL] };
|
||||
// validate a grid from the API: null/'' = always; a preset name; 7 strings of 24 x '1'/'0'; or 7 arrays of 24 booleans
|
||||
function cleanHours(h) {
|
||||
if (h == null || h === '' || h === 'always') return { hours: null };
|
||||
if (typeof h === 'string' && PRESETS[h] !== undefined) return { hours: PRESETS[h] ? PRESETS[h].slice() : null };
|
||||
if (!Array.isArray(h) || h.length !== 7) return { error: 'Hours must be a 7 by 24 grid.' };
|
||||
const out = [];
|
||||
for (const d of h) {
|
||||
let s = Array.isArray(d) ? d.map(x => x && x !== '0' ? '1' : '0').join('') : String(d || '');
|
||||
if (!/^[01]{24}$/.test(s)) return { error: 'Hours must be a 7 by 24 grid.' };
|
||||
out.push(s);
|
||||
}
|
||||
if (out.every(s => s === ALL)) return { hours: null };
|
||||
if (out.every(s => s === NONE)) return { error: 'Pick at least one hour, or choose Always on.' };
|
||||
return { hours: out };
|
||||
}
|
||||
// validate a zone name: 'visitor' or anything Intl knows; stored canonical, never an offset
|
||||
function cleanTz(tz) {
|
||||
const s = String(tz || '').trim(); if (!s || s === 'visitor') return { tz: 'visitor' };
|
||||
if (s.length > 64 || !/^[A-Za-z0-9_+\-\/]+$/.test(s)) return { error: 'That time zone name is not one we know.' };
|
||||
try { return { tz: new Intl.DateTimeFormat('en', { timeZone: s }).resolvedOptions().timeZone }; } catch (e) { return { error: 'That time zone name is not one we know. Use a name like America/New_York.' }; }
|
||||
}
|
||||
const zoneFor = (r, country) => (r.tz && r.tz !== 'visitor') ? r.tz : (COUNTRY_TZ[String(country || '').toUpperCase()] || DEFAULT_TZ);
|
||||
// the weekday + hour right now (or at ts) in a zone -> { wd, h }
|
||||
function cellAt(tz, ts) {
|
||||
try {
|
||||
const parts = new Intl.DateTimeFormat('en-US', { timeZone: tz, hour: 'numeric', hour12: false, hourCycle: 'h23', weekday: 'short' }).formatToParts(new Date(ts || Date.now()));
|
||||
let wd = 1, h = 0; for (const p of parts) { if (p.type === 'weekday') wd = WD[p.value] ?? 1; if (p.type === 'hour') h = Number(p.value) % 24; }
|
||||
return { wd, h };
|
||||
} catch (e) { return cellAt(DEFAULT_TZ, ts); }
|
||||
}
|
||||
const isOn = (hours, cell) => !hours || hours[cell.wd][cell.h] === '1';
|
||||
|
||||
function pub(r) {
|
||||
const hits = J.db.hits.filter(h => h.r === r.id);
|
||||
const since7 = Date.now() - 7 * DAY;
|
||||
const perDest = {};
|
||||
for (const h of hits) { const d = perDest[h.d] = perDest[h.d] || { hits: 0, hits7: 0, uniques: new Set() }; d.hits++; if (h.ts >= since7) d.hits7++; d.uniques.add(h.v); }
|
||||
const conv = J.db.conv.filter(c => c.r === r.id); const convBy = {}; for (const c of conv) convBy[c.ev] = (convBy[c.ev] || 0) + 1;
|
||||
const since30 = Date.now() - 30 * DAY;
|
||||
return { id: r.id, code: r.code, name: r.name, owner: r.owner, created: r.created, fallback: r.fallback || '', paused: !!r.paused, conversions: conv.length, convBy,
|
||||
destinations: r.destinations.map(d => Object.assign({}, d, { hits: (perDest[d.id] || { hits: 0 }).hits, hits7: (perDest[d.id] || { hits7: 0 }).hits7, uniques: (perDest[d.id] || { uniques: new Set() }).uniques.size })),
|
||||
hours: r.hours || null, tz: r.tz || 'visitor', offHours30: hits.filter(h => h.oh && h.ts >= since30 && !h.bot).length, fallbackHealth: r.fallbackHealth || null,
|
||||
destinations: r.destinations.map(d => Object.assign({ hours: null, health: null, autoPaused: 0 }, d, { hits: (perDest[d.id] || { hits: 0 }).hits, hits7: (perDest[d.id] || { hits7: 0 }).hits7, uniques: (perDest[d.id] || { uniques: new Set() }).uniques.size })),
|
||||
hits: hits.length, hits7: hits.filter(h => h.ts >= since7).length, uniques: new Set(hits.map(h => h.v)).size, bots: hits.filter(h => h.bot).length };
|
||||
}
|
||||
// "my best hours": the rotation's own non-bot hits over 30 days, bucketed by weekday + hour in the rotation's zone
|
||||
// (per visitor country when tz = visitor). Top 25% of cells by uniques. Unlocks at 200 hits.
|
||||
const BEST_MIN = 200;
|
||||
function bestHours(r) {
|
||||
const since = Date.now() - 30 * DAY;
|
||||
const hits = J.db.hits.filter(h => h.r === r.id && !h.bot && h.ts >= since);
|
||||
const cells = []; for (let i = 0; i < 7; i++) cells.push(new Array(24).fill(0).map(() => new Set()));
|
||||
for (const h of hits) { const c = cellAt(zoneFor(r, h.c), h.ts); cells[c.wd][c.h].add(h.v); }
|
||||
const counts = cells.map(d => d.map(s => s.size));
|
||||
const flat = []; counts.forEach((d, wd) => d.forEach((n, h) => { if (n > 0) flat.push({ wd, h, n }); }));
|
||||
flat.sort((a, b) => b.n - a.n);
|
||||
const keep = flat.slice(0, Math.max(1, Math.ceil(flat.length * 0.25)));
|
||||
const grid = new Array(7).fill(NONE).map(s => s.split(''));
|
||||
for (const c of keep) grid[c.wd][c.h] = '1';
|
||||
const ready = hits.length >= BEST_MIN && keep.length > 0;
|
||||
return { hits: hits.length, need: BEST_MIN, ready, hours: ready ? grid.map(d => d.join('')) : null, cells: counts };
|
||||
}
|
||||
async function list(owner) { return J.db.rotations.filter(r => r.owner === norm(owner)).map(pub); }
|
||||
async function get(owner, id) { const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); return r ? pub(r) : null; }
|
||||
async function create(owner, body) {
|
||||
@@ -46,6 +112,8 @@ async function update(owner, id, body) {
|
||||
if (body.name != null) { const n = String(body.name).trim().slice(0, 80); if (n) r.name = n; }
|
||||
if (body.fallback != null) r.fallback = cleanUrl(body.fallback) || '';
|
||||
if (body.paused != null) r.paused = !!body.paused;
|
||||
if (body.hours !== undefined) { const h = cleanHours(body.hours); if (h.error) return h; if (h.hours) r.hours = h.hours; else delete r.hours; }
|
||||
if (body.tz !== undefined) { const t = cleanTz(body.tz); if (t.error) return t; if (t.tz === 'visitor') delete r.tz; else r.tz = t.tz; }
|
||||
J.save(); return { ok: true, rotation: pub(r) };
|
||||
}
|
||||
async function remove(owner, id) { const n = J.db.rotations.length; J.db.rotations = J.db.rotations.filter(r => !(r.id === Number(id) && r.owner === norm(owner))); J.save(); return n !== J.db.rotations.length ? { ok: true } : { error: 'No such rotation.' }; }
|
||||
@@ -63,13 +131,14 @@ async function updateDest(owner, id, did, body) {
|
||||
if (body.url != null) { const u = cleanUrl(body.url); if (!u) return { error: 'Destination must be a full https:// address.' }; d.url = u; }
|
||||
if (body.label != null) d.label = String(body.label).trim().slice(0, 60);
|
||||
if (body.weight != null) d.weight = Math.max(1, Math.min(100, Math.round(Number(body.weight) || 1)));
|
||||
if (body.active != null) d.active = !!body.active;
|
||||
if (body.active != null) { d.active = !!body.active; delete d.autoPaused; if (d.health) { d.health.fails = 0; d.health.passes = 0; } } // the owner's own choice: never auto-resumed, counters start over
|
||||
if (body.hours !== undefined) { const h = cleanHours(body.hours); if (h.error) return h; if (h.hours) d.hours = h.hours; else delete d.hours; }
|
||||
if (body.remove) r.destinations = r.destinations.filter(x => x.id !== d.id);
|
||||
J.save(); return { ok: true, rotation: pub(r) };
|
||||
}
|
||||
// pick by weight among active destinations
|
||||
function pick(r) {
|
||||
const live = r.destinations.filter(d => d.active);
|
||||
// pick by weight among active destinations that are inside their own hours right now
|
||||
function pick(r, cell) {
|
||||
const live = r.destinations.filter(d => d.active && (!cell || isOn(d.hours, cell)));
|
||||
if (!live.length) return null;
|
||||
const total = live.reduce((n, d) => n + d.weight, 0); let x = crypto.randomInt(total);
|
||||
for (const d of live) { x -= d.weight; if (x < 0) return d; }
|
||||
@@ -79,18 +148,21 @@ function pick(r) {
|
||||
async function resolve(code, req) {
|
||||
const r = J.db.rotations.find(r => r.code === norm(code)); if (!r) return null;
|
||||
const ua = String(req.headers['user-agent'] || ''); const bot = BOT.test(ua) || !ua;
|
||||
const d = r.paused ? null : pick(r);
|
||||
const url = d ? d.url : (r.fallback || null);
|
||||
const ip = String(req.headers['x-forwarded-for'] || req.socket.remoteAddress || '').split(',')[0].trim();
|
||||
const day = new Date().toISOString().slice(0, 10);
|
||||
const v = crypto.createHash('sha256').update(day + '|' + ip + '|' + ua).digest('hex').slice(0, 16); // daily-salted visitor hash, no IP stored
|
||||
let country = ''; try { country = geo && geo.countryOf ? (geo.countryOf(ip) || '') : ''; } catch (e) {}
|
||||
// dayparting: the rotation's own hours gate everything (off hours -> fallback); each destination's hours gate the pick
|
||||
const cell = cellAt(zoneFor(r, country));
|
||||
const off = !r.paused && !isOn(r.hours, cell);
|
||||
const d = (r.paused || off) ? null : pick(r, cell);
|
||||
const url = d ? d.url : (r.fallback || null);
|
||||
const ref = String(req.headers.referer || ''); let src = 'direct'; try { if (ref) src = new URL(ref).hostname.replace(/^www\./, ''); } catch (e) {}
|
||||
const device = /mobile|android|iphone|ipad/i.test(ua) ? 'mobile' : 'desktop';
|
||||
// click ids and sub ids that rode in on the link (tracker / traffic-network params), kept per click
|
||||
const q = {}; try { const sp = new URL(req.url, 'http://x').searchParams; let n = 0; for (const [k, val] of sp) { const key = String(k).toLowerCase(); if (n >= 20) break; if (/^(clickid|click_id|cid|subid|sub_id|s[1-5]|sub[1-5]|t[1-5]|aff_sub[1-5]?|utm_(source|medium|campaign|term|content)|src|source|campaign|zone|placement)$/.test(key)) { q[key] = String(val).slice(0, 200); n++; } } } catch (e) {}
|
||||
const id = crypto.randomBytes(6).toString('hex').slice(0, 10);
|
||||
J.db.hits.push({ id, r: r.id, d: d ? d.id : 0, ts: Date.now(), v, c: country, s: src, dv: device, bot: bot ? 1 : 0, q: Object.keys(q).length ? q : undefined });
|
||||
J.db.hits.push({ id, r: r.id, d: d ? d.id : 0, ts: Date.now(), v, c: country, s: src, dv: device, bot: bot ? 1 : 0, oh: off ? 1 : undefined, q: Object.keys(q).length ? q : undefined });
|
||||
if (J.db.hits.length > 200000) J.db.hits = J.db.hits.slice(-150000);
|
||||
J.save();
|
||||
let out = url;
|
||||
@@ -133,7 +205,7 @@ async function stats(owner, id) {
|
||||
const hours = new Array(24).fill(0); for (const h of hits) hours[new Date(h.ts).getUTCHours()]++;
|
||||
const subs = {}; for (const h of hits) if (h.q) for (const [k, v] of Object.entries(h.q)) { const key = k + '=' + v; subs[key] = (subs[key] || 0) + 1; }
|
||||
const conv = J.db.conv.filter(c => c.r === r.id); const convBy = {}; for (const c of conv) { const k = c.ev + (c.label ? ' · ' + c.label : ''); convBy[k] = (convBy[k] || 0) + 1; }
|
||||
return { rotation: pub(r), country: by('c'), source: by('s'), device: by('dv'), days: Object.entries(days).sort().slice(-30).map(([k, n]) => ({ day: k, n })), hours, bots: J.db.hits.filter(h => h.r === r.id && h.bot).length,
|
||||
return { rotation: pub(r), country: by('c'), source: by('s'), device: by('dv'), days: Object.entries(days).sort().slice(-30).map(([k, n]) => ({ day: k, n })), hours, bots: J.db.hits.filter(h => h.r === r.id && h.bot).length, best: bestHours(r), offHours: hits.filter(h => h.oh).length,
|
||||
subs: Object.entries(subs).sort((a, b) => b[1] - a[1]).slice(0, 12).map(([k, n]) => ({ k, n })), conversions: Object.entries(convBy).sort((a, b) => b[1] - a[1]).map(([k, n]) => ({ k, n })) };
|
||||
}
|
||||
function totals() { return { rotations: J.db.rotations.length, hits: J.db.hits.length }; }
|
||||
@@ -172,4 +244,9 @@ function servedToday() {
|
||||
const startCt = new Date(ct.getFullYear(), ct.getMonth(), ct.getDate()).getTime(); const start = now.getTime() - (ct.getTime() - startCt);
|
||||
return J.db.hits.filter(h => h.ts >= start && !h.bot).length;
|
||||
}
|
||||
module.exports = { init, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday };
|
||||
// raw access for health.js (same store, same save)
|
||||
const rawRotations = () => J.db.rotations;
|
||||
const save = () => J.save();
|
||||
const findMine = (owner, id) => J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)) || null;
|
||||
module.exports = { init, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday,
|
||||
pub, rawRotations, save, findMine, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ };
|
||||
|
||||
@@ -39,8 +39,11 @@ const toolkit = require('./toolkit');
|
||||
const registry = require('./registry'); // network registry: who is who across properties (LinkSpin, 2026-09-15)
|
||||
const carry = require('./carry'); // sponsor carry-over: engine activation, claim window, notices
|
||||
const rotator = require('./rotator');
|
||||
const health = require('./health'); // destination health checks + auto-pause (2026-10-10)
|
||||
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29)
|
||||
const pages = require('./pages'); // member pages: bridge / review / squeeze, served at /p/<slug> (2026-09-29)
|
||||
const domains = require('./domains'); // link-domain pool by channel + six-hourly safety checks; burned domains leave the pool (2026-10-10)
|
||||
const zonereport = require('./zonereport'); // read-only zone numbers for member Reports (2026-10-10)
|
||||
const zones = require('./zones'); // ad zones on members' own sites (2026-09-29)
|
||||
const nas = require('./nas');
|
||||
const audiences = require('./audiences'); // first-party retargeting (2026-10-08) // only asked whether syndication is on (the status strip)
|
||||
@@ -48,7 +51,7 @@ const MEMBER_AD_TYPES = ['banner', 'text', 'login']; // the formats LinkSpin mem
|
||||
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
|
||||
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
||||
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
||||
const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/blog', '/whats-new', '/leaderboard']);
|
||||
const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/publishers', '/earning', '/blog', '/whats-new', '/leaderboard']);
|
||||
let tankWaitCache = null; // dashboard: who is waiting for a sponsor (refreshed every minute)
|
||||
const geo = require('./geo'); // viewer country -> tier (DB-IP lite), for campaign targeting
|
||||
const burner = require('./burner'); // automatic on-chain credit burns (inert without ENGINE_KEY)
|
||||
@@ -413,11 +416,19 @@ async function boot() {
|
||||
carry.init({ dataDir: DATA_DIR, accounts, registry, chain, mailer, messages, siteConfig, adminEmail: ADMIN_EMAIL, host: SITE_HOST });
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []);
|
||||
rotator.init({ dataDir: DATA_DIR, geo, ownHosts });
|
||||
// destination health: every 30 min, first pass 2 min after boot; a pause lands in the owner's on-site inbox (same path as the payment notices)
|
||||
health.init({ rotator, dataDir: DATA_DIR, notify: (email, subject, html) => messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [email], subject, html) });
|
||||
setTimeout(() => health.tick().catch(e => console.error('health', e.message)), 2 * 60 * 1000);
|
||||
setInterval(() => health.tick().catch(e => console.error('health', e.message)), 30 * 60 * 1000);
|
||||
setInterval(() => { try { rotator.sweepDemos(); } catch (e) {} }, 60 * 60 * 1000); // unclaimed home-page demo spins expire after 24 h
|
||||
postbacks.init({ dataDir: DATA_DIR, ownHosts, rotator });
|
||||
zones.init({ dataDir: DATA_DIR, ads, siteHost: SITE_HOST });
|
||||
pages.init({ dataDir: DATA_DIR, ownHosts, openrouterKey: () => { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; } } });
|
||||
pages.init({ dataDir: DATA_DIR, ownHosts, imageBase: () => (IS_PROD ? 'https' : 'http') + '://' + SITE_HOST, openrouterKey: () => { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; } } });
|
||||
audiences.init({ dataDir: DATA_DIR });
|
||||
// link-domain pool: channels live in site.json (linkDomainChannels), check state in domains.json; a burn alerts the admin once
|
||||
domains.init({ dataDir: DATA_DIR, siteConfig, saveSite: patch => fs.writeFileSync(SITE_FILE, JSON.stringify(Object.assign(siteConfig(), patch), null, 2)),
|
||||
notify: async text => { const sc = siteConfig(); if (sc.telegramBotToken && sc.telegramAdminChatId) await telegramSend(sc.telegramAdminChatId, text); else if (ADMIN_EMAIL && mailer.hasKey()) await mailer.send(ADMIN_EMAIL, 'LinkSpin: link domain burned', text.replace(/<[^>]+>/g, '')); } });
|
||||
zonereport.init({ dataDir: DATA_DIR });
|
||||
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, send: async (c, t, th) => { await telegramSend(c, t, th); return true; } });
|
||||
setInterval(() => snapshot.tick().catch(e => console.error('snapshot', e.message)), 10 * 60 * 1000);
|
||||
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, site: SITE_URL });
|
||||
@@ -902,7 +913,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const u = new URL(req.url, 'http://x');
|
||||
const p = u.pathname;
|
||||
// zone endpoints run on other people's sites and show only ad creatives, so they pass the curtain
|
||||
const zonePath = p === '/z.js' || p === '/z/nas' || p === '/p.js' || p === '/p.gif' || p.startsWith('/api/zone/') || p.startsWith('/banners/linkspin-') || p.startsWith('/art/house-');
|
||||
const zonePath = p === '/z.js' || p === '/z/nas' || p === '/p.js' || p === '/p.gif' || p.startsWith('/u/pages/') || p.startsWith('/api/zone/') || p.startsWith('/banners/linkspin-') || p.startsWith('/art/house-');
|
||||
if (!zonePath && curtained(req, res, u)) return; // nothing below this line runs for an uninvited visitor
|
||||
|
||||
// -- the rotator redirect: one hop, recorded, on any host (LinkSpin)
|
||||
@@ -936,6 +947,10 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (p === '/api/zone/seen' && (req.method === 'GET' || req.method === 'POST')) { await zones.seen(u.searchParams.get('i'), req); res.writeHead(204, corsCreds(req)); return res.end(); }
|
||||
{ const zm = /^\/api\/zone\/click\/([a-f0-9]{12})$/.exec(p); if (zm && req.method === 'GET') { const target = await zones.click(zm[1]); res.writeHead(302, { Location: target || '/', 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer-when-downgrade' }); return res.end(); } }
|
||||
// -- publisher program (2026-10-10): the public offer for site owners who carry zones, and its live "Network right now"
|
||||
// strip (7-day totals from zones.js, cached a minute). App host only; the link and pages domains stay single-purpose.
|
||||
if (p === '/api/public/publishers' && req.method === 'GET') return json(res, 200, zones.publisherPublic(), { 'Cache-Control': 'public, max-age=60' });
|
||||
if (p === '/publishers' && (req.method === 'GET' || req.method === 'HEAD') && !isPagesHost(req) && !isLinkHost(req)) return sendFile(res, path.join(PUBLIC_DIR, 'publishers.html'));
|
||||
{ const wm = /^\/welcome\/([a-f0-9]{48})$/.exec(p); if (wm && (req.method === 'GET' || req.method === 'POST')) { // one-time tester sign-in link
|
||||
const t = inviteTokens.get(wm[1]);
|
||||
if (!t || t.exp < Date.now()) { inviteTokens.delete(wm[1]); res.writeHead(410, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end('<!doctype html><meta charset="utf-8"><title>Link used</title><p style="font:15px system-ui;padding:24px">That sign-in link was already used or has expired. Ask for a fresh one.</p>'); }
|
||||
@@ -1944,6 +1959,11 @@ const server = http.createServer(async (req, res) => {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const r = await rotator.stats(s.email, m[1]); return r ? json(res, 200, r, { 'Cache-Control': 'no-store' }) : json(res, 404, { error: 'No such rotation.' });
|
||||
}
|
||||
m = /^\/api\/my\/rotations\/(\d+)\/health$/.exec(p); // "Check now": fresh health states for every destination (once a minute per rotation)
|
||||
if (m && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const r = await health.checkRotation(s.email, m[1]); return json(res, r.error ? (/No such/.test(r.error) ? 404 : 429) : 200, r, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/strip' && req.method === 'GET') { // status strip under every Control Room screen
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
let served = 0; try { served = (await rotator.summary(s.email, 1)).totals.served; } catch (e) {}
|
||||
@@ -1952,7 +1972,7 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (p === '/api/my/zones' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
return json(res, 200, { zones: await zones.list(s.email), host: SITE_HOST, sizes: Object.keys(zones.SIZES), rates: zones.settings() }, { 'Cache-Control': 'no-store' });
|
||||
return json(res, 200, { zones: await zones.list(s.email), host: SITE_HOST, sizes: Object.keys(zones.SIZES), networkSizes: Array.from(zones.NAS_SIZES), tiers: zones.TIERS, rates: zones.settings(), warmup: zones.WARMUP, holdRatio: zones.HOLD_RATIO }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/zones' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
@@ -1976,18 +1996,56 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (p === '/api/admin/zones' && req.method === 'GET') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
return json(res, 200, { zones: await zones.adminList(), totals: zones.totals(), rates: zones.settings(), warmup: zones.WARMUP, holdRatio: zones.HOLD_RATIO }, { 'Cache-Control': 'no-store' });
|
||||
return json(res, 200, { zones: await zones.adminList(), totals: zones.totals(), publishers: zones.publisherTotals(7), rates: zones.settings(), tiers: zones.TIERS, warmup: zones.WARMUP, holdRatio: zones.HOLD_RATIO }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
m = /^\/api\/admin\/zones\/(ls-[a-f0-9]{6})$/.exec(p);
|
||||
// admin: pause/resume, note, and the publisher tier ({ tier: 'standard' | 'verified' }; /tier is an alias for the same update)
|
||||
m = /^\/api\/admin\/zones\/(ls-[a-f0-9]{6})(\/tier)?$/.exec(p);
|
||||
if (m && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
const r = await zones.adminSet(m[1], await readBody(req)); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
// -- hosted page images: /u/pages/<owner-hash>/<id>.<ext>, only files the pages index knows, a year of cache (2026-10-10)
|
||||
m = /^\/u\/pages\/([a-f0-9]{16})\/([a-f0-9]{12})\.(png|jpg|webp)$/.exec(p);
|
||||
if (m && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||
const f = pages.imageFile(m[1], m[2], m[3]); if (!f) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); }
|
||||
return fs.readFile(f.file, (err, data) => { if (err) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); } res.writeHead(200, { 'Content-Type': f.mime, 'Content-Length': String(data.length), 'Cache-Control': 'public, max-age=31536000, immutable', 'X-Content-Type-Options': 'nosniff', 'Content-Disposition': 'inline', 'Access-Control-Allow-Origin': '*' }); res.end(req.method === 'HEAD' ? '' : data); });
|
||||
}
|
||||
// -- the link-domain pool for the member Links screen: live (not burned, not reserve) hosts with their channel
|
||||
if (p === '/api/my/link-hosts' && (req.method === 'GET' || req.method === 'POST')) { // the shell's api() helper posts (2026-10-10)
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const hs = domains.hosts(); return json(res, 200, { hosts: hs.length ? hs : [{ host: SITE_HOST, channel: 'email', label: 'Email', note: 'The app host (no link domains are live)' }], channels: domains.CHANNELS }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/pages' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const hosts = String(siteConfig().linkDomains || '').split(',').map(x => x.trim()).filter(x => x && !x.startsWith('www.'));
|
||||
const hosts = domains.live(); // burned or reserve domains are never handed out for new pages
|
||||
const ph = pagesHost(); const pageBase = ph ? 'https://' + ph + '/' : 'https://' + (hosts[0] || SITE_HOST) + '/p/';
|
||||
return json(res, 200, { pages: await pages.list(s.email), hosts: ph ? [ph] : (hosts.length ? hosts : [SITE_HOST]), pageBase, types: pages.TYPES, styles: require('./pagestyle').catalog() }, { 'Cache-Control': 'no-store' });
|
||||
return json(res, 200, { pages: await pages.list(s.email), hosts: ph ? [ph] : (hosts.length ? hosts : [SITE_HOST]), pageBase, types: pages.TYPES, styles: require('./pagestyle').catalog(), providers: pages.providers(), images: await pages.images(s.email), imageMax: pages.IMG_MAX, imageBytes: pages.IMG_BYTES }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/pages/upload' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const up = await pages.readUpload(req); if (up.error) return json(res, 400, up);
|
||||
const r = await pages.uploadImage(s.email, up.buf, up.ct); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
m = /^\/api\/my\/pages\/images\/([a-f0-9]{12})$/.exec(p);
|
||||
if (m && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const b = await readBody(req); if (!b.remove) return json(res, 400, { error: 'Nothing to do.' });
|
||||
const r = await pages.removeImage(s.email, m[1]); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
// -- admin: the link-domain pool (channel per domain, last safety check, burned flag, check now / clear / pull)
|
||||
if (p === '/api/admin/domains' && req.method === 'GET') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
return json(res, 200, { domains: domains.all(), channels: domains.CHANNELS, labels: domains.LABEL, notes: domains.NOTE, gsb: !!String(process.env.GSB_API_KEY || '').trim() }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/admin/domains' && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
const b = await readBody(req); let r;
|
||||
if (b.action === 'check') r = b.domain ? await domains.check(b.domain) : { ok: true, results: await domains.checkAll() };
|
||||
else if (b.action === 'channel') r = domains.setChannel(b.domain, b.channel);
|
||||
else if (b.action === 'clear') r = domains.clear(b.domain);
|
||||
else if (b.action === 'burn') r = domains.burn(b.domain, b.reason);
|
||||
else r = { error: 'Unknown action.' };
|
||||
return json(res, r.error ? 400 : 200, Object.assign(r, { domains: domains.all() }));
|
||||
}
|
||||
if (p === '/api/my/pages' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
@@ -2014,7 +2072,9 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/api/my/reports' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const days = Math.max(1, Math.min(365, Number(u.searchParams.get('days')) || 30));
|
||||
return json(res, 200, await rotator.summary(s.email, days), { 'Cache-Control': 'no-store' });
|
||||
// spins (the rotator summary, spread at the top level so older report screens keep working) + pages + zones (2026-10-10)
|
||||
const [spins, pg, zn] = await Promise.all([rotator.summary(s.email, days), pages.summary(s.email, days), zonereport.summary(s.email, days)]);
|
||||
return json(res, 200, Object.assign({}, spins, { spins, pages: pg, zones: zn, days: spins.days, range: days }), { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/postbacks' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
// Holding tank (Marty, 2026-09-11): free members who arrived with no sponsor wait
|
||||
// here, and a member who has bought their own $20+ package can adopt one:
|
||||
// here, and a member who has bought their own $25 or larger package can adopt one:
|
||||
// first come, at most two open adoptions at a time, an adoption falls back into
|
||||
// the tank after 7 days if the person never linked a wallet or bought, and a
|
||||
// person can be adopted twice at most before they stay wherever they are.
|
||||
@@ -16,7 +16,7 @@ const CAP_OPEN = 2; // open adoptions per adopter
|
||||
const TTL_MS = 7 * 86400000; // an adoption's window to convert
|
||||
const MAX_ADOPTIONS = 2; // per adoptee, lifetime (dropped adoptions count too, since 2026-09-13)
|
||||
const HOLD_MS = 3 * 24 * 3600 * 1000; // an adoption is a commitment: no releasing someone you picked up less than 3 days ago (Marty, 2026-09-13)
|
||||
const MIN_OWN_BUY_CENTS = 2000; // adopter must have bought a $20+ package themselves
|
||||
const MIN_OWN_BUY_CENTS = 2500; // adopter must have bought a qualifying ($25+) package themselves
|
||||
const WARN_DAYS = 10; // dormant lead: sponsor warned after this many days without contact
|
||||
const RESCUE_DAYS = 14; // ...and the lead moves to the tank after this many (warning at least 4 days old)
|
||||
|
||||
@@ -71,7 +71,7 @@ async function waiting() {
|
||||
.sort((a, b) => (b.lastSeen || b.joined) - (a.lastSeen || a.joined));
|
||||
}
|
||||
|
||||
// has this member bought a $20+ package themselves? (the qualifying-for-yourself buy)
|
||||
// has this member bought a $25 or larger package themselves? (the qualifying-for-yourself buy)
|
||||
function hasOwnBuy(memberId) {
|
||||
if (!memberId) return false;
|
||||
for (const ev of chain.recentEvents(200000)) if (ev.type === 'Purchase' && ev.buyerId === memberId && Number(ev.priceCents) >= MIN_OWN_BUY_CENTS) return true;
|
||||
@@ -80,8 +80,8 @@ function hasOwnBuy(memberId) {
|
||||
async function eligibility(email) {
|
||||
const a = await accounts.byEmail(email);
|
||||
if (!a) return { ok: false, reason: 'Sign in first.' };
|
||||
if (!a.memberId) return { ok: false, reason: 'Switch on payouts and buy your first $20 package to adopt from the tank.' };
|
||||
if (!hasOwnBuy(a.memberId)) return { ok: false, reason: 'Buy your own $20 or more package first. Adopting is for members who have made that move themselves.' };
|
||||
if (!a.memberId) return { ok: false, reason: 'Switch on payouts and buy your first $25 package to adopt from the tank.' };
|
||||
if (!hasOwnBuy(a.memberId)) return { ok: false, reason: 'Buy your own $25 or larger package first. Adopting is for members who have made that move themselves.' };
|
||||
const open = await impl().open(a.email);
|
||||
if (open.length >= CAP_OPEN) return { ok: false, reason: 'You have ' + CAP_OPEN + ' open adoptions. Help one of them link a wallet or buy, and a slot frees up.', full: true };
|
||||
return { ok: true, account: a, open };
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Zone numbers for the member Reports screen (2026-10-10). A READ-ONLY view over DATA_DIR/zones.json (the store
|
||||
// zones.js owns): views, viewable views, clicks and credits for the member's zones over the chosen days, by Central
|
||||
// day and by zone. Counting mirrors zones.statusOf / pubZone: bots excluded, `ok` = viewable, `k` = clicked.
|
||||
// Credits per zone are the lifetime meter zones.js keeps (z.credits); there is no dated credit log in the store yet.
|
||||
// Parsed on demand with a short cache so a 300k-impression file is not re-read on every click of the range picker.
|
||||
// Move this into zones.js as zones.summary(owner, days) when that file is free.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
let DATA_DIR = null; let cache = { at: 0, mtime: 0, db: null };
|
||||
const DAY = 86400000, TTL = 30 * 1000;
|
||||
function init(opts) { DATA_DIR = opts.dataDir; }
|
||||
function load() {
|
||||
const file = path.join(DATA_DIR, 'zones.json'); let mtime = 0; try { mtime = fs.statSync(file).mtimeMs; } catch (e) { return { zones: [], imps: [] }; }
|
||||
if (cache.db && cache.mtime === mtime && Date.now() - cache.at < TTL) return cache.db;
|
||||
let db; try { db = JSON.parse(fs.readFileSync(file, 'utf8')); } catch (e) { db = {}; }
|
||||
db = { zones: Array.isArray(db.zones) ? db.zones : [], imps: Array.isArray(db.imps) ? db.imps : [] };
|
||||
cache = { at: Date.now(), mtime, db }; return db;
|
||||
}
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
async function summary(owner, days) {
|
||||
const db = load(); const mine = db.zones.filter(z => z.owner === norm(owner)); const ids = new Set(mine.map(z => z.id));
|
||||
const since = Date.now() - (Number(days) || 30) * DAY;
|
||||
const imps = db.imps.filter(i => ids.has(i.z) && i.ts >= since && !i.bot);
|
||||
const dayMap = {}; for (const i of imps) { const d = dayMap[ctDay(i.ts)] = dayMap[ctDay(i.ts)] || { day: ctDay(i.ts), views: 0, viewable: 0, clicks: 0 }; d.views++; if (i.ok) d.viewable++; if (i.k) d.clicks++; }
|
||||
const byDay = Object.values(dayMap).sort((a, b) => a.day < b.day ? -1 : 1);
|
||||
const byZone = mine.map(z => { const zi = imps.filter(i => i.z === z.id); const seen = zi.filter(i => i.ok).length; return { id: z.id, name: z.name, site: z.site, size: z.size, active: !!z.active, paused: !!z.adminPaused, views: zi.length, viewable: seen, viewablePct: zi.length ? Math.round(seen / zi.length * 100) : null, clicks: zi.filter(i => i.k).length, paid: zi.filter(i => i.ok && !i.house && !i.off).length, credits: z.credits || 0 }; }).sort((a, b) => b.views - a.views);
|
||||
return { zones: mine.length, views: imps.length, viewable: imps.filter(i => i.ok).length, clicks: imps.filter(i => i.k).length, paid: imps.filter(i => i.ok && !i.house && !i.off).length, credits: mine.reduce((n, z) => n + (z.credits || 0), 0), byDay, byZone };
|
||||
}
|
||||
module.exports = { init, summary };
|
||||
@@ -17,12 +17,21 @@ const NAS_SIZES = new Set(['728x90', '468x60']); // the sizes Network Ad Space s
|
||||
const NAS_TAG = (w, h) => '<script src="https://www.networkadspace.com/showadss.php?w=' + w + '&h=' + h + '&n=1&bw=' + w + '&bh=' + h + '&c=999"></script>';
|
||||
const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i;
|
||||
const J = { db: null, FILE: () => path.join(DATA_DIR, 'zones.json'),
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, zones: [], imps: [], acc: {} }; } for (const k of ['zones', 'imps']) if (!Array.isArray(this.db[k])) this.db[k] = []; if (!this.db.acc) this.db.acc = {}; },
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, zones: [], imps: [], acc: {}, pay: [] }; } for (const k of ['zones', 'imps', 'pay']) if (!Array.isArray(this.db[k])) this.db[k] = []; if (!this.db.acc) this.db.acc = {}; },
|
||||
save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db)); } catch (e) {} } };
|
||||
function init(opts) { DATA_DIR = opts.dataDir; ads = opts.ads; siteHost = opts.siteHost || siteHost; J.load(); }
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const DAY = 86400000;
|
||||
function settings() { let s = {}; try { s = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'zone-rates.json'), 'utf8')); } catch (e) {} return Object.assign({ viewsPerCredit: 5, nasViewsPerCredit: 10, capPerVisitorDay: 50, houseOn: 1, nasOn: 0 }, s); } // nasOn default OFF: the network tier in zones is switched on with NAS at the end of testing (Marty 2026-10-09)
|
||||
// day keys in Central time (reports and the publisher strip count days the way Marty reads them)
|
||||
const dayFmt = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' });
|
||||
const dayKey = ts => dayFmt.format(new Date(ts));
|
||||
function settings() { let s = {}; try { s = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'zone-rates.json'), 'utf8')); } catch (e) {} return Object.assign({ viewsPerCredit: 5, nasViewsPerCredit: 10, nasViewsPerCreditVerified: 8, capPerVisitorDay: 50, houseOn: 1, nasOn: 0 }, s); } // nasOn default OFF: the network tier in zones is switched on with NAS at the end of testing (Marty 2026-10-09)
|
||||
// Publisher tiers (2026-10-10): every zone starts Standard; an admin marks a reviewed site Verified, and its network-ad
|
||||
// views pay at the better rate (1 credit per nasViewsPerCreditVerified views instead of nasViewsPerCredit). Member
|
||||
// campaign views pay the same on both tiers. The rate is applied when a view is credited (seen), not when it is served.
|
||||
const TIERS = ['standard', 'verified'];
|
||||
function tierOf(z) { return z && z.tier === 'verified' ? 'verified' : 'standard'; }
|
||||
function rateFor(z, nas, s) { s = s || settings(); if (!nas) return s.viewsPerCredit; return tierOf(z) === 'verified' ? s.nasViewsPerCreditVerified : s.nasViewsPerCredit; }
|
||||
// the document an NAS fallback renders in: our own frame, so the NAS tag's document.write lands in a page we control
|
||||
function nasFrame(size) { const wh = SIZES[size]; if (!wh || !NAS_SIZES.has(size)) return null; return '<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}body{width:' + wh[0] + 'px;height:' + wh[1] + 'px}img{border:0;display:block}</style></head><body>' + NAS_TAG(wh[0], wh[1]) + '</body></html>'; }
|
||||
// Earning status (Marty, 2026-09-29): a zone earns only once its first WARMUP on-site views have landed with at least
|
||||
@@ -41,7 +50,7 @@ function pubZone(z) {
|
||||
const imps = impsOf(z);
|
||||
const seen = imps.filter(i => i.ok).length; const clicks = imps.filter(i => i.k).length; const last = J.db.imps.filter(i => i.z === z.id).slice(-1)[0];
|
||||
const ratio = imps.length ? seen / imps.length : 0; const st = statusOf(z, imps);
|
||||
return { id: z.id, name: z.name, site: z.site, size: z.size, active: !!z.active, created: z.created, views30: imps.length, viewable30: seen, viewablePct: imps.length ? Math.round(ratio * 100) : null, clicks30: clicks, credits: z.credits || 0, grade: !imps.length ? null : ratio >= 0.6 ? 'A' : ratio >= 0.4 ? 'B' : 'C', lastSeen: last ? last.ts : 0, house30: imps.filter(i => i.house).length, nas30: imps.filter(i => i.nas).length, campaign30: imps.filter(i => i.camp).length, offsite30: imps.filter(i => i.off).length, status: st.state, statusLabel: st.label, paused: !!z.adminPaused };
|
||||
return { id: z.id, name: z.name, site: z.site, size: z.size, tier: tierOf(z), active: !!z.active, created: z.created, views30: imps.length, viewable30: seen, viewablePct: imps.length ? Math.round(ratio * 100) : null, clicks30: clicks, credits: z.credits || 0, grade: !imps.length ? null : ratio >= 0.6 ? 'A' : ratio >= 0.4 ? 'B' : 'C', lastSeen: last ? last.ts : 0, house30: imps.filter(i => i.house).length, nas30: imps.filter(i => i.nas).length, campaign30: imps.filter(i => i.camp).length, offsite30: imps.filter(i => i.off).length, status: st.state, statusLabel: st.label, paused: !!z.adminPaused };
|
||||
}
|
||||
// the site the tag is running on, from the browser's referrer (cross-origin fetches still send the origin); matches the
|
||||
// declared site or any subdomain of it
|
||||
@@ -53,7 +62,7 @@ async function create(owner, body) {
|
||||
const size = SIZES[String(body.size || '')] ? String(body.size) : '728x90';
|
||||
const name = String(body.name || '').trim().slice(0, 60) || 'Zone'; const site = String(body.site || '').trim().toLowerCase().replace(/^https?:\/\//, '').replace(/^www\./, '').split('/')[0].split(':')[0].slice(0, 80);
|
||||
if (!/^[a-z0-9.-]+$/.test(site) || !site.includes('.')) return { error: 'Enter the site the tag will live on, like myblog.com. Paid ads only serve on that site.' };
|
||||
const z = { id: 'ls-' + crypto.randomBytes(3).toString('hex'), owner: norm(owner), name, site, size, active: true, created: Date.now(), credits: 0 };
|
||||
const z = { id: 'ls-' + crypto.randomBytes(3).toString('hex'), owner: norm(owner), name, site, size, tier: 'standard', active: true, created: Date.now(), credits: 0 };
|
||||
J.db.zones.push(z); J.save(); return { ok: true, zone: pubZone(z) };
|
||||
}
|
||||
async function update(owner, id, body) {
|
||||
@@ -95,10 +104,15 @@ async function seen(impId, req) {
|
||||
imp.ok = 1;
|
||||
const earning = statusOf(z, impsOf(z)).state === 'earning';
|
||||
if (earning && todayByVisitor < s.capPerVisitorDay && !imp.house && !imp.off) { // house and off-site views are not paid
|
||||
// LinkSpin campaign views and NAS views accrue on separate meters with their own rates; whole credits go to the owner
|
||||
const key = z.owner + (imp.nas ? '|nas' : ''); const per = imp.nas ? s.nasViewsPerCredit : s.viewsPerCredit;
|
||||
// LinkSpin campaign views and NAS views accrue on separate meters with their own rates (verified zones keep their own
|
||||
// network meter, since their rate differs); whole credits go to the owner and are logged for the publisher reports
|
||||
const key = z.owner + (imp.nas ? (tierOf(z) === 'verified' ? '|nasv' : '|nas') : ''); const per = rateFor(z, !!imp.nas, s);
|
||||
J.db.acc[key] = (J.db.acc[key] || 0) + 1;
|
||||
if (per > 0 && J.db.acc[key] >= per) { const cr = Math.floor(J.db.acc[key] / per); J.db.acc[key] -= cr * per; z.credits = (z.credits || 0) + cr; try { await ads.addEarned(z.owner, cr, { log: { kind: 'earn', note: 'Zone views: ' + z.name + (imp.nas ? ' (network)' : ''), ref: 'zone:' + z.id, rollup: true } }); } catch (e) {} }
|
||||
if (per > 0 && J.db.acc[key] >= per) {
|
||||
const cr = Math.floor(J.db.acc[key] / per); J.db.acc[key] -= cr * per; z.credits = (z.credits || 0) + cr;
|
||||
J.db.pay.push({ ts: Date.now(), z: z.id, n: cr, nas: imp.nas ? 1 : 0 }); if (J.db.pay.length > 100000) J.db.pay = J.db.pay.slice(-80000);
|
||||
try { await ads.addEarned(z.owner, cr, { log: { kind: 'earn', note: 'Zone views: ' + z.name + (imp.nas ? ' (network)' : ''), ref: 'zone:' + z.id, rollup: true } }); } catch (e) {}
|
||||
}
|
||||
}
|
||||
J.save(); return { ok: true };
|
||||
}
|
||||
@@ -114,7 +128,32 @@ async function adminSet(id, body) {
|
||||
const z = J.db.zones.find(z => z.id === String(id)); if (!z) return { error: 'No such zone.' };
|
||||
if (body.paused != null) z.adminPaused = !!body.paused;
|
||||
if (body.note != null) z.adminNote = String(body.note).slice(0, 200);
|
||||
if (body.tier != null) { const t = String(body.tier).toLowerCase(); if (!TIERS.includes(t)) return { error: 'Tier is standard or verified.' }; z.tier = t; }
|
||||
J.save(); return { ok: true, zone: Object.assign(pubZone(z), { owner: z.owner, note: z.adminNote || '' }) };
|
||||
}
|
||||
function totals() { const since = Date.now() - 30 * DAY; const imps = J.db.imps.filter(i => i.ts >= since && !i.bot); return { zones: J.db.zones.length, views30: imps.length, viewable30: imps.filter(i => i.ok).length, clicks30: imps.filter(i => i.k).length, nas30: imps.filter(i => i.nas).length, credits: J.db.zones.reduce((n, z) => n + (z.credits || 0), 0) }; }
|
||||
module.exports = { init, SIZES, NAS_SIZES, WARMUP, HOLD_RATIO, settings, nasFrame, list, create, update, tag, serve, seen, click, totals, adminList, adminSet };
|
||||
// -- publisher program totals (Reports screen + the public strip): the last N days, Central days, per day and per zone.
|
||||
// "live" = switched on, not admin-paused, and seen by a real visitor inside the window. Credits are read from the pay log
|
||||
// (kept since 2026-10-10; credits granted before that are in each zone's lifetime total only).
|
||||
function publisherTotals(days) {
|
||||
days = Math.max(1, Math.min(365, Number(days) || 7)); const since = Date.now() - days * DAY;
|
||||
const imps = J.db.imps.filter(i => i.ts >= since && !i.bot); const pays = J.db.pay.filter(p => p.ts >= since);
|
||||
const byDay = {}, byZone = {}, seenZ = new Set();
|
||||
const dayRec = ts => { const k = dayKey(ts); return byDay[k] = byDay[k] || { day: k, views: 0, viewable: 0, credits: 0 }; };
|
||||
const zoneRec = id => { if (byZone[id]) return byZone[id]; const z = J.db.zones.find(x => x.id === id) || {}; return byZone[id] = { id, name: z.name || id, site: z.site || '', size: z.size || '', tier: tierOf(z), owner: z.owner || '', views: 0, viewable: 0, credits: 0 }; };
|
||||
for (const i of imps) { const d = dayRec(i.ts), zr = zoneRec(i.z); d.views++; zr.views++; if (i.ok) { d.viewable++; zr.viewable++; } if (!i.off) seenZ.add(i.z); }
|
||||
for (const p of pays) { dayRec(p.ts).credits += p.n; zoneRec(p.z).credits += p.n; }
|
||||
const live = J.db.zones.filter(z => z.active && !z.adminPaused && seenZ.has(z.id)).length;
|
||||
return { days, zones: J.db.zones.length, live, views: imps.length, viewable: imps.filter(i => i.ok).length, credits: pays.reduce((n, p) => n + p.n, 0),
|
||||
byDay: Object.values(byDay).sort((a, b) => a.day < b.day ? -1 : 1), byZone: Object.values(byZone).sort((a, b) => b.views - a.views) };
|
||||
}
|
||||
// the public "Network right now" strip on /publishers: 7-day totals plus the rates, cached a minute
|
||||
let pubCache = null;
|
||||
function publisherPublic() {
|
||||
if (pubCache && Date.now() - pubCache.ts < 60000) return pubCache.data;
|
||||
const t = publisherTotals(7); const s = settings();
|
||||
const data = { zones: t.zones, live: t.live, views7: t.views, viewable7: t.viewable, credits7: t.credits, sizes: Object.keys(SIZES), networkSizes: Array.from(NAS_SIZES), tiers: TIERS,
|
||||
rates: { viewsPerCredit: s.viewsPerCredit, nasViewsPerCredit: s.nasViewsPerCredit, nasViewsPerCreditVerified: s.nasViewsPerCreditVerified, capPerVisitorDay: s.capPerVisitorDay }, warmup: WARMUP, holdRatio: HOLD_RATIO, updated: Date.now() };
|
||||
pubCache = { ts: Date.now(), data }; return data;
|
||||
}
|
||||
module.exports = { init, SIZES, NAS_SIZES, TIERS, WARMUP, HOLD_RATIO, settings, tierOf, rateFor, nasFrame, list, create, update, tag, serve, seen, click, totals, publisherTotals, publisherPublic, adminList, adminSet };
|
||||
|
||||
Reference in New Issue
Block a user