From 994a2054d8a3cddb005fa133c23b157ac663671e Mon Sep 17 00:00:00 2001 From: martbost Date: Sun, 22 Nov 2026 12:56:38 -0600 Subject: [PATCH] Video Spin zone (/vz/): a rotating player for any web page; house Video Spin admin route /vz/ sends a frame to Social Tube's small player for one of the spin's videos on each page view; no click is recorded for a view (rotator.peek), plays and taps are counted by Video App Income under the spin's code. Embed code on the Video Spin screen. vsCreate / vsAdd shared by the member routes and POST /api/admin/house-videospin (admin key, house account, admin action log). Chatbot lines updated (Marty 2026-11-22). Co-Authored-By: Claude Fable 5.2 --- chatbot.js | 4 +- public/assets/video-spin.js | 3 ++ public/links.html | 3 +- rotator.js | 9 +++- server.js | 85 ++++++++++++++++++++++++++----------- 5 files changed, 75 insertions(+), 29 deletions(-) diff --git a/chatbot.js b/chatbot.js index 0273891..68c7648 100644 --- a/chatbot.js +++ b/chatbot.js @@ -71,7 +71,7 @@ const CANNED = [ a: 'The Level 4 override is 3 percent of every package bought four levels below you, paid by the company on top of the three levels the contract pays. It goes to the buyer’s 4th sponsor up if that member has 5 or more qualifying buyers (referrals who bought a package of $25 or more, the same bar as level 3). If they are not qualified yet, it moves up the line to the next member who is, up to 25 steps, and each purchase pays one override to one person. It is paid weekly in POL from a company wallet, every Monday after 9 AM Central for the Monday to Sunday week before, through the contract’s award function, so every payment has a Polygon link, and it shows on your Wallet screen as "Level 4 override". Weekly totals under 0.01 POL carry over to the next week. Purchases from the start date on count, earlier ones do not. It comes out of the platform’s 20 percent share, so the 50/20/10 split does not change. InstantAdPay pays its own override separately. What you earn depends on real purchases in your line; nothing is guaranteed.' }, { id: 'video-spin', title: 'Video Spins (Social Tube videos)', q: ['What is a Video Spin?', 'How do Video Spins work?', 'Where do my Social Tube videos go here?'], tags: ['video spin', 'video spins', 'social tube'], re: /(video ?spins?|rotat\w* (my |several |some )?videos?|spin (my |several )?videos?|social ?tube.{0,40}(track|link|spin|rotat)|(track|spin|rotat)\w*.{0,40}social ?tube)/i, - a: 'A Video Spin is one short link that opens a different video page each time. Open Links, choose Video Spins, name one, then tick videos you made on Video App Income or paste the Social Tube address of any member\'s video. Share the one link and the videos take turns; you can pause or remove any of them, and a video its owner hides is taken out automatically. Each video shows its clicks here plus how many people opened it, played it and tapped its button on Social Tube. Whoever\'s video is playing gets the views, and anyone who goes on to make their own video is credited to you. Video Spins come with your tier: Starter holds 2 with 5 videos each, Builder 5 with 15, Leader 10 with 25. Starter opens with any package of your own. The videos themselves are made on Video App Income (the first one is free) and shown on Social Tube, socialtube.club.' }, + a: 'A Video Spin is one short link that opens a different video page each time. Open Links, choose Video Spins, name one, then tick videos you made on Video App Income or paste the Social Tube address of any member\'s video. Share the one link and the videos take turns; you can pause or remove any of them, and a video its owner hides is taken out automatically. Each video shows its clicks here plus how many people opened it, played it and tapped its button on Social Tube. A Video Spin also has a rotating player: copy the code under "Put it on a web page" and each page view there plays a different video from the spin. Whoever\'s video is playing gets the views, and anyone who goes on to make their own video is credited to you. Video Spins come with your tier: Starter holds 2 with 5 videos each, Builder 5 with 15, Leader 10 with 25. Starter opens with any package of your own. The videos themselves are made on Video App Income (the first one is free) and shown on Social Tube, socialtube.club.' }, { id: 'banner-spin', title: 'Banner Spin: one image link that rotates your banners', q: ['What is Banner Spin?', 'How do I rotate several banners in one ad slot?', 'Who gets Banner Spin?'], tags: ['banner spin', 'banners', 'rotator', 'traffic exchange'], re: /banner ?spins?\b|rotat\w* (my |several |multiple |many |a few |\d+ )?banners|banners? rotat|(one|single) (image|banner) (url|address|link)/i, a: 'Banner Spin gives you one image address and one click address that rotate up to 25 banners, each with its own target page or spin link, so one banner slot on a traffic exchange, safelist, forum or your own site carries a whole campaign. It is a free add-on that opens with your own package of $25 or more: Starter holds 2 Banner Spins of 5 banners, Builder (level 2 open, 2 qualifying buyers) 5 of 15, Leader (level 3 open, 5 qualifying buyers) 10 of 25. Build it under Links, Banner Spins (' + SITE_URL + '/links#b) and copy one of four embeds: the image + click pair for exchanges and safelists, the HTML snippet for your site, the script tag (it writes the banner and its own link, so every click matches exactly) or the forum code. A click goes to the banner that visitor saw; one we cannot match goes to your fallback. It will not rotate inside paid ad networks (they copy the image when you upload a creative) or in Gmail (its image proxy keeps one copy), so use a single-banner Banner Spin for email. The Stats tab and Reports show views, clicks, CTR, match rate and conversions per banner and per placement, a WINNER badge once two banners have 1,000 views each, and a CACHED flag on sites that copy banners. Every live banner is checked every 30 minutes and paused after three failed checks, never the last live one.' }, @@ -225,7 +225,7 @@ FACTS: ${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS (the rotator: one short link, /r/, 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 with a CSV download, or the member pastes an autoresponder form on a squeeze page and LinkSpin restyles it; there is no lead 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, plus Pages, Zones, and since 2026-10-12 Traffic sources and Placements). BLOG at /blog with RSS at /blog/feed.xml. TRAFFIC SOURCES at /sources (2026-10-12): a source is a record of a network the member buys traffic on, created from a catalog of networks (PropellerAds, Zeropark, Adsterra, ExoClick, HilltopAds, TrafficStars, PopAds and more, with each network's macro tokens and conversion postback URL; account-specific slots such as a goal id are filled in at creation) or defined by hand; a spin link is pointed at one source (Share kit on the Links screen, or the Sources screen), and then the Share kit's first row is the exact campaign URL for that network with its macros already in place; when a click that came through that source converts (join, lead, wallet, purchase, or a partner-reported conversion; the member picks which) LinkSpin fires that network's own postback with the network's click id and the payout, server to server, and only the network that sent the click is told; Reports show clicks, uniques and conversions by source and by placement (the value the network's zone, placement, site, campaign, creative, banner or keyword macro carried); up to 30 sources per account, 20 params each; a source with no postback still builds the campaign URL and shows in Reports; the account-level Postbacks list on the Links screen (for the member's own tracker) still works alongside. TRAFFIC GUIDE at /traffic-guide (2026-10-28, public, linked from the Sources screen header and each source's detail): pick an offer type (free sign-up or email capture; crypto or team-build opportunity; advertising tools and ad credits; games and play-to-earn; software, apps and AI tools; courses and info products; giveaways and freebies) to see each ad format rated best / good / weak / avoid with a reason, a tip, and the catalog networks that sell the good formats (strict-policy networks Google, Microsoft, Facebook, Taboola, Revcontent, MGID left out for the crypto offer; adult-only TrafficJunky only for games and giveaways); cards for the 8 formats (popunder, push, in-page push, native, search, social, banners, domain redirect: what it is, how you pay, what converts, what struggles, landing page); a table of all 30 catalog networks with the formats each sells, adult-heavy and strict-policy flags and best-for; ground rules (test small, track every click under Sources, one change at a time, block zones that waste money, no income promises, mainstream vs adult inventory). The New source picker shows the same format tags and can be searched by format (push, native...). Never promise results; the guide says Reports are the final word. Knowledge checked on ${KNOWLEDGE_DATE}. - CONVERSION PIXEL (LIVE 2026-10-23, Control Room > Conversions at ${SITE_URL}/conversions; InstantAdPay members see the same goals under Campaigns > Conversion tracking, held on their LinkSpin account): a member names GOALS (subscriber, sale, any word, optional default value, up to 20); each goal has a PUBLIC pixel id (px + 10 characters) that can only count clicks the member owns. EVERY CLICK GETS AN ID: LinkSpin ad clicks (banner, text, zones) and InstantAdPay ad clicks add lsclk= to the target address (other params kept); a spin link reached through an ad passes its own id on and inherits the ad as its source; spin links of a member with a goal add lsclk to the destination too, and so do Banner Spin clicks that go straight to a page (since 2026-10-26; a banner pointed at a spin link gets the spin link's id). SETUP, 3 steps: 1) the LANDING TAG on the landing page, one line , keeps the id on the member's own site 30 days (localStorage + a first-party cookie), fills hidden form fields named lsclk, lsid or clickid and adds the id to links that stay on the same site; 2) the GOAL PIXEL on the thank-you page, an image cv.gif?px=PIXEL_ID&goal=NAME (optional &value=19.95) or the script version cv.js that reads what the tag kept; 3) Send a test conversion (recorded apart, never counted). MATCHING ORDER: the click id in the address, then the id the tag kept, then LinkSpin's own cookie, then a 24-hour match on network + browser (a hash, no IP stored); the method is shown per goal so members see how solid each count is. RULES: each goal counts once per click (an ad click and the spin-link click it led to are one click), only within 30 days of a real click, only for the pixel owner's own clicks, rate limited per pixel and per visitor. OWN CLICKS (2026-10-26): the goal owner's own click on ANY click type (ads, spin links, Banner Spins) is kept as a test and never counted: a click made while signed in as the owner, or a click or conversion from a browser (network + browser soft key) the owner has signed in from on LinkSpin or InstantAdPay; the Conversions screen says 'N from your own clicks, kept as tests and left out'. To test, use Send a test conversion and the &test=1 page check, never a sign-up of your own. REPORTS per goal: conversions and cost per goal (the campaign's credits spent / its conversions, in that site's ad credits) by ad campaign (LinkSpin and InstantAdPay), spin link, Banner Spin (banners straight to a page), destination page and traffic source, plus CSV export. ONE PLACE TO LOOK (2026-11-07): Reports > Conversions on LinkSpin and the Conversion tracking card on InstantAdPay list goals together with join, wallet and purchase events, with values, each event once; per-link Conv. counts include goals; the CSV holds goal conversions only. NETWORK EVENTS (2026-11-07, reporting only, it never changes sponsors, payouts or anything on chain): the landing tag adds the kept click id to links to instantadpay.com, linkspin.app and the share domains instantadpay.link, ctbgo.com and mylinehq.com, also inside a member's own redirect link when the address is in one of its parameters (spin and Banner Spin links are left alone; a button that navigates by script instead of a link is not covered); a spin link or Banner Spin pointed straight at those sites adds lsclk with no goal needed. InstantAdPay keeps the click 30 days in a first-party cookie, stores it on the account at sign-up and reports sign-up, wallet link and each package purchase (value = the USD price on the chain event, linked positions included) to LinkSpin, which counts join and wallet once per click and every purchase on its own. Same 30-day rule: an event more than 30 days after the click does not count. The first account on a click owns it. The click owner's own account and own clicks are kept as tests. Postbacks fire for join, wallet and purchase as they do for LinkSpin's own. Nothing is counted back in time: an account without a click stored at sign-up has none. POSTBACKS: a postback or traffic source set to the event 'goal' fires for every goal with {event} = the goal name. AUTORESPONDERS: when Aweber, GetResponse or another provider hosts the thank-you page, set its thank-you (success) redirect to the member's own page that carries the pixel; otherwise the pixel still counts through the cookie or the 24-hour match, less surely. The tag and pixel never break the page if LinkSpin cannot be reached and work inside traffic-exchange frames. SETUP GUIDE (public, 2026-10-24): ${SITE_URL}/conversion-tracking (InstantAdPay's copy: https://instantadpay.com/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, the last test time updates, then remove it), what to do without code on the thank-you page (image pixel = cookie or 24-hour match; LinkSpin.goal(pixelId, name) from the page's own code for a pop-up form; postbacks), how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest, a Banner Spin banner pointed straight at a page now carries its own click id and counts under By Banner Spin; the member's own clicks on ads, spin links and Banner Spins are all kept as tests). Send members there for any setup question. - TOOL LIMITS BY TIER (2026-10-21): spin links and pages each: Free (no package) 3, Starter (any package of your own) 10, Builder (level 2 open, 2 qualifying buyers) 50, Leader (level 3 open, 5 qualifying buyers) unlimited (fair use). Each spin link rotates up to 25 destinations at every tier; clicks are unlimited. Nothing already made is ever removed when a cap applies; new ones wait for the upgrade. Banner Spin has its own ladder (Starter 2 x 5, Builder 5 x 15, Leader 10 x 25). Other limits, same for everyone: 50 zones, 20 audiences, 20 postbacks, 5 linked positions. -- VIDEO SPIN (LIVE 2026-11-22): Links > Video Spins. One short spin link (/r/) that rotates through video pages on Social Tube (socialtube.club, the network's video gallery of videos members make on Video App Income). The member picks their own videos from a list or pastes any member's Social Tube video address; every video is checked with Video App Income before it is added, and other addresses cannot be put in a Video Spin. Pause, resume and remove per video; pause or delete the whole spin; a hidden or removed video is taken out by the health check. Per video: clicks (LinkSpin) plus opened / played / tapped the button (counted on Social Tube). The video owner gets the views; a visitor who goes on to join Video App Income is credited to the spin's owner. Limits by tier: Starter 2 Video Spins x 5 videos, Builder 5 x 15, Leader 10 x 25; Free has none. Video Spins are counted apart from ordinary spin links. Social Tube is also its own traffic source now (clicks from it carry ?src=socialtube; network link code nwst). +- VIDEO SPIN (LIVE 2026-11-22): Links > Video Spins. One short spin link (/r/) that rotates through video pages on Social Tube (socialtube.club, the network's video gallery of videos members make on Video App Income). The member picks their own videos from a list or pastes any member's Social Tube video address; every video is checked with Video App Income before it is added, and other addresses cannot be put in a Video Spin. Pause, resume and remove per video; pause or delete the whole spin; a hidden or removed video is taken out by the health check. Per video: clicks (LinkSpin) plus opened / played / tapped the button (counted on Social Tube). The video owner gets the views; a visitor who goes on to join Video App Income is credited to the spin's owner. ROTATING PLAYER: each Video Spin also has embed code (an iframe to /vz/) that plays a different video of the spin on each page view; page views are not counted as clicks, plays and button taps are counted per video. Limits by tier: Starter 2 Video Spins x 5 videos, Builder 5 x 15, Leader 10 x 25; Free has none. Video Spins are counted apart from ordinary spin links. Social Tube is also its own traffic source now (clicks from it carry ?src=socialtube; network link code nwst). - BANNER SPIN (LIVE 2026-10-18, reports and health checks 2026-10-20): one image address (/i/.gif on a link domain) and one click address (/c/) that rotate up to 25 banners, each with its own target (any https page or one of the member's spin links), weights 1 to 100, random by weight on every view or one banner per visitor per day, the dayparting grid per Banner Spin and per banner, pause, a fallback page and an optional fallback banner image, and a traffic source so its conversions fire that network's postback. Built on the Links screen (${SITE_URL}/links#b). WHO GETS IT: a free add-on for members with their own package of $25 or more; tiers: Starter 2 Banner Spins x 5 banners, Builder (level 2 open, 2 qualifying buyers) 5 x 15, Leader (level 3 open, 5 qualifying buyers) 10 x 25; dropping below a tier keeps everything serving, it only stops new ones. One size per Banner Spin (468x60, 728x90, 300x250, 125x125, 160x600, 120x600, 336x280, 250x250, 320x50); JPG, PNG or GIF (animated is fine), 150 KB at most, uploads count toward the 10 files a day. EMBEDS: the image + click pair (traffic exchanges, safelists, downline builders), an HTML snippet (own sites, blogs, HTML email), a script tag (writes the banner and its own link, so every click matches exactly) and forum BBCode; every link domain answers every code. MATCHING: with the pair, the server remembers which banner a visitor saw on which page for 15 minutes and sends the click there; an unmatched click goes to the fallback. LIMITS: paid ad networks (Froggy, PropellerAds and the like) copy the image at upload, so it freezes on one banner there; Gmail and some mail apps fetch images through a caching proxy, so email readers mostly see one banner and clicks fall back: use a single-banner Banner Spin for email. REPORTS: per banner and per placement views, unique viewers (daily sample), clicks, CTR, match rate and conversions, by Central day, country and device, bots and server loads shown separately and never counted; a WINNER badge once two or more live banners have 1,000 views each and one leads on click rate (LinkSpin never changes weights by itself); a CACHED flag on a placement that copies banners to its own server; totals also on the Reports screen. HEALTH: every 30 minutes each live banner's image must load as an image of the right size and its target must pass the spin-link checks (dead, parked, slow); three failures in a row pause that banner, two clean passes resume it, the last live banner is never auto-paused, and the status shows on each banner row. - 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. diff --git a/public/assets/video-spin.js b/public/assets/video-spin.js index fb94d31..aac72a7 100644 --- a/public/assets/video-spin.js +++ b/public/assets/video-spin.js @@ -10,6 +10,7 @@ const mark = () => { if (!$('vsWs').hidden) history.replaceState(null, '', '#v' + (SEL || '')); }; const base = () => 'https://' + (HOST || location.host), linkOf = s => base() + '/r/' + s.code; const clicks7 = s => s.hits7 || 0; + const zoneCode = s => ''; const state = s => s.paused ? { cls: 'warn', t: 'PAUSED' } : !s.destinations.some(d => d.active) ? { cls: 'bad', t: 'NO LIVE VIDEO' } : { cls: 'ok', t: 'LIVE' }; // ── view switch: this script only owns the Video Spins view; banner-spin.js keeps switching the other two ── @@ -75,6 +76,7 @@ box.innerHTML = '

