diff --git a/chatbot.js b/chatbot.js index 110e38b..a3112fc 100644 --- a/chatbot.js +++ b/chatbot.js @@ -25,7 +25,7 @@ let DATA_DIR = null; let chain = null; const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro'; const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b'; -const KNOWLEDGE_DATE = '2026-10-24'; // the day the CANNED answers and FACTS below were last checked against the site +const KNOWLEDGE_DATE = '2026-10-25'; // the day the CANNED answers and FACTS below were last checked against the site function init(opts) { if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); } @@ -41,7 +41,7 @@ const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)| const CANNED = [ { id: 'refuel', title: 'Monthly Refuel streak and Pit Stops', q: ['What is my refuel day?', 'How does the refuel streak work?', 'What is a Pit Stop?', 'How much should I spend each month?'], tags: ['refuel', 'streak', 'pit stop', 'twin engine', 'bonus credits'], re: /(refuel(ing)? (day|streak|bonus|window)|my refuel|monthly refuel|pit ?stop|twin engine|both engines|refuel streak|streak bonus|free miss)/i, - a: 'The Monthly Refuel streak rewards members who refuel their ads every month. A counted refuel is a new package of $20 or more on InstantAdPay, or $25 or more on LinkSpin, bought by one of your own positions. Your first one sets your refuel day; the next is due 30 days later, the window opens 5 days before that day and there is a 5-day grace after it (Central time). Each refuel adds bonus ad credits on the site where you bought: month 1 +10%, month 2 +15%, month 3 +20%, month 4 and up +25%. Refuel BOTH sites in the same cycle and each gets +15%, +20%, +30% or +40% (the first site is topped up to that rate), plus a 100-credit Featured bonus on InstantAdPay from month 4 (enough for two Featured days and more). Either site alone keeps your streak going; both sites in a cycle is the bigger bonus. The bonus stacks on Five Dollar Friday and Wired Wednesday. Another $20+/$25+ package on a site you already refueled this cycle, before your next window opens, is a Pit Stop: half your current rate, once per site per cycle, and it does not count as the refuel. Miss the grace and the streak starts again, except for one free miss a year. Badges at your first refuel and at 3, 6 and 12 months. Each counted refuel also unlocks the Refuel Kit for that month: members-only banners (728x90, 300x250, 468x60, 160x600 and 1200x630) with your @name and a QR code to your own link drawn on them, in the Ads screen (with a Load into my Banner Spin button); they stay yours after the month, a 3-month streak adds an animated version and 6 months a custom-banners credit. Your first counted refuel also opens the Engine Room panel on the Ads screen: three plain dials (fuel left on both sites against this cycle’s refuel with days left at your burn, clicks this week with clicks per 1,000 credits, goals this month against a goal you set), warning lights, six part lights with setup links and one next move. Your refuel day, streak, next bonus and Pit Stop status are on the Refuel card on your Credits screen. Buy here: https://linkspin.app/credits. The full guide, with the flow step by step: https://linkspin.app/refuel. Bonus credits are ad credits that buy delivery, never cash, and no income is guaranteed.' }, + a: 'The Monthly Refuel streak rewards members who refuel their ads every month. A counted refuel is a new package of $20 or more on InstantAdPay, or $25 or more on LinkSpin, bought by one of your own positions. Your first one sets your refuel day; the next is due 30 days later, the window opens 5 days before that day and there is a 5-day grace after it (Central time). Each refuel adds bonus ad credits on the site where you bought: month 1 +10%, month 2 +15%, month 3 +20%, month 4 and up +25%. Refuel BOTH sites in the same cycle and each gets +15%, +20%, +30% or +40% (the first site is topped up to that rate), plus a 100-credit Featured bonus on InstantAdPay from month 4 (enough for two Featured days and more). Either site alone keeps your streak going; both sites in a cycle is the bigger bonus. The bonus stacks on Five Dollar Friday and Wired Wednesday. Another $20+/$25+ package on a site you already refueled this cycle, before your next window opens, is a Pit Stop: half your current rate, once per site per cycle, and it does not count as the refuel. Miss the grace and the streak starts again, except for one free miss a year. Badges at your first refuel and at 3, 6 and 12 months. Each counted refuel also unlocks the Refuel Kit for that month: members-only banners (728x90, 300x250, 468x60, 160x600 and 1200x630) with your @name and a QR code to your own link drawn on them, in the Ads screen (with a Load into my Banner Spin button); they stay yours after the month, a 3-month streak adds an animated version and 6 months a custom-banners credit. Your first counted refuel also opens the Engine Room panel on the Ads screen: three plain dials (fuel left on both sites against this cycle’s refuel with days left at your burn, clicks this week with clicks per 1,000 credits, goals this month against a goal you set), warning lights, six part lights with setup links and one next move. Your refuel day, streak, next bonus and Pit Stop status are on the Refuel card on your Credits screen: Refuel in the menu takes you straight there (https://linkspin.app/credits#refuel), and packages that count are marked counts for Refuel. Buy here: https://linkspin.app/credits#buy. The full guide, with the flow step by step: https://linkspin.app/refuel. Bonus credits are ad credits that buy delivery, never cash, and no income is guaranteed.' }, { id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a ticket?'], tags: ['support', 'help', 'ticket', 'contact'], re: SUPPORT_RE, handoff: true, a: 'Open Help in your Control Room (' + SITE_URL + '/help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use ' + SITE_URL + '/support. You can also tap "Send this to support" below and I will pass this chat along.' }, @@ -153,7 +153,7 @@ function seeds() { // ---- facts for the AI fallback ---- // the refuel fact follows the refuelStreak switch: while it is off the assistant says it is not live yet (2026-10-24) let REFUEL_ON = () => false; -function refuelFact() { return REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'; } +function refuelFact() { return REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package. ROUTES (2026-10-25): LinkSpin menu item Refuel = https://linkspin.app/credits#refuel (the Refuel panel, scrolled to and highlighted); packages of $25+ there are marked counts for Refuel; https://linkspin.app/credits#buy = the package picker; https://linkspin.app/ads#engine = LinkSpin Engine Room. InstantAdPay Engine Room = https://instantadpay.com/my#engine; its Set up conversion tracking opens https://instantadpay.com/my#conversions (Campaigns > Conversion tracking card, same goals LinkSpin counts). Engine Room links that cross to LinkSpin (Banner Spin, spin link, page, testing, refuel LinkSpin) open LinkSpin with a note at the top naming the job, Step 1, a guide link and Back to InstantAdPay; same email signs in on both.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'; } const REFUEL_OFF_ANSWER = 'The Monthly Refuel streak (bonus ad credits for refueling every month, more when you refuel both InstantAdPay and LinkSpin) is built but not switched on yet, so nothing counts toward it today. The bonuses running now are Five Dollar Friday and Wired Wednesday on InstantAdPay. When the streak goes live, your Refuel card will show your refuel day.'; function systemPrompt(kbBlock) { 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. diff --git a/engine.js b/engine.js index 385a509..538b53b 100644 --- a/engine.js +++ b/engine.js @@ -11,9 +11,16 @@ const DAY = 86400000; const n0 = v => (typeof v === 'number' && isFinite(v) ? v : Number(v) || 0); const LINKS = { - iapBuy: 'https://instantadpay.com/my#buy', iapCampaigns: 'https://instantadpay.com/my#campaigns', iapTracking: 'https://instantadpay.com/my#campaigns', - lsBuy: 'https://linkspin.app/credits', lsAds: 'https://linkspin.app/ads', lsLinks: 'https://linkspin.app/links', lsPages: 'https://linkspin.app/pages', lsConv: 'https://linkspin.app/conversions', + iapBuy: 'https://instantadpay.com/my#buy', iapCampaigns: 'https://instantadpay.com/my#campaigns', iapTracking: 'https://instantadpay.com/my#conversions', + lsBuy: 'https://linkspin.app/credits#buy', lsAds: 'https://linkspin.app/ads', lsLinks: 'https://linkspin.app/links', lsBanner: 'https://linkspin.app/links#b', lsPages: 'https://linkspin.app/pages', lsConv: 'https://linkspin.app/conversions', }; +// 2026-10-25 (Marty: "the flow from InstantAdPay to LinkSpin is confusing"): every link points at the screen on the site the +// member is ON when that site can do the job (buy, campaigns, conversion goals: InstantAdPay's Campaigns > Conversion +// tracking card writes the same LinkSpin goals). Only LinkSpin-only tools (Banner Spin, spin links, pages) cross over, and +// engine-room.js tags those links with ?from=&task= so LinkSpin shows an arrival strip with the first step. +const linksFor = site => site === 'linkspin' + ? { buy: LINKS.lsBuy, campaigns: LINKS.lsAds, tracking: LINKS.lsConv } + : { buy: LINKS.iapBuy, campaigns: LINKS.iapCampaigns, tracking: LINKS.iapTracking }; const ACTIVE = new Set(['active', 'paused']); // credits a day across recent campaigns: what each delivered over the days it has run (30 at most), summed @@ -26,7 +33,7 @@ function burnPerDay(camps, now) { } return b; } -function part(state, label, note, link) { return { state, label, note, link }; } +function part(state, label, note, link, key) { return { state, label, note, link, key }; } function build(o) { const now = o.now || Date.now(); @@ -36,6 +43,7 @@ function build(o) { const camps = sites.flatMap(f => (f.campaigns || []).map(c => Object.assign({ site: f.site }, c))); const recent = camps.filter(c => ACTIVE.has(c.status) || now - n0(c.created) <= 30 * DAY || c.status === 'out'); const locked = !rf.started; + const here = o.site === 'linkspin' ? 'linkspin' : 'iap', L = linksFor(here); // ---- dial 1: fuel left vs this cycle's refuel ---- const left = sites.reduce((s, f) => s + n0(f.credits && f.credits.available) + n0(f.credits && f.credits.inCampaigns), 0); const cy = rf.cycle || null; @@ -67,34 +75,36 @@ function build(o) { ]; // ---- the six parts ---- const P = (lsF && lsF.parts) || {}; - const pFuel = !camps.length ? part('grey', 'Fuel', 'no ads yet', LINKS.iapCampaigns) - : out.length && !running.length ? part('amber', 'Fuel', 'nothing running', LINKS.iapCampaigns) - : low.length || (daysLeft != null && daysLeft < 5) ? part('amber', 'Fuel', daysLeft != null && daysLeft < 5 ? 'about ' + daysLeft + ' days left at your burn' : 'an ad is running low', LINKS.iapBuy) - : running.length ? part('green', 'Fuel', running.length + ' ad' + (running.length === 1 ? '' : 's') + ' running', LINKS.iapCampaigns) : part('amber', 'Fuel', 'nothing running', LINKS.iapCampaigns); - const pick = (k, label, link) => { const x = P[k]; return x ? part(x.state, label, x.note, link) : part('grey', label, lsF ? 'not set up' : 'LinkSpin did not answer', link); }; - const parts = [pFuel, pick('bannerSpin', 'Banner spin', LINKS.lsLinks), pick('spinLink', 'Spin link', LINKS.lsLinks), pick('page', 'Page', LINKS.lsPages), pick('testing', 'Testing', LINKS.lsLinks), - lsF ? (n0(lsF.goalsCount) === 0 ? part('grey', 'Conversion tracking', 'no goal set', LINKS.lsConv) : n0(lsF.conv30) === 0 ? part('amber', 'Conversion tracking', 'no conversions tracked yet', LINKS.lsConv) : part('green', 'Conversion tracking', n0(lsF.conv30) + ' in 30 days', LINKS.lsConv)) - : part('grey', 'Conversion tracking', 'LinkSpin did not answer', LINKS.iapTracking)]; + const pFuel = !camps.length ? part('grey', 'Fuel', 'no ads yet', L.campaigns, 'ads') + : out.length && !running.length ? part('amber', 'Fuel', 'nothing running', L.campaigns, 'ads') + : low.length || (daysLeft != null && daysLeft < 5) ? part('amber', 'Fuel', daysLeft != null && daysLeft < 5 ? 'about ' + daysLeft + ' days left at your burn' : 'an ad is running low', L.buy, 'refuel') + : running.length ? part('green', 'Fuel', running.length + ' ad' + (running.length === 1 ? '' : 's') + ' running', L.campaigns, 'ads') : part('amber', 'Fuel', 'nothing running', L.campaigns, 'ads'); + const pick = (k, label, link, key) => { const x = P[k]; return x ? part(x.state, label, x.note, link, key) : part('grey', label, lsF ? 'not set up' : 'LinkSpin did not answer', link, key); }; + const parts = [pFuel, pick('bannerSpin', 'Banner spin', LINKS.lsBanner, 'bannerspin'), pick('spinLink', 'Spin link', LINKS.lsLinks, 'spinlink'), pick('page', 'Page', LINKS.lsPages, 'page'), pick('testing', 'Testing', LINKS.lsLinks, 'testing'), + lsF ? (n0(lsF.goalsCount) === 0 ? part('grey', 'Conversion tracking', 'no goal set', L.tracking, 'conversions') : n0(lsF.conv30) === 0 ? part('amber', 'Conversion tracking', 'no conversions tracked yet', L.tracking, 'conversions') : part('green', 'Conversion tracking', n0(lsF.conv30) + ' in 30 days', L.tracking, 'conversions')) + : part('grey', 'Conversion tracking', 'LinkSpin did not answer', L.tracking, 'conversions')]; // ---- one next move ---- const per1000 = c => n0(c.delivered) >= 200 ? n0(c.clicks) / n0(c.delivered) * 1000 : null; const ranked = running.filter(c => per1000(c) != null).sort((a, b) => per1000(b) - per1000(a)); const linkFor = c => c.site === 'linkspin' ? LINKS.lsAds : LINKS.iapCampaigns; const availAll = sites.reduce((s, f) => s + n0(f.credits && f.credits.available), 0); let next; - if (locked) next = { key: 'start', label: 'Refuel to start your engine', why: 'Your first counted refuel ($' + (rf.minUsd ? rf.minUsd.iap : 20) + '+ here or $' + (rf.minUsd ? rf.minUsd.linkspin : 25) + '+ on LinkSpin) starts the streak and lights this room.', link: LINKS.iapBuy }; - else if (rf.windowOpen) next = { key: 'refuel', label: 'Refuel now', why: 'Your refuel window is open: +' + rf.next.single + '% on one site, +' + rf.next.both + '% on each with both.', link: LINKS.iapBuy }; + const mIap = rf.minUsd ? rf.minUsd.iap : 20, mLs = rf.minUsd ? rf.minUsd.linkspin : 25; + const firstWhy = here === 'linkspin' ? 'A package of $' + mLs + ' or more here (or $' + mIap + '+ on InstantAdPay) starts the streak and lights this room.' : 'A package of $' + mIap + ' or more here (or $' + mLs + '+ on LinkSpin) starts the streak and lights this room.'; + if (locked) next = { key: 'start', label: 'Refuel to start your engine', why: firstWhy, link: L.buy, guide: '/refuel' }; + else if (rf.windowOpen) next = { key: 'refuel', label: 'Refuel now', why: 'Your refuel window is open: +' + rf.next.single + '% on one site, +' + rf.next.both + '% on each with both. A $' + (here === 'linkspin' ? mLs : mIap) + '+ package here counts.', link: L.buy, guide: '/refuel' }; else if (out.length && !running.length && availAll >= 100) next = { key: 'relaunch', label: 'Relaunch an ad', why: 'Nothing is running and you have ' + Math.round(availAll).toLocaleString('en-US') + ' credits free.', link: linkFor(out[0]) }; - else if (daysLeft != null && daysLeft < 5) next = { key: 'pitstop', label: 'Top up' + (rf.pitStop && (rf.pitStop.iap || rf.pitStop.linkspin) ? ' (Pit Stop +' + rf.pitStop.pct + '%)' : ''), why: 'About ' + daysLeft + ' days of fuel left at your current burn.', link: LINKS.iapBuy }; + else if (daysLeft != null && daysLeft < 5) next = { key: 'pitstop', label: 'Top up' + (rf.pitStop && (rf.pitStop.iap || rf.pitStop.linkspin) ? ' (Pit Stop +' + rf.pitStop.pct + '%)' : ''), why: 'About ' + daysLeft + ' days of fuel left at your current burn.', link: L.buy }; else if (low.length) { const best = low.slice().sort((a, b) => (per1000(b) || 0) - (per1000(a) || 0))[0]; next = { key: 'topup', label: 'Top up the winner', why: '"' + (best.name || 'your ad') + '" is past 80% of its budget.', link: linkFor(best) }; } - else if (parts[5].state === 'grey') next = { key: 'tracking', label: 'Set up conversion tracking', why: 'Count signups and sales back to the ad that sent them.', link: parts[5].link }; - else if (parts[1].state === 'grey') next = { key: 'bannerspin', label: 'Make a Banner Spin', why: 'Test up to 5 banners in one ad slot and let the winner show.', link: LINKS.lsLinks }; - else if (parts[4].state !== 'green') next = { key: 'testing', label: 'Test A against B', why: 'Add a second page to your spin link so the rotation can pick a winner.', link: LINKS.lsLinks }; + else if (parts[5].state === 'grey') next = { key: 'tracking', label: 'Set up conversion tracking', why: here === 'linkspin' ? 'Count signups and sales back to the ad that sent them. Step 1: add a goal, then paste its two snippets on your pages.' : 'Count signups and sales back to the ad that sent them. Step 1: add a goal under Campaigns > Conversion tracking, then paste its two snippets on your pages.', link: parts[5].link, guide: '/conversion-tracking' }; + else if (parts[1].state === 'grey') next = { key: 'bannerspin', label: 'Make a Banner Spin', why: 'Test up to 5 banners in one ad slot and let the winner show.' + (here === 'linkspin' ? '' : ' Banner Spin is a LinkSpin tool: the same email signs you in there.'), link: LINKS.lsBanner }; + else if (parts[4].state !== 'green') next = { key: 'testing', label: 'Test A against B', why: 'Add a second page to your spin link so the rotation can pick a winner.' + (here === 'linkspin' ? '' : ' Spin links live on LinkSpin: the same email signs you in there.'), link: LINKS.lsLinks }; else if (ranked.length >= 2 && per1000(ranked[0]) > per1000(ranked[ranked.length - 1]) * 1.5) { const worst = ranked[ranked.length - 1]; next = { key: 'cut', label: 'Cut the loser', why: '"' + (worst.name || 'an ad') + '" brings the fewest clicks per 1,000 credits. Pause it and move the credits to "' + (ranked[0].name || 'your best ad') + '".', link: linkFor(worst) }; } - else next = { key: 'cruise', label: 'Keep it running', why: 'Every part is lit. Check again on your refuel day.', link: LINKS.iapCampaigns }; + else next = { key: 'cruise', label: 'Keep it running', why: 'Every part is lit. Check again on your refuel day.', link: L.campaigns }; return { on: true, locked, fuel, clicks, goals, streak: { active: !!rf.active, months: rf.streak || 0, best: rf.best || 0, refuelDay: rf.refuelDayLabel || null, graceEnd: rf.graceLabel || null, windowOpen: !!rf.windowOpen, next: rf.next || null, pitStop: rf.pitStop || null, freeMiss: rf.freeMiss || null, both: !!(cy && cy.both), note: streakNote(rf, cy) }, - warnings, parts, next, sites: { iap: !!(o.iap && o.iap.ok), linkspin: !!(o.ls && o.ls.ok) }, at: now, + warnings, parts, next, site: here, sites: { iap: !!(o.iap && o.iap.ok), linkspin: !!(o.ls && o.ls.ok) }, at: now, }; } diff --git a/public/ads.html b/public/ads.html index 0f5e6df..c174ec0 100644 --- a/public/ads.html +++ b/public/ads.html @@ -74,9 +74,9 @@ - + - - + + diff --git a/public/assets/cr-shell.js b/public/assets/cr-shell.js index 0c61dc6..e4f8c01 100644 --- a/public/assets/cr-shell.js +++ b/public/assets/cr-shell.js @@ -13,6 +13,7 @@ window.CR = (function () { ['zones', 'Zones', '/zones', ''], ['ads', 'Ads', '/ads', ''], ['credits', 'Credits', '/credits', ''], + ['refuel', 'Refuel', '/credits#refuel', ''], // Monthly Refuel panel on Credits (Marty 2026-10-25: no refuel option in the menu) ['reports', 'Reports', '/reports', ''], ['conversions', 'Conversions', '/conversions', ''], // conversion pixel goals (2026-10-23) ['team', 'Team', '/team', ''], @@ -26,8 +27,43 @@ window.CR = (function () { ]; // screens not built yet fall back to the classic dashboard pane so nothing is a dead end const FALLBACK = {}; // the classic /my dashboard is retired (2026-10-08); its leftover panes live at /tools - const BUILT = new Set(['links', 'sources', 'pages', 'zones', 'ads', 'credits', 'reports', 'conversions', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile', 'help']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11); Help = support tickets (2026-10-16) + const BUILT = new Set(['links', 'sources', 'pages', 'zones', 'ads', 'credits', 'refuel', 'reports', 'conversions', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile', 'help']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11); Help = support tickets (2026-10-16) let ME = null, toastT; + // Deep links (2026-10-25): /credits#refuel, /credits#buy and /ads#engine scroll to their panel once it has loaded (and any + // sign-in or sponsor pop-up is closed) and flash it, so a button that says "Refuel" lands ON the Refuel panel. + const ANCHOR = { refuel: 'rfPanel', buy: 'buyPanel', engine: 'erPanel', kit: 'rkPanel' }; + function focusAnchor() { + const id = ANCHOR[location.hash.slice(1)]; if (!id) return; + const t0 = Date.now(); + const tick = () => { + const el = $(id); + if (!el || el.hidden || !el.offsetParent || document.querySelector('.modal-back')) { if (Date.now() - t0 < 90000) setTimeout(tick, 400); return; } + el.scrollIntoView({ behavior: 'smooth', block: 'start' }); + el.classList.remove('cr-flash'); void el.offsetWidth; el.classList.add('cr-flash'); + // panels above it (packages, purchases) can still be loading and push it down, mostly on phones: settle once more + setTimeout(() => { const r = el.getBoundingClientRect(); if (Math.abs(r.top) > 60) el.scrollIntoView({ block: 'start' }); }, 1600); + }; + setTimeout(tick, 200); + } + // Arrival strip (2026-10-25, Marty: "it took me to LinkSpin, but I really don't know how to pick up from there"): a link from + // InstantAdPay carries ?from=iap&task=; the screen opens with one line naming the job, its first step, a guide and the way back. + const ARRIVE = { + refuel: ['refuel LinkSpin', 'pick a package of $25 or more (marked "counts for Refuel") under Buy a package, then press Buy. It counts toward the same streak as InstantAdPay.', '/refuel', 'How the Refuel streak works'], + conversions: ['set up conversion tracking', 'press Add a goal and name it, for example subscriber or sale. Then paste its two snippets on your pages.', '/conversion-tracking', 'Step-by-step setup guide'], + bannerspin: ['make a Banner Spin', 'press + New Banner Spin, pick a banner size and add up to 5 banners. LinkSpin keeps showing the one that gets clicked.'], + spinlink: ['make a spin link', 'press + New spin and paste the page you promote. You get one short link to use in your ads.'], + testing: ['test A against B', 'open your spin link and add a second page under Destinations (or a second banner to a Banner Spin). The rotation picks the winner.'], + page: ['build a page', 'press + New page, fill it in and publish it. Then add it to a spin link.'], + ads: ['check your LinkSpin ads', 'your LinkSpin ads are listed on this screen. Open the one you came for to top it up or relaunch it.'], + }; + const qp = (() => { try { return new URLSearchParams(location.search); } catch (e) { return new URLSearchParams(''); } })(); + const ARR = qp.get('from') === 'iap' ? (ARRIVE[qp.get('task')] || ['carry on from InstantAdPay', 'use the menu on the left. Everything here signs in with the same email.']) : null; + function arriveStrip() { + if (!ARR || $('crArrive')) return ''; + if (!document.getElementById('crArriveCss')) { const st = document.createElement('style'); st.id = 'crArriveCss'; st.textContent = '.arrive{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;margin:12px 24px 0;padding:10px 14px;border:1px solid var(--sig,#ff6a1a);border-radius:8px;background:#FFF8F2;font-size:13.5px;line-height:1.45}.arrive .grow{flex:1 1 auto}.arrive button{border:0;background:none;font-size:18px;line-height:1;cursor:pointer;color:inherit;padding:0 2px}@media (max-width:900px){.arrive{margin:10px 16px 0}}.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); } + return '
You came from InstantAdPay to ' + esc(ARR[0]) + '. Sign in with the same email you use on InstantAdPay, then Step 1: ' + esc(ARR[1]) + + (ARR[2] ? ' ' + esc(ARR[3]) + '' : '') + 'Back to InstantAdPay
'; + } // Expired session (Marty 2026-10-23: "told me to sign in but never redirected me"): sessions last 24 h, and a screen // left open past that got 'Sign in first.' errors with no way forward. Any 401 from our API, or coming back to a tab // whose session has lapsed, opens the in-shell sign-in once and reloads the screen after it. @@ -61,19 +97,28 @@ window.CR = (function () { if (document.getElementById('iapChat') || document.querySelector('script[src^="/assets/chat.js"]')) return; const s = document.createElement('script'); s.src = '/assets/chat.js?v=20261018c'; s.defer = true; document.body.appendChild(s); } + function railActive(o) { let a = o.active; if (a === 'credits' && location.hash === '#refuel') a = 'refuel'; return a; } function mount(o) { const page = $('page'); if (!page) return; chat(); + if (!document.getElementById('crFlashCss')) { const st = document.createElement('style'); st.id = 'crFlashCss'; st.textContent = '.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); } + const act = railActive(o); const app = document.createElement('div'); app.className = 'app'; let railWide = true; try { railWide = localStorage.getItem('cr.rail') !== 'narrow'; } catch (e) {} if (railWide) app.classList.add('wide'); // expanded by default (Marty 2026-10-08), the choice remembered per browser app.innerHTML = '' + '
' + esc(o.crumb || 'Control room') + '

