Video Spin: one short link that rotates through video pages on Social Tube; Social Tube as a network link + traffic source

Links > Video Spins (third view). A Video Spin is a spin link (rotator kind 'video'): its videos are picked from the member's own Video App
Income videos or added by any member's Social Tube address, each checked with Video App Income over signed calls (NETCONV_SECRET_VAI,
prefix vspin.v1.). Pasted addresses are refused on a Video Spin. Per video: clicks here plus opened / played / tapped from Video App Income.
Limits mirror Banner Spin (Starter 2x5, Builder 5x15, Leader 10x25), counted apart from spin links. Network link nwst + source socialtube;
socialtube.club gets the click id. Chatbot answer video-spin, KNOWLEDGE_DATE 2026-11-22 (Marty 2026-11-22).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-22 12:29:54 -06:00
parent a6c36aeca1
commit bca3666ee2
9 changed files with 232 additions and 12 deletions
+18
View File
@@ -159,6 +159,24 @@
"verified": true,
"source": "network"
},
{
"key": "socialtube",
"name": "Social Tube",
"site": "socialtube.club",
"costModel": "",
"params": [
{
"key": "clickid",
"token": "{clickid}",
"label": "Click id",
"role": "externalId"
}
],
"postbackUrl": "",
"notes": "Crypto Team Build Network video gallery (members' short videos made with Video App Income). Clicks that arrive from Social Tube carry ?src=socialtube and are counted under this source automatically. Sign-ups and credit purchases on Video App Income that follow one of your clicks show in Reports > Conversions.",
"verified": true,
"source": "network"
},
{
"key": "viraladsource",
"name": "ViralAdSource",
+5 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -15,6 +15,7 @@ const SITES = [
{ id: 'viraladsource', code: 'nwvas', name: 'ViralAdSource', url: 'https://viraladsource.com/{s2}?ref={s1}' },
{ id: 'yourprogrambuilder', code: 'nwypb', name: 'YourProgramBuilder', url: 'https://yourprogrambuilder.com/{s2}?ref={s1}' },
{ id: 'videoappincome', code: 'nwvai', name: 'Video App Income', url: 'https://videoappincome.com/{s2}?ref={s1}' }, // 2026-11-21: s2 = join for the invite page, empty = the sales page
{ id: 'socialtube', code: 'nwst', name: 'Social Tube', url: 'https://socialtube.club/{s2}?ref={s1}' }, // 2026-11-22: the network's video gallery; ?ref= keeps the member's credit on every page there
{ id: 'fivex', code: 'nw5x', name: '5xYourTeam', url: 'https://5xyourteam.com/{s2}?ref={s1}' },
{ id: 'downlinehydra', code: 'nwdh', name: 'DownlineHydra', url: 'https://downlinehydra.com/{s2}?ref={s1}' },
{ id: 'stackpol', code: 'nwsp', name: 'Stack POL', url: 'https://stackpol.com/{s2}?ref={s1}' },
+103
View File
@@ -0,0 +1,103 @@
// Video Spin (2026-11-22): the third view on the Links screen. One short link that rotates through video pages on Social Tube.
// It is a spin link underneath (rotator.js, kind 'video'): pause, weights and removal go through the spin-link routes; creating one,
// adding videos and the play counts go through /api/my/videospins (server.js), which checks every video with Video App Income.
(function () {
'use strict';
if (!window.CR || !document.getElementById('vsWs')) return;
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast;
let D = null, SPINS = [], SEL = null, HOST = '', PLAYS = {}, BUSY = false;
let WANT = Number((/^#v([0-9]+)$/.exec(location.hash) || [])[1]) || 0; // the Video Spin named in the address when the page opened
const mark = () => { if (!$('vsWs').hidden) history.replaceState(null, '', '#v' + (SEL || '')); };
const base = () => 'https://' + (HOST || location.host), linkOf = s => base() + '/r/' + s.code;
const clicks7 = s => s.hits7 || 0;
const state = s => s.paused ? { cls: 'warn', t: 'PAUSED' } : !s.destinations.some(d => d.active) ? { cls: 'bad', t: 'NO LIVE VIDEO' } : { cls: 'ok', t: 'LIVE' };
// ── view switch: this script only owns the Video Spins view; banner-spin.js keeps switching the other two ──
function show(on) {
$('vsWs').hidden = !on; const vb = $('vsNewBtn'); if (vb) vb.hidden = !on;
if (on) { $('ws').hidden = true; $('bsWs').hidden = true; const nb = $('newBtn'), bn = $('bsNewBtn'); if (nb) nb.hidden = true; if (bn) bn.hidden = true; }
}
$('vsw').querySelectorAll('button').forEach(b => b.addEventListener('click', () => {
const on = b.dataset.v === 'videos'; show(on);
if (on) load(true);
}));
(function addBtn(n) { const nb = $('newBtn'); if (!nb) { if (n < 50) setTimeout(() => addBtn(n + 1), 200); return; }
const b = document.createElement('button'); b.className = 'btn pri'; b.id = 'vsNewBtn'; b.type = 'button'; b.hidden = $('vsWs').hidden; b.textContent = '+ New Video Spin'; nb.parentNode.appendChild(b);
b.addEventListener('click', () => { SEL = null; render(); const i = $('vsNewName'); if (i) i.focus(); }); })(0);
async function load(keep) {
try { D = await CR.get('/api/my/videospins'); } catch (e) { toast(e.message, true); return; }
SPINS = (D.spins || []).slice().sort((a, b) => clicks7(b) - clicks7(a) || b.created - a.created);
const hs = D.hosts || []; if (!HOST || !hs.includes(HOST)) HOST = hs[0] || location.host;
if (!keep || !SPINS.some(s => s.id === SEL)) SEL = null;
if (WANT) { if (SPINS.some(s => s.id === WANT)) SEL = WANT; WANT = 0; }
mark(); setTimeout(mark, 1500); // the spin-link list reloads in the background and may set its own address; keep ours while this view is open
render(); if (SEL) loadPlays();
}
async function loadPlays() { const id = SEL; try { const r = await CR.get('/api/my/videospins/' + id + '/plays'); if (id === SEL) { PLAYS = r.plays || {}; renderDetail(); } } catch (e) {} }
function render() { renderList(); renderDetail(); }
function renderList() {
const L = D.limits || { spins: 0, videos: 0 }, t = D.tier || { label: '' };
$('vsCount').textContent = SPINS.length + ' Video Spin' + (SPINS.length === 1 ? '' : 's');
$('vsTier').innerHTML = L.spins ? esc(t.label) + ' tier: ' + L.spins + ' Video Spins, ' + L.videos + ' videos in each.'
: 'Video Spins start at the Starter tier (any package of your own): 2 Video Spins with 5 videos in each.';
$('vsItems').innerHTML = SPINS.length ? SPINS.map(s => { const h = state(s); return '<div class="item' + (s.id === SEL ? ' on' : '') + '" data-id="' + s.id + '" role="button" tabindex="0">'
+ '<div><div class="nm">' + esc(s.name) + (h.cls !== 'ok' ? ' <span class="tag ' + h.cls + '">' + h.t + '</span>' : '') + ' <span class="tag plain">' + s.destinations.length + ' video' + (s.destinations.length === 1 ? '' : 's') + '</span></div><div class="cd">' + esc((HOST || location.host) + '/r/' + s.code) + '</div></div>'
+ '<div class="rt"><span class="n">' + fmt(clicks7(s)) + '</span><span class="muted" style="font-size:10px">7 d</span></div></div>'; }).join('')
: '<div class="empty"><div class="muted">No Video Spins yet.</div></div>';
$('vsItems').querySelectorAll('.item').forEach(el => { const go = () => { SEL = Number(el.dataset.id); PLAYS = {}; history.replaceState(null, '', '#v' + SEL); render(); loadPlays(); };
el.addEventListener('click', go); el.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); go(); } }); });
}
function renderDetail() {
const box = $('vsDetail'), s = SPINS.find(x => x.id === SEL), L = D.limits || { spins: 0, videos: 0 };
if (!s) {
const can = D.on && L.spins > 0 && SPINS.length < L.spins;
box.innerHTML = '<div class="vsp"><div class="h-disp" style="font-size:18px">Video Spin</div>'
+ '<p class="muted" style="margin:8px 0 14px;max-width:560px">One short link that plays a different video page each time it is opened. Pick videos you made on Video App Income, or add any member\'s video by its Social Tube link. Share the one link; the videos take turns. People who go on to make their own video are credited to you.</p>'
+ (D.vaiError ? '<p class="muted" style="margin:0 0 12px">' + esc(D.vaiError) + '</p>' : '')
+ (!D.on ? '<p class="muted">Video Spins are not switched on yet.</p>'
: can ? '<div class="vsrow"><input class="field" id="vsNewName" maxlength="80" placeholder="Name this Video Spin, for example: My best videos"><button class="btn pri" type="button" id="vsCreate">Create</button></div>'
: '<p class="muted">' + (L.spins ? 'You have all ' + L.spins + ' Video Spins your tier holds. Remove one to make another.' : 'Video Spins start at the Starter tier (any package of your own).') + '</p>')
+ '</div>';
const c = $('vsCreate'); if (c) { const go = async () => { const name = $('vsNewName').value.trim(); if (!name) { toast('Give it a name first.', true); return; } if (BUSY) return; BUSY = true;
try { const r = await api('/api/my/videospins', { name }); SEL = r.rotation.id; history.replaceState(null, '', '#v' + SEL); toast('Video Spin created. Now add videos.'); await load(true); } catch (e) { toast(e.message, true); } BUSY = false; };
c.addEventListener('click', go); $('vsNewName').addEventListener('keydown', e => { if (e.key === 'Enter') go(); }); }
return;
}
const inSpin = new Set(s.destinations.map(d => d.vid)), mine = (D.videos || []).filter(v => !inSpin.has(v.id)), room = Math.max(0, L.videos - s.destinations.length);
const rows = s.destinations.map(d => { const p = PLAYS[d.vid] || null, gone = p && p.live === false;
const tag = gone ? '<span class="tag bad">REMOVED BY OWNER</span>' : !d.active ? '<span class="tag warn">' + (d.autoPaused ? 'PAUSED: NOT LOADING' : 'PAUSED') + '</span>' : '';
return '<div class="vsv"><img src="' + esc(d.poster || '') + '" alt="" loading="lazy"><div class="vsi"><b>' + esc(d.label || 'Video') + '</b> ' + tag + '<div class="muted">' + (d.vowner ? 'By ' + esc(d.vowner) + '. ' : '') + fmt(d.hits || 0) + ' click' + ((d.hits || 0) === 1 ? '' : 's')
+ (p ? ', ' + fmt(p.views) + ' opened, ' + fmt(p.plays) + ' played, ' + fmt(p.taps) + ' tapped the button' : '') + '</div></div>'
+ '<div class="vsa"><button class="btn sm" type="button" data-act="' + (d.active ? 'pause' : 'resume') + '" data-d="' + d.id + '">' + (d.active ? 'Pause' : 'Resume') + '</button><button class="btn sm" type="button" data-act="remove" data-d="' + d.id + '">Remove</button></div></div>'; }).join('');
box.innerHTML = '<div class="vsp"><div class="vshead"><h2>' + esc(s.name) + '</h2><span class="tag ' + state(s).cls + '">' + state(s).t + '</span></div>'
+ '<div class="vsrow"><input class="field mono" id="vsLink" readonly value="' + esc(linkOf(s)) + '"><button class="btn pri" type="button" id="vsCopy">Copy link</button><button class="btn" type="button" id="vsPause">' + (s.paused ? 'Resume' : 'Pause') + '</button><button class="btn" type="button" id="vsDel">Delete</button></div>'
+ '<p class="muted" style="margin:8px 0 0">' + fmt(s.hits || 0) + ' clicks in all, ' + fmt(s.hits7 || 0) + ' in the last 7 days' + (s.conversions ? ', ' + s.conversions + ' conversion' + (s.conversions === 1 ? '' : 's') : '') + '. Each open goes to one of the videos below.</p>'
+ '<h3 class="vsh">Videos in this spin <span class="muted">' + s.destinations.length + ' of ' + L.videos + '</span></h3>'
+ (rows || '<p class="muted">No videos yet. Add some below; the link starts working with the first one.</p>')
+ '<h3 class="vsh">Add your videos</h3>'
+ (D.vaiError ? '<p class="muted">' + esc(D.vaiError) + '</p>' : !D.member ? '<p class="muted">No Video App Income account was found for your email address. Make your first video at <a href="https://linkspin.app/r/nwvai?src=linkspin&amp;s2=" target="_blank" rel="noopener">videoappincome.com</a> (it is free), then come back.</p>'
: !room ? '<p class="muted">This Video Spin is full for your tier.</p>'
: mine.length ? '<div class="vsgrid">' + mine.map(v => '<label class="vsc"><input type="checkbox" value="' + esc(v.id) + '"><img src="' + esc(v.poster) + '" alt="" loading="lazy"><span>' + esc(v.title) + '</span></label>').join('') + '</div><div class="vsrow" style="margin-top:10px"><button class="btn pri" type="button" id="vsAddMine">Add selected</button><span class="muted">Room for ' + room + ' more.</span></div>'
: '<p class="muted">' + ((D.videos || []).length ? 'All of your videos are already in this spin.' : 'You have no videos on Social Tube yet. Make one on Video App Income and it appears here.') + '</p>')
+ '<h3 class="vsh">Add any member\'s video</h3><p class="muted" style="margin:0 0 8px">Open the video on socialtube.club and paste its address. Its owner gets the views; people who go on to join are credited to you.</p>'
+ (room ? '<div class="vsrow"><input class="field" id="vsLinkIn" maxlength="300" placeholder="https://socialtube.club/watch/..."><button class="btn" type="button" id="vsAddLink">Add</button></div>' : '<p class="muted">This Video Spin is full for your tier.</p>')
+ '</div>';
$('vsCopy').addEventListener('click', () => { const u = linkOf(s); (navigator.clipboard && navigator.clipboard.writeText ? navigator.clipboard.writeText(u) : Promise.reject()).then(() => toast('Link copied'), () => { $('vsLink').select(); toast('Select and copy the link', true); }); });
$('vsPause').addEventListener('click', () => act(() => api('/api/my/rotations/' + s.id, { paused: !s.paused }), s.paused ? 'Resumed' : 'Paused'));
$('vsDel').addEventListener('click', e => { const b = e.currentTarget; if (b.dataset.arm !== '1') { b.dataset.arm = '1'; b.textContent = 'Tap again to delete'; setTimeout(() => { b.dataset.arm = ''; b.textContent = 'Delete'; }, 4000); return; }
act(async () => { await api('/api/my/rotations/' + s.id, { remove: true }); SEL = null; history.replaceState(null, '', '#v'); }, 'Video Spin deleted'); });
box.querySelectorAll('[data-act]').forEach(b => b.addEventListener('click', () => { const a = b.dataset.act, p = '/api/my/rotations/' + s.id + '/dest/' + b.dataset.d;
act(() => api(p, a === 'remove' ? { remove: true } : { active: a === 'resume' }), a === 'remove' ? 'Video removed from this spin' : a === 'resume' ? 'Video resumed' : 'Video paused'); }));
const am = $('vsAddMine'); if (am) am.addEventListener('click', () => { const ids = [...box.querySelectorAll('.vsc input:checked')].map(x => x.value); if (!ids.length) { toast('Tick at least one video.', true); return; }
act(() => api('/api/my/videospins/' + s.id + '/add', { ids }), ids.length === 1 ? 'Video added' : ids.length + ' videos added'); });
const al = $('vsAddLink'); if (al) { const go = () => { const link = $('vsLinkIn').value.trim(); if (!link) { toast('Paste a Social Tube video link first.', true); return; } act(() => api('/api/my/videospins/' + s.id + '/add', { link }), 'Video added'); };
al.addEventListener('click', go); $('vsLinkIn').addEventListener('keydown', e => { if (e.key === 'Enter') go(); }); }
}
async function act(fn, done) { if (BUSY) return; BUSY = true; try { await fn(); if (done) toast(done); await load(true); } catch (e) { toast(e.message, true); } BUSY = false; }
window.VideoSpin = { reload: () => load(true) };
if (/^#v/.test(location.hash)) setTimeout(() => { const b = $('vsw').querySelector('button[data-v="videos"]'); if (b) b.click(); }, 400);
})();
+19 -1
View File
@@ -107,11 +107,20 @@
.bscache{display:block;margin-top:3px;font-size:11px;color:var(--warn)} .bsbreak{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
@media (max-width:900px){.bsr .ml,.st3 .ml{display:inline;color:var(--muted);font-size:11px}.bsr .rw .r,.st3 .rw .r{text-align:left}.bsr .hd,.st3 .hd{display:none}.bsr .rw{grid-template-columns:1fr 1fr}.st3 .rw{grid-template-columns:1fr 1fr 1fr}.st3 .rw>:first-child{grid-column:1/-1}.addg{grid-template-columns:1fr}.bsbreak{grid-template-columns:1fr}}
@media (max-width:760px){.bsr .rw{grid-template-columns:1fr}.tgt{grid-template-columns:1fr}.vsw{padding:8px 10px 0}.vsw button{padding:6px 10px;font-size:14px}}
/* Video Spin (2026-11-22) */
.vsp{padding:18px 20px 28px;max-width:860px}.vshead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:12px}.vshead h2{margin:0;font-size:20px}
.vsrow{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.vsrow .field{flex:1;min-width:200px}
.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}
.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}}
</style>
</head>
<body>
<div id="page">
<div class="vsw" id="vsw" role="tablist" aria-label="Link type"><button type="button" class="on" data-v="links" role="tab">Spin links</button><button type="button" data-v="banners" role="tab">Banner Spins<span class="nw">NEW</span></button></div>
<div class="vsw" id="vsw" role="tablist" aria-label="Link type"><button type="button" class="on" data-v="links" role="tab">Spin links</button><button type="button" data-v="banners" role="tab">Banner Spins<span class="nw">NEW</span></button><button type="button" data-v="videos" role="tab">Video Spins<span class="nw">NEW</span></button></div>
<div class="ws" id="ws">
<div class="list">
<div class="hd"><h2 id="listCount">Links</h2><span class="muted mono" id="listSort">by clicks, 7 days</span></div>
@@ -183,6 +192,14 @@
</div>
</div>
</div>
<div class="ws" id="vsWs" hidden>
<div class="list">
<div class="hd"><h2 id="vsCount">Video Spins</h2><span class="muted mono">by clicks, 7 days</span></div>
<div class="flt" id="vsTier" style="font-size:12px"></div>
<div class="items" id="vsItems"></div>
</div>
<div class="detail" id="vsDetail"></div>
</div>
<div class="ws" id="bsWs" hidden>
<div class="list">
<div class="hd"><h2 id="bsCount">Banner Spins</h2><span class="muted mono" id="bsSort">by views, 30 d</span></div>
@@ -273,5 +290,6 @@
<script src="/assets/cr-shell.js?v=20261115hub"></script>
<script src="/assets/links.js?v=20261111big"></script>
<script src="/assets/banner-spin.js?v=20261114bc"></script>
<script src="/assets/video-spin.js?v=20261122a"></script>
</body>
</html>
+3 -3
View File
@@ -28,9 +28,9 @@ const srcOf = (owner, tpl) => read('sources.json').items.find(x => x.owner === o
try {
await boot();
const rots = read('rotator.json').rotations.filter(r => r.owner === ADMIN);
ok(['nwiap', 'nwls', 'nwdlb', 'nwvbb', 'nwvab', 'nwvas', 'nwypb', 'nwvai', 'nw5x', 'nwdh', 'nwsp', 'nwec'].every(c => rots.some(r => r.code === c)) && rots.length === 12, 'the admin account has the twelve network links', rots.map(r => r.code));
ok(['nwiap', 'nwls', 'nwdlb', 'nwvbb', 'nwvab', 'nwvas', 'nwypb', 'nwvai', 'nwst', 'nw5x', 'nwdh', 'nwsp', 'nwec'].every(c => rots.some(r => r.code === c)) && rots.length === 13, 'the admin account has the thirteen network links', rots.map(r => r.code));
const mineSrc = read('sources.json').items.filter(x => x.owner === ADMIN);
ok(['instantadpay', 'linkspin', 'downlinebanners', 'viralbannerblitz', 'viraladblitz', 'viraladsource', 'yourprogrambuilder', 'videoappincome', '5xyourteam', 'downlinehydra', 'stackpol', 'earnerscorner'].every(t => mineSrc.some(x => x.template === t)) && mineSrc.length === 12, 'and one source per network site', mineSrc.map(x => x.template));
ok(['instantadpay', 'linkspin', 'downlinebanners', 'viralbannerblitz', 'viraladblitz', 'viraladsource', 'yourprogrambuilder', 'videoappincome', 'socialtube', '5xyourteam', 'downlinehydra', 'stackpol', 'earnerscorner'].every(t => mineSrc.some(x => x.template === t)) && mineSrc.length === 13, 'and one source per network site', mineSrc.map(x => x.template));
let r = await go('/r/nwdlb?src=iap&s1=bob&s2=how');
ok(r.status === 302 && /^https:\/\/downlinebanners\.com\/how\?ref=bob$/.test(r.loc), 'nwdlb: lands on /how with ?ref=bob', r);
@@ -66,7 +66,7 @@ try {
ok(read('sources.json').items.filter(x => x.owner === MEM).length === 2, 'an unknown src makes no source');
await stop(); await boot();
ok(read('rotator.json').rotations.filter(x => x.owner === ADMIN).length === 12 && read('sources.json').items.filter(x => x.owner === ADMIN).length === 12, 'a reboot makes nothing twice');
ok(read('rotator.json').rotations.filter(x => x.owner === ADMIN).length === 13 && read('sources.json').items.filter(x => x.owner === ADMIN).length === 13, 'a reboot makes nothing twice');
} catch (e) { fail++; console.error(e); }
finally { await stop(); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
console.log('\n' + pass + ' passed, ' + fail + ' failed'); process.exit(fail ? 1 : 0);
+3 -1
View File
@@ -100,7 +100,7 @@ function pub(r) {
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 = convOf(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,
return { id: r.id, code: r.code, name: r.name, kind: r.kind || '', owner: r.owner, created: r.created, fallback: r.fallback || '', paused: !!r.paused, conversions: conv.length, convBy,
hours: r.hours || null, tz: r.tz || 'visitor', offHours30: hits.filter(h => h.oh && h.ts >= since30 && !h.bot).length, fallbackHealth: r.fallbackHealth || null, sourceId: r.sourceId || '',
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 };
@@ -131,6 +131,7 @@ async function create(owner, body) {
if (!isOwner(owner) && J.db.rotations.filter(r => r.owner === norm(owner)).length >= 100) return { error: 'That is a lot of rotations. Archive some first.' };
let code = newCode(); while (J.db.rotations.some(r => r.code === code)) code = newCode();
const r = { id: (J.db.rotations.reduce((m, x) => Math.max(m, x.id), 0) + 1), owner: norm(owner), name, code, fallback: cleanUrl(body.fallback) || '', destinations: [], created: Date.now(), paused: false, nextDest: 1 };
if (body.kind === 'video') { r.kind = 'video'; if (/^[A-Za-z0-9_.-]{1,40}$/.test(String(body.vref || ''))) r.vref = String(body.vref); } // Video Spin (2026-11-22): set by server.js only, never from a member's request body
J.db.rotations.push(r); J.save(); return { ok: true, rotation: pub(r) };
}
async function update(owner, id, body) {
@@ -194,6 +195,7 @@ async function addDest(owner, id, body, opts) {
if (r.destinations.length >= cap) return { error: 'Up to ' + DEST_MAX + ' destinations per rotation.' };
const w = Math.max(1, Math.min(100, Math.round(Number(body.weight) || 1)));
const d = { id: r.nextDest++, url, label: String(body.label || '').trim().slice(0, 60), weight: w, active: true, added: Date.now() };
if (opts && opts.video) { d.vid = String(opts.video.id); d.poster = String(opts.video.poster || ''); d.vowner = String(opts.video.owner || '').slice(0, 40); } // a Video Spin destination
r.destinations.push(d);
if (opts && opts.defer) return { ok: true, id: d.id }; // bulk import: the caller saves once at the end (rotator.json holds every click, ~18 MB; one write per destination would stall the app)
J.save(); return { ok: true, rotation: pub(r) };
+79 -5
View File
@@ -249,6 +249,27 @@ async function bannerFacts(email) {
// Tool tiers for spin links and pages (Marty 2026-10-21: "cap this ... and there needs to be more of an incentive for
// upgrading"): free 3, Starter (any package of your own) 10, Builder (2 qualifying buyers) 50, Leader (5) unlimited with a
// fair-use ceiling. Existing items above a cap are never removed; only new ones wait for the upgrade.
// Video Spin (2026-11-22). Limits by tool tier, mirroring Banner Spin. The picker and the play counts come from Video App Income over
// signed calls: X-Ls-Ts + X-Ls-Sig = HMAC-SHA256(NETCONV_SECRET_VAI, 'vspin.v1.' + ts + '\n' + raw). VAI_URL defaults to the live site.
const VS_LIMITS = { free: { spins: 0, videos: 0 }, starter: { spins: 2, videos: 5 }, builder: { spins: 5, videos: 15 }, leader: { spins: 10, videos: 25 } };
const VAI_URL = () => String(process.env.VAI_URL || 'https://videoappincome.com').trim().replace(/\/+$/, '');
const vsSecret = () => String(process.env.NETCONV_SECRET_VAI || '').trim();
const vsOn = () => vsSecret().length >= 32;
async function vaiCall(op, body) {
const raw = JSON.stringify(body), ts = String(Date.now());
const r = await fetch(VAI_URL() + '/api/partner/ls/' + op, { method: 'POST', headers: { 'content-type': 'application/json', 'x-ls-ts': ts, 'x-ls-sig': crypto.createHmac('sha256', vsSecret()).update('vspin.v1.' + ts + '\n' + raw).digest('hex') }, body: raw, signal: AbortSignal.timeout(12000) });
return { s: r.status, j: await r.json().catch(() => ({})) };
}
// 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; };
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;
if (!vsOn()) return { member: null, videos: [] };
let username = ''; try { const a = await accounts.byEmail(e); username = (a && a.username) || ''; } catch (er) {}
const x = await vaiCall('videos', { email: e, username }); if (x.s !== 200) throw new Error('vai ' + x.s);
const v = { member: x.j.member || null, videos: Array.isArray(x.j.videos) ? x.j.videos : [] }; vsMineCache.set(e, { ts: Date.now(), v }); return v;
}
const TOOL_TIERS = { free: { label: 'Free', max: 3, need: '' }, starter: { label: 'Starter', max: 10, need: 'any package of your own' },
builder: { label: 'Builder', max: 50, need: 'level 2 open (2 qualifying buyers)' }, leader: { label: 'Leader', max: 500, unlimited: true, need: 'level 3 open (5 qualifying buyers)' } };
const TOOL_ORDER = ['free', 'starter', 'builder', 'leader'];
@@ -950,7 +971,7 @@ function readRaw(req, maxBytes) {
// the image pixel cannot read the thank-you page's address, but a browser that sends the full referrer hands it to us
function refClickId(req) { try { const r = new URL(String(req.headers.referer || '')); const v = r.searchParams.get('lsclk') || r.searchParams.get('lsid') || ''; return /^[a-z0-9]{6,24}$/i.test(v) ? v : ''; } catch (e) { return ''; } }
// the sites of the network a click id may travel to (the landing tag's list, 2026-11-07): this site, InstantAdPay, its share domains
const NETWORK_HOSTS = String(process.env.NETWORK_HOSTS || 'instantadpay.com,instantadpay.link,ctbgo.com,mylinehq.com,videoappincome.com,clickvidpro.com').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
const NETWORK_HOSTS = String(process.env.NETWORK_HOSTS || 'instantadpay.com,instantadpay.link,ctbgo.com,mylinehq.com,videoappincome.com,clickvidpro.com,socialtube.club').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
function networkHosts() { return [...new Set([String(SITE_HOST || '').toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '')].concat(NETWORK_HOSTS))].filter(Boolean); }
function clickCookie(id) { return 'ls.clk=' + id + '; Path=/; Max-Age=2592000; ' + (IS_PROD ? 'SameSite=None; Secure' : 'SameSite=Lax'); }
// an ad click: record a click id for the campaign and append ?lsclk=<id> to the target (existing params kept, an lsclk
@@ -2801,15 +2822,65 @@ const server = http.createServer(async (req, res) => {
return json(res, r.error ? 400 : 200, r);
}
// -- the rotator (LinkSpin core tool)
// ── Video Spin (Marty 2026-11-22): one short link that rotates through video pages on Social Tube. It IS a spin link (rotator.js, kind
// 'video'), so pausing, weights, schedules, health checks, sources and reports are the rotator's own. What is new: the videos are picked,
// not pasted (the member's own from Video App Income, or any member's by its Social Tube link, checked there), and the report adds plays
// from Video App Income. Limits mirror Banner Spin: Starter 2 x 5, Builder 5 x 15, Leader 10 x 25.
if (p === '/api/my/videospins' && req.method === 'GET') {
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
const sc = siteConfig(); const hosts = String(sc.linkDomains || '').split(',').map(x => x.trim()).filter(Boolean);
const t = await toolTier(s.email), lim = VS_LIMITS[t.key] || VS_LIMITS.free; let mine = { member: null, videos: [] }, vaiError = '';
try { mine = await vsMine(s.email); } catch (e) { vaiError = 'Video App Income is not answering right now. Your Video Spins still work.'; }
return json(res, 200, { spins: (await rotator.list(s.email)).filter(x => x.kind === 'video'), hosts: hosts.length ? hosts : [SITE_HOST], tier: t, limits: lim, member: mine.member, videos: mine.videos, vaiError, on: vsOn() }, { 'Cache-Control': 'no-store' });
}
if (p === '/api/my/videospins' && req.method === 'POST') {
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
if (!vsOn()) return json(res, 503, { error: 'Video Spins are not switched on yet.' });
const b = await readBody(req), t = await toolTier(s.email), lim = VS_LIMITS[t.key] || VS_LIMITS.free, have = (await rotator.list(s.email)).filter(x => x.kind === 'video').length;
if (!lim.spins) return json(res, 400, { error: 'Video Spins start at the Starter tier (any package of your own).', tier: t });
if (have >= lim.spins) return json(res, 400, { error: 'Your ' + t.label + ' tier holds ' + lim.spins + ' Video Spins and you have ' + have + '.', tier: t });
let mine = { member: null }; try { mine = await vsMine(s.email); } catch (e) {}
const ref = mine.member ? mine.member.username || mine.member.id : '';
const r = await rotator.create(s.email, { name: b.name, fallback: 'https://socialtube.club/' + (ref ? '?ref=' + encodeURIComponent(ref) : ''), kind: 'video', vref: ref });
return json(res, r.error ? 400 : 200, r);
}
m = /^\/api\/my\/videospins\/(\d+)\/add$/.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.' });
if (!vsOn()) return json(res, 503, { error: 'Video Spins are not switched on yet.' });
const rot = (await rotator.list(s.email)).find(x => x.id === Number(m[1]) && x.kind === 'video'); if (!rot) return json(res, 404, { error: 'No such Video Spin.' });
const b = await readBody(req), t = await toolTier(s.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 }
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(s.email); for (const id of ids) { const vd = mine.videos.find(x => x.id === id); if (vd) picks.push(vd); } if (picks.length !== ids.length) return json(res, 400, { 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 json(res, 400, { error: (x.j && x.j.error) || 'That video link could not be checked.' }); picks.push(x.j.video); }
} catch (e) { return json(res, 502, { error: 'Video App Income is not answering right now. Nothing was added. Try again in a minute.' }); }
if (!picks.length) return json(res, 400, { 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 json(res, 400, { 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 json(res, 400, { 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(s.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 json(res, 400, out); }
return json(res, 200, { ok: true, added: fresh.length, rotation: out.rotation });
}
m = /^\/api\/my\/videospins\/(\d+)\/plays$/.exec(p);
if (m && req.method === 'GET') { // what happened on the video pages themselves, counted by Video App Income for this Video Spin's code
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
const rot = (await rotator.list(s.email)).find(x => x.id === Number(m[1]) && x.kind === 'video'); if (!rot) return json(res, 404, { error: 'No such Video Spin.' });
try { const x = await vaiCall('stats', { code: rot.code, ids: rot.destinations.map(d => d.vid).filter(Boolean) }); return json(res, 200, { ok: true, plays: (x.s === 200 && x.j.stats) || {} }, { 'Cache-Control': 'no-store' }); }
catch (e) { return json(res, 200, { ok: true, plays: {}, vaiError: 'Play counts are not available right now.' }); }
}
if (p === '/api/my/rotations' && req.method === 'GET') {
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
const sc = siteConfig(); const hosts = String(sc.linkDomains || '').split(',').map(x => x.trim()).filter(Boolean);
return json(res, 200, { rotations: await rotator.list(s.email), hosts: hosts.length ? hosts : [SITE_HOST], tier: await toolTier(s.email) }, { 'Cache-Control': 'no-store' });
return json(res, 200, { rotations: (await rotator.list(s.email)).filter(x => !x.kind), hosts: hosts.length ? hosts : [SITE_HOST], tier: await toolTier(s.email) }, { 'Cache-Control': 'no-store' }); // Video Spins have their own screen and limits
}
if (p === '/api/my/rotations' && req.method === 'POST') {
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
{ const t = await toolTier(s.email); const have = (await rotator.list(s.email)).length; if (have >= t.max) return json(res, 400, { error: toolCapError('spin links', have, t), tier: t }); }
const r = await rotator.create(s.email, await readBody(req)); return json(res, r.error ? 400 : 200, r);
{ const t = await toolTier(s.email); const have = (await rotator.list(s.email)).filter(x => !x.kind).length; if (have >= t.max) return json(res, 400, { error: toolCapError('spin links', have, t), tier: t }); }
{ const b0 = await readBody(req); const r = await rotator.create(s.email, { name: b0.name, fallback: b0.fallback }); return json(res, r.error ? 400 : 200, r); } // only name and fallback are taken from the member
}
m = /^\/api\/my\/rotations\/(\d+)$/.exec(p);
if (m && req.method === 'POST') {
@@ -2819,12 +2890,15 @@ const server = http.createServer(async (req, res) => {
m = /^\/api\/my\/rotations\/(\d+)\/dest$/.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.' });
if ((await rotator.list(s.email)).some(x => x.id === Number(m[1]) && x.kind === 'video')) return json(res, 400, { error: 'Add videos to a Video Spin from its own screen.' });
const r = await rotator.addDest(s.email, m[1], await readBody(req)); return json(res, r.error ? 400 : 200, r);
}
m = /^\/api\/my\/rotations\/(\d+)\/dest\/(\d+)$/.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 r = await rotator.updateDest(s.email, m[1], m[2], await readBody(req)); return json(res, r.error ? 400 : 200, r);
const db0 = await readBody(req);
if (db0 && db0.url != null && (await rotator.list(s.email)).some(x => x.id === Number(m[1]) && x.kind === 'video')) return json(res, 400, { error: 'A video in a Video Spin keeps its own address. Remove it and add another instead.' });
const r = await rotator.updateDest(s.email, m[1], m[2], db0); return json(res, r.error ? 400 : 200, r);
}
m = /^\/api\/my\/rotations\/(\d+)\/stats$/.exec(p);
if (m && req.method === 'GET') {
+1 -1
View File
@@ -143,7 +143,7 @@ function meta(owner) { const m = {}; for (const s of mine(owner)) m[s.id] = { na
// source for that site, made from the network catalog template the first time it is needed. Only network templates qualify.
const NET_SRC = { iap: 'instantadpay', instantadpay: 'instantadpay', linkspin: 'linkspin', dlb: 'downlinebanners', downlinebanners: 'downlinebanners',
vbb: 'viralbannerblitz', viralbannerblitz: 'viralbannerblitz', stackpol: 'stackpol', earnerscorner: 'earnerscorner',
dh: 'downlinehydra', downlinehydra: 'downlinehydra', vab: 'viraladblitz', viraladblitz: 'viraladblitz', vas: 'viraladsource', viraladsource: 'viraladsource', ypb: 'yourprogrambuilder', yourprogrambuilder: 'yourprogrambuilder', fivex: '5xyourteam', '5xyourteam': '5xyourteam', vai: 'videoappincome', videoappincome: 'videoappincome' };
dh: 'downlinehydra', downlinehydra: 'downlinehydra', vab: 'viraladblitz', viraladblitz: 'viraladblitz', vas: 'viraladsource', viraladsource: 'viraladsource', ypb: 'yourprogrambuilder', yourprogrambuilder: 'yourprogrambuilder', fivex: '5xyourteam', '5xyourteam': '5xyourteam', vai: 'videoappincome', videoappincome: 'videoappincome', st: 'socialtube', socialtube: 'socialtube' };
function networkTemplate(src) { const k = NET_SRC[String(src || '').trim().toLowerCase()]; const t = k ? template(k) : null; return t && t.source === 'network' ? t : null; }
function networkSource(owner, src) {
const t = networkTemplate(src); if (!t || !owner) return null;