' + esc(s.name) + '

' + state(s).t + '
' + '
' + '

' + fmt(s.hits || 0) + ' clicks in all, ' + fmt(s.hits7 || 0) + ' in the last 7 days' + (s.conversions ? ', ' + s.conversions + ' conversion' + (s.conversions === 1 ? '' : 's') : '') + '. Each open goes to one of the videos below.

' + + '
Put it on a web page (rotating player)

Paste this code into any page. Each page view plays a different video from this spin, with that video\'s own button. Page views are not counted as clicks; plays and button taps show under each video.

' + '

Videos in this spin ' + s.destinations.length + ' of ' + L.videos + '

' + (rows || '

No videos yet. Add some below; the link starts working with the first one.

') + '

Add your videos

' @@ -86,6 +88,7 @@ + (room ? '
' : '

This Video Spin is full for your tier.

') + '
'; $('vsCopy').addEventListener('click', () => { const u = linkOf(s); (navigator.clipboard && navigator.clipboard.writeText ? navigator.clipboard.writeText(u) : Promise.reject()).then(() => toast('Link copied'), () => { $('vsLink').select(); toast('Select and copy the link', true); }); }); + $('vsZoneCopy').addEventListener('click', () => { const u = zoneCode(s); (navigator.clipboard && navigator.clipboard.writeText ? navigator.clipboard.writeText(u) : Promise.reject()).then(() => toast('Code copied'), () => { $('vsZone').select(); toast('Select and copy the code', true); }); }); $('vsPause').addEventListener('click', () => act(() => api('/api/my/rotations/' + s.id, { paused: !s.paused }), s.paused ? 'Resumed' : 'Paused')); $('vsDel').addEventListener('click', e => { const b = e.currentTarget; if (b.dataset.arm !== '1') { b.dataset.arm = '1'; b.textContent = 'Tap again to delete'; setTimeout(() => { b.dataset.arm = ''; b.textContent = 'Delete'; }, 4000); return; } act(async () => { await api('/api/my/rotations/' + s.id, { remove: true }); SEL = null; history.replaceState(null, '', '#v'); }, 'Video Spin deleted'); }); diff --git a/public/links.html b/public/links.html index 4130c70..78a8b00 100644 --- a/public/links.html +++ b/public/links.html @@ -113,6 +113,7 @@ .vsh{font-size:14px;letter-spacing:.06em;text-transform:uppercase;margin:24px 0 8px;display:flex;gap:10px;align-items:baseline}.vsh .muted{font-size:12px;text-transform:none;letter-spacing:0;font-weight:400} .vsv{display:grid;grid-template-columns:44px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}.vsv img{width:44px;height:78px;object-fit:cover;border-radius:6px;background:#000} .vsi b{font-size:14px}.vsi .muted{font-size:12.5px;margin-top:3px}.vsa{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end} +.vsz{margin-top:14px;border:1px solid var(--line);border-radius:8px;padding:10px 12px;background:var(--panel)}.vsz summary{cursor:pointer;font-weight:700;font-size:13.5px} .vsgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:10px}.vsc{position:relative;display:block;cursor:pointer;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--panel)} .vsc img{display:block;width:100%;aspect-ratio:9/16;object-fit:cover;background:#000}.vsc span{display:block;font-size:12px;line-height:1.3;padding:6px 7px;max-height:44px;overflow:hidden}.vsc input{position:absolute;left:6px;top:6px;width:18px;height:18px} @media (max-width:760px){.vsp{padding:14px 14px 24px}.vsv{grid-template-columns:44px minmax(0,1fr)}.vsa{grid-column:1/-1;justify-content:flex-start}} @@ -290,6 +291,6 @@ - + diff --git a/rotator.js b/rotator.js index c9610ef..9e4bb38 100644 --- a/rotator.js +++ b/rotator.js @@ -220,6 +220,13 @@ function pick(r, cell) { return live[live.length - 1]; } // the redirect: returns { url, dest } or null (unknown code). Records the hit. +// A pick with no click recorded (Video Spin zone, 2026-11-22): the embedded player asks for a video on every page view, and a page view +// is not a click. Same rules as a click: paused or off-hours gives no destination. +async function peek(code) { + const r = J.db.rotations.find(r => r.code === norm(code)); if (!r) return null; + const cell = cellAt(zoneFor(r, '')); const off = !r.paused && !isOn(r.hours, cell); + return { rotation: r, dest: (r.paused || off) ? null : pick(r, cell) }; +} 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; @@ -411,5 +418,5 @@ function adminAll() { destinations: (r.destinations || []).map(d => ({ id: d.id, url: d.url, label: d.label || '', weight: d.weight, active: !!d.active, autoPaused: d.autoPaused || 0, health: d.health ? { state: d.health.state, note: d.health.note || '', checkedAt: d.health.checkedAt || 0 } : null })), hits: o.hits, hits7: o.hits7, bots: o.bots, conversions: cv[r.id] || 0 }; }); } -module.exports = { eraseOwner, _json: { state: () => J.db, save: () => J.save() }, init, convRows, adminAll, hitById, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday, window24, +module.exports = { eraseOwner, _json: { state: () => J.db, save: () => J.save() }, init, convRows, adminAll, hitById, list, get, create, update, remove, addDest, updateDest, resolve, peek, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday, window24, pub, rawRotations, save, findMine, setExternalConvert, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ, sourceCounts, detachSource, ensureFixed, ensurePartner, partnerStats }; diff --git a/server.js b/server.js index f317211..9744329 100644 --- a/server.js +++ b/server.js @@ -262,6 +262,35 @@ async function vaiCall(op, body) { } // the video's page: the address Video App Income gives for it when it is a plain watch address for that id, else the known one const vsWatchUrl = x => { const u = String((x && x.url) || ''), id = String((x && x.id) || ''); return u.startsWith('http') && !u.includes('?') && !u.includes('#') && u.endsWith('/watch/' + id) && u.length < 200 && (!IS_PROD || u.startsWith('https://socialtube.club/')) ? u : 'https://socialtube.club/watch/' + id; }; +async function vsCreate(email, name) { // -> { code, body } + if (!vsOn()) return { code: 503, body: { error: 'Video Spins are not switched on yet.' } }; + const t = await toolTier(email), lim = VS_LIMITS[t.key] || VS_LIMITS.free, have = (await rotator.list(email)).filter(x => x.kind === 'video').length; + if (!lim.spins) return { code: 400, body: { error: 'Video Spins start at the Starter tier (any package of your own).', tier: t } }; + if (have >= lim.spins) return { code: 400, body: { error: 'Your ' + t.label + ' tier holds ' + lim.spins + ' Video Spins and you have ' + have + '.', tier: t } }; + let mine = { member: null }; try { mine = await vsMine(email); } catch (e) {} + const ref = mine.member ? mine.member.username || mine.member.id : ''; + const r = await rotator.create(email, { name, fallback: 'https://socialtube.club/' + (ref ? '?ref=' + encodeURIComponent(ref) : ''), kind: 'video', vref: ref }); + return { code: r.error ? 400 : 200, body: r }; +} +async function vsAdd(email, id, b) { // b: { ids: [own video ids], link: a Social Tube video address } -> { code, body } + if (!vsOn()) return { code: 503, body: { error: 'Video Spins are not switched on yet.' } }; + const rot = (await rotator.list(email)).find(x => x.id === Number(id) && x.kind === 'video'); if (!rot) return { code: 404, body: { error: 'No such Video Spin.' } }; + const t = await toolTier(email), lim = VS_LIMITS[t.key] || VS_LIMITS.free, raw = rotator._json.state().rotations.find(x => x.id === rot.id); + const picks = []; // { id, title, owner, poster, url } + try { + const ids = (Array.isArray(b.ids) ? b.ids : []).map(String).filter(x => /^[A-Za-z0-9]{1,20}$/.test(x)).slice(0, 25); + if (ids.length) { const mine = await vsMine(email); for (const vid of ids) { const vd = mine.videos.find(x => x.id === vid); if (vd) picks.push(vd); } if (picks.length !== ids.length) return { code: 400, body: { error: 'One of those is not a video of yours on Social Tube. Reload and pick again.' } }; } + const link = String(b.link || '').trim(); + if (link) { const x = await vaiCall('video', { link }); if (x.s !== 200 || !x.j.video) return { code: 400, body: { error: (x.j && x.j.error) || 'That video link could not be checked.' } }; picks.push(x.j.video); } + } catch (e) { return { code: 502, body: { error: 'Video App Income is not answering right now. Nothing was added. Try again in a minute.' } }; } + if (!picks.length) return { code: 400, body: { error: 'Pick at least one video, or paste a Social Tube video link.' } }; + const fresh = picks.filter((x, i) => !rot.destinations.some(d => d.vid === x.id) && picks.findIndex(y => y.id === x.id) === i); + if (!fresh.length) return { code: 400, body: { error: picks.length === 1 ? 'That video is already in this Video Spin.' : 'Those videos are already in this Video Spin.' } }; + if (rot.destinations.length + fresh.length > lim.videos) return { code: 400, body: { error: 'Your ' + t.label + ' tier holds ' + lim.videos + ' videos in one Video Spin. This one has ' + rot.destinations.length + '.', tier: t } }; + let out = null; + for (const x of fresh) { out = await rotator.addDest(email, rot.id, { url: vsWatchUrl(x) + '?vs=' + rot.code + (raw && raw.vref ? '&ref=' + encodeURIComponent(raw.vref) : ''), label: String(x.title || 'Video').slice(0, 60), weight: 10 }, { video: x }); if (out.error) return { code: 400, body: out }; } + return { code: 200, body: { ok: true, added: fresh.length, rotation: out.rotation } }; +} const vsMineCache = new Map(); // email -> { ts, v }: the member's own Social Tube videos, kept one minute async function vsMine(email) { const e = String(email || '').toLowerCase(), hit = vsMineCache.get(e); if (hit && Date.now() - hit.ts < 60000) return hit.v; @@ -1491,6 +1520,16 @@ const server = http.createServer(async (req, res) => { // every /go/ and every ?return= link goes to networksso (2026-11-17): it knows the hub's sign-in sites, so a new site no longer needs a line here if (req.method === 'GET' && (p.startsWith('/go/') || p.startsWith('/sso/') || p === '/api/sso/status' || u.searchParams.has('return')) && !isPagesHost(req) && !isLinkHost(req) && await networksso.handle(req, res, u)) return; + // -- Video Spin zone (2026-11-22):