' + esc(o.title || '') + '

' + esc(o.sub || '') + '' + (o.actions || '') + '
' // pre-launch notice (Marty, 2026-10-17): open to everyone from today, official launch November 15 + '
Pre-launch testing until November 15. Everything is live and working, but features and screens may change while we test. Questions? Use Help.
' - + '
' + + arriveStrip() + '
' + '
rotator checkingserved today ·zones live ·network ·
'; page.parentNode.insertBefore(app, page); app.querySelector('#crBody').appendChild(page); + if ($('crArriveX')) $('crArriveX').addEventListener('click', () => { const a = $('crArrive'); if (a) a.remove(); }); + // the rail's Refuel item while already on Credits: only the hash changes, so scroll by hand (and again on a repeat click) + const paintRail = () => { const a2 = railActive(o); app.querySelectorAll('.rail a[href]').forEach(x => { const k = x.getAttribute('href') === '/credits#refuel' ? 'refuel' : x.getAttribute('href') === '/credits' ? 'credits' : null; if (k) { x.classList.toggle('on', k === a2); if (k === a2) x.setAttribute('aria-current', 'page'); else x.removeAttribute('aria-current'); } }); }; + app.querySelectorAll('.rail a[href="/credits#refuel"]').forEach(x => x.addEventListener('click', e => { if (location.pathname !== '/credits') return; e.preventDefault(); history.replaceState(null, '', location.pathname + location.search + '#refuel'); paintRail(); focusAnchor(); })); + window.addEventListener('hashchange', () => { paintRail(); focusAnchor(); }); + focusAnchor(); $('crRailTog').addEventListener('click', () => { const wide = !app.classList.contains('wide'); app.classList.toggle('wide', wide); try { localStorage.setItem('cr.rail', wide ? 'wide' : 'narrow'); } catch (e) {} }); $('crUserBtn').addEventListener('click', async e => { e.preventDefault(); if (!ME || !ME.signedIn) return signInFlow(() => location.reload()); const v = await dialog({ title: ME.username ? '@' + ME.username : (ME.email || 'Account'), text: 'Signed in on LinkSpin. Your classic dashboard is still at /my.', ok: 'Sign out', no: 'Close', danger: true }); if (v) { try { await api('/api/auth/logout'); } catch (er) {} location.reload(); } }); clock(); setInterval(clock, 30000); @@ -84,14 +129,14 @@ window.CR = (function () { try { const s = await get('/api/my/strip'); $('stDot').className = 'dot' + (s.ok ? '' : ' off'); $('stHealth').textContent = s.ok ? 'healthy' : 'degraded'; $('stServed').textContent = fmt(s.served); $('stZones').textContent = fmt(s.zones); $('stNet').textContent = s.network ? 'on' : 'off'; } catch (e) { $('stHealth').textContent = 'offline'; } } - function whoPaint(m) { const w = $('crWho'), a = $('crAv'); if (!w) return; if (m && m.signedIn) { const name = m.username ? '@' + m.username : (m.email || '').split('@')[0]; w.textContent = name; a.textContent = (m.username || m.email || '?').replace(/^@/, '').slice(0, 2).toUpperCase(); } else { w.textContent = 'Sign in'; a.textContent = ''; } } + function whoPaint(m) { const si = $('crArriveSi'); if (si) si.hidden = !!(m && m.signedIn); const w = $('crWho'), a = $('crAv'); if (!w) return; if (m && m.signedIn) { const name = m.username ? '@' + m.username : (m.email || '').split('@')[0]; w.textContent = name; a.textContent = (m.username || m.email || '?').replace(/^@/, '').slice(0, 2).toUpperCase(); } else { w.textContent = 'Sign in'; a.textContent = ''; } } const sub = t => { const s = $('crSub'); if (s) s.textContent = t; }; async function me(force) { if (ME && !force) return ME; try { ME = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) { ME = { signedIn: false }; } return ME; } // sign-in inside the shell: email -> six-digit code, on the same endpoints and guards as the dashboard. const FTS = Date.now(); async function signInFlow(onReady) { let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); } - host.innerHTML = '').join('') + ''; + const nextLink = go(d.next.link, TASK[d.next.key]); + const next = ''; + const how = d.next.guide === '/refuel' ? '' : '

How the Refuel streak works

'; // the member guide (2026-10-24) if (d.locked) return '
' + next + how + '
'; return '
' + next + dials + streak + how + warns + parts + '

Numbers cover InstantAdPay and LinkSpin together' + (d.sites && (!d.sites.iap || !d.sites.linkspin) ? ' (one site did not answer just now)' : '') + '. Credits buy ad delivery only.

'; } @@ -52,6 +65,7 @@ if (!d || !d.on) { if (host) host.hidden = true; return; } if (host) host.hidden = false; if (d.error) { root.innerHTML = '

' + esc(d.error) + '

'; return; } + FROM = d.site === 'linkspin' ? 'linkspin' : 'iap'; root.innerHTML = view(d); const save = root.querySelector('[data-er-save]'); if (save) save.addEventListener('click', async () => { @@ -63,4 +77,5 @@ } window.ENGINE_ROOM = { load }; load(); setInterval(() => { if (!document.hidden) load(); }, 120000); + window.addEventListener('cr:signedin', () => load(true)); // LinkSpin's in-shell sign-in: the panel loaded signed out })(); diff --git a/public/assets/fuel.js b/public/assets/fuel.js index 982e424..0d4935b 100644 --- a/public/assets/fuel.js +++ b/public/assets/fuel.js @@ -5,7 +5,10 @@ const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); const n = v => Number(v || 0).toLocaleString('en-US'); window.FUEL = window.FUEL || {}; - const HOW = '

How the Refuel streak works

'; // the member guide (2026-10-24) + const HOW = '

How the Refuel streak works' + (location.pathname === '/ads' ? '' : ' · Engine Room') + '

'; // the member guide (2026-10-24); Engine Room link (2026-10-25) + // the one action, said plainly (2026-10-25): which package counts, and a button that lands on the package picker + const buyBtn = (v, label, pri) => '

Any package of $' + v.minUsd.linkspin + ' or more here counts (marked counts for Refuel under Buy a package).

' + + '' + label + ''; function site(name, s, minUsd) { const row = '
' + name + ': '; // own spacing: the Ads screen has no .row rule (2026-10-24) return s && s.refueled ? row + '+' + s.pct + '% · ' + n(s.bonus) + ' bonus credits
' @@ -16,17 +19,19 @@ if (!v.active) { return '

' + (v.started ? 'Your last streak ended. ' : '') + 'A package of $' + v.minUsd.linkspin + ' or more here, or $' + v.minUsd.iap + '+ on InstantAdPay, ' + (v.started ? 'starts it again' : 'starts your monthly refuel streak and sets your own refuel day') + '.

' + '

Bonus ad credits: month 1 +' + v.ladder.single[0] + '%, then +' + v.ladder.single.slice(1).join('%, +') + '%. Refuel both sites in the same cycle and each gets +' + v.ladder.both.join('%, +') + '%.

' - + 'Start my streak' + HOW; + + buyBtn(v, 'Buy a $' + v.minUsd.linkspin + '+ package to start', true) + HOW; } const c = v.cycle || {}; let h = v.windowOpen ? '

Your refuel window is open. Refuel day ' + esc(v.refuelDayLabel) + ', grace to ' + esc(v.graceLabel) + ' (Central). Next refuel: +' + v.next.single + '%, or +' + v.next.both + '% on each site with both.

' : '

Next refuel day ' + esc(v.refuelDayLabel) + ' (Central). Window opens ' + esc(v.opensLabel) + ', grace to ' + esc(v.graceLabel) + '.

'; if (c.month) h += '
' + site('InstantAdPay', c.iap, v.minUsd.iap) + site('LinkSpin', c.linkspin, v.minUsd.linkspin) + '
'; - if (!v.windowOpen && c.month && !c.both) h += '

Refuel ' + (c.linkspin && c.linkspin.refueled ? 'InstantAdPay ($' + v.minUsd.iap + '+)' : 'LinkSpin ($' + v.minUsd.linkspin + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to +' + v.next.secondEngine + '%.

'; + if (!v.windowOpen && c.month && !c.both) h += '

Refuel ' + (c.linkspin && c.linkspin.refueled ? 'InstantAdPay ($' + v.minUsd.iap + '+)' : 'LinkSpin ($' + v.minUsd.linkspin + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to +' + v.next.secondEngine + '%.' + + (c.linkspin && c.linkspin.refueled ? ' Buy on InstantAdPay ↗' : '') + '

'; if (v.pitStop && (v.pitStop.linkspin || v.pitStop.usedLinkspin)) h += '

Pit Stop ' + (v.pitStop.linkspin ? 'available here: +' + v.pitStop.pct + '% on a $' + v.minUsd.linkspin + '+ top-up, once this cycle. It does not count as your refuel.' : 'used here this cycle.') + '

'; h += '

' + (v.freeMiss.available ? 'One free miss left this year.' : 'Free miss for this year used.') + '

'; - return h + '' + (v.windowOpen ? 'Refuel now' : 'Buy a package') + '' + HOW; + const lsDone = c.linkspin && c.linkspin.refueled; + return h + buyBtn(v, v.windowOpen ? 'Refuel now: buy a $' + v.minUsd.linkspin + '+ package' : lsDone ? 'Buy another package' : 'Buy a $' + v.minUsd.linkspin + '+ package', v.windowOpen || !lsDone) + HOW; } async function load() { const panel = $('rfPanel'); if (!panel) return; @@ -36,6 +41,9 @@ if (!v || !v.on) { panel.hidden = true; return; } $('rfMeta').textContent = v.active ? 'streak: ' + v.streak + ' month' + (v.streak === 1 ? '' : 's') : 'shared with InstantAdPay'; $('rfBody').innerHTML = body(v); panel.hidden = false; + // on Credits the button just scrolls to the package picker (no reload); the picker then marks which packages count + panel.querySelectorAll('[data-rf-buy]').forEach(a => a.addEventListener('click', e => { if (location.pathname !== '/credits') return; e.preventDefault(); history.replaceState(null, '', location.pathname + location.search + '#buy'); window.dispatchEvent(new HashChangeEvent('hashchange')); })); + if (window.LSCredits) window.LSCredits.repaint(); } catch (e) { panel.hidden = true; } } window.FUEL.loadRefuel = load; @@ -97,4 +105,5 @@ } window.FUEL.loadKits = loadKits; loadKits(); + window.addEventListener('cr:signedin', () => { load(); loadKits(); }); // signed in from the shell's pop-up (arrivals from InstantAdPay) })(); diff --git a/public/conversions.html b/public/conversions.html index af49782..7dee4fd 100644 --- a/public/conversions.html +++ b/public/conversions.html @@ -68,7 +68,7 @@
- + diff --git a/public/credits.html b/public/credits.html index ecf9fe6..4f5ff0c 100644 --- a/public/credits.html +++ b/public/credits.html @@ -34,7 +34,7 @@
-
+

Buy a package

priced in dollars · settled in POL at the live rate · one transaction
loading packages…
@@ -83,8 +83,8 @@
- - - + + + diff --git a/public/help.html b/public/help.html index 14941f3..15d07c2 100644 --- a/public/help.html +++ b/public/help.html @@ -29,7 +29,7 @@
loading
- + diff --git a/public/links.html b/public/links.html index f645c12..acccf15 100644 --- a/public/links.html +++ b/public/links.html @@ -252,7 +252,7 @@
- + diff --git a/public/my.html b/public/my.html index 5f4e239..fb161d9 100644 --- a/public/my.html +++ b/public/my.html @@ -1008,7 +1008,7 @@
- + diff --git a/public/pages.html b/public/pages.html index 031848a..bedad75 100644 --- a/public/pages.html +++ b/public/pages.html @@ -72,7 +72,7 @@ - + diff --git a/public/reports.html b/public/reports.html index 8116953..4aa009c 100644 --- a/public/reports.html +++ b/public/reports.html @@ -89,7 +89,7 @@ - + diff --git a/public/sources.html b/public/sources.html index 7bc2134..d136287 100644 --- a/public/sources.html +++ b/public/sources.html @@ -123,7 +123,7 @@ - + diff --git a/public/team.html b/public/team.html index 37731d4..09a426e 100644 --- a/public/team.html +++ b/public/team.html @@ -37,7 +37,7 @@ - + diff --git a/public/wallet.html b/public/wallet.html index 6ded5d0..af2288b 100644 --- a/public/wallet.html +++ b/public/wallet.html @@ -31,7 +31,7 @@ - + diff --git a/public/zones.html b/public/zones.html index 2b8c43f..9cfbc60 100644 --- a/public/zones.html +++ b/public/zones.html @@ -41,7 +41,7 @@ - + diff --git a/server.js b/server.js index 38eaf73..a26d7de 100644 --- a/server.js +++ b/server.js @@ -3904,7 +3904,7 @@ const server = http.createServer(async (req, res) => { if (!refuel.cfg().on) return json(res, 200, { on: false }); const [own, peer] = await Promise.all([engine.facts({ site: 'linkspin', adminMember, ads, coach, bannerspin, rotator, pages, convtrack }, s.email), engineFromIap(s.email, u.searchParams.get('fresh') === '1')]); if (!peer || !peer.refuel) return json(res, 200, { on: true, error: 'InstantAdPay did not answer just now. Try again in a minute.' }); - return json(res, 200, engine.build({ refuel: peer.refuel, iap: peer.facts, ls: own, goal: peer.refuel.goal })); + return json(res, 200, engine.build({ site: 'linkspin', refuel: peer.refuel, iap: peer.facts, ls: own, goal: peer.refuel.goal })); } if (p === '/api/my/engine/goal' && req.method === 'POST') { const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });