diff --git a/ads.js b/ads.js index 3a6f2ef..a078f31 100644 Binary files a/ads.js and b/ads.js differ diff --git a/chatbot.js b/chatbot.js index 2869fd3..dd5f252 100644 --- a/chatbot.js +++ b/chatbot.js @@ -23,7 +23,7 @@ function enabled() { return !!key(); } const KNOWLEDGE_DATE = '2026-10-02'; // bump whenever the canned answers / prompt are brought up to date const CANNED = [ { re: /(spooky ?doors?|trick.or.treat|hallowe.?en|costume|candy ladder|\bcandy\b|\bknock)/i, - a: 'Spooky Doors (https://spookydoors.com) is the network\u2019s Halloween game. It opens on Oct 17 and closes at midnight Central at the end of Halloween night (Oct 31), and it shows in Members > Games only during the season; one tap signs you in with your InstantAdPay account. Walk the street, grab loose candy, hop the black cats and bats, and knock on doors. Every door is a short verified visit to a member\u2019s page or ad (a member video once you have visited them all), up to 15 doors a day, separate from your Earn visits and Drip Runner refuels. Most doors give a treat of 10 candy; about one door in five plays a trick, and beating it with quick taps adds a small bonus. Candy climbs a ladder that pays POL once per rung (100 candy 0.1 POL, 250 candy 0.25, 500 candy 0.5, 1,000 candy 1, 2,000 candy 2), from a season pool funded by a share of door ad spend and costume sales, so rungs pay only while the pool covers them. POL goes to the wallet on your InstantAdPay account once your game balance reaches 0.25 POL. The witch costume is free; the vampire (300 credits), bedsheet ghost (300) and Lucky caramel apple (500) are bought with your ad credits in the game\u2019s costume shop. Nothing here is a promise of income.' }, + a: 'Spooky Doors (https://spookydoors.com) is the network\u2019s Halloween game. It opens on Oct 4 and closes at midnight Central at the end of Halloween night (Oct 31), and it shows in Members > Games only during the season; one tap signs you in with your InstantAdPay account. Walk the street, grab loose candy, hop the black cats and bats, and knock on doors. Every door is a short verified visit to a member\u2019s page or ad (a member video once you have visited them all), up to 15 doors a day, separate from your Earn visits and Drip Runner refuels. Most doors give a treat of 10 candy; about one door in five plays a trick, and beating it with quick taps adds a small bonus. Candy climbs a ladder that pays POL once per rung (100 candy 0.1 POL, 250 candy 0.25, 500 candy 0.5, 1,000 candy 1, 2,000 candy 2), from a season pool funded by a share of door ad spend and costume sales, so rungs pay only while the pool covers them. POL goes to the wallet on your InstantAdPay account once your game balance reaches 0.25 POL. The witch costume is free; the vampire (300 credits), bedsheet ghost (300) and Lucky caramel apple (500) are bought with your ad credits in the game\u2019s costume shop. Advertisers can also put a verified-visits pack behind the doors: when you create a verified-visits campaign, pick Everywhere (3 credits a visit), Behind Spooky Doors (4 credits a door) or Golden Spooky Door (6 credits a door, and the player gets a little bonus candy). Door packs show only in Spooky Doors until the season ends, then any doors left run as normal visits. Nothing here is a promise of income.' }, { re: /(drip ?runner|games? (tab|page|hub)|play (a |the )?game|games? (that )?pay|refuel)/i, a: 'Members > Games lists the network\u2019s games; one tap signs you in. Drip Runner is a runner game: tap to hop, collect gold drips, dodge the bots, clear chapters. The first clear of each chapter drips a little POL into your game balance, which is sent to your wallet once it reaches the payout line shown in the game. When a run ends you can refuel instead of restarting: a short verified visit to a member\u2019s page (or a member video when you have visited them all), up to 20 refuels a day, separate from your regular Earn visits. Refuels are paid for by advertisers, and a share of that funds the POL pool every drip is paid from, so drips depend on the pool and are small. Share your link from the game lobby: when people on your team refuel, a share of what their refuels add to the pool goes to your game balance. Nothing here is a promise of income. PolHunter and Gem Kingdom are on the same Games page; Gem Kingdom is a match-3 that pays POL for first clears of stages and bosses (its Crowns are bought with ad credits).' }, { re: /(gem ?kingdom|crowns?\b|match.?3|goblin king|ice queen|bog witch|ember dragon|stronghold)/i, @@ -171,7 +171,7 @@ FACTS: - Onsite SOLO ADS are live: a solo ad is a full message (subject + up to 2000 characters of formatted text + your link) delivered into members' on-site Inbox (Members > Inbox). The composer in Campaigns > Solo ad has a rich-text editor (bold, headings, lists, links), lets you ATTACH one image (PNG/JPG/WebP/GIF, up to 3MB) or one video (MP4/WebM, up to 25MB), and adds a call-to-action button with a custom label that opens the target URL. Cost 5 credits per guaranteed delivery, minimum 10 deliveries (50 credits). Each member receives a given solo at most once, and never the sender's own. Readers earn 2 credits per real read (10-second dwell on the open message, up to 5 rewarded reads/day) — claimed right from the message. Compose one in Campaigns > Solo ad. - Campaign target URLs are checked the moment they are submitted: the page must be reachable and must ALLOW framing (no X-Frame-Options deny/sameorigin, no blocking CSP frame-ancestors), because surf views show the real site full screen. Frame-blocking or dead URLs are rejected with the exact reason; the fix is a landing page that allows framing. Login-ad targets skip the frame check (they are click-through only). - SPONSOR CHAT (Members): a two-way, one-to-one chat. A member can start a conversation with their DIRECT sponsor; a sponsor can message anyone in their downline. Presence-aware — when both are online it is live, otherwise a message waits in the recipient's on-site inbox and sends an email. Each member has an availability toggle in Profile (default on; turning it off stops live chats but people can still leave a note) and can mute a specific person. This is separate from the once-a-day sponsor BROADCAST to the whole downline. -- SPOOKY DOORS (Halloween season game, 2026-10-02): https://spookydoors.com, open 2026-10-17 through Halloween night (closes at midnight Central at the end of Oct 31); its Games tab card shows only during the season, with a "Limited time, ends Oct 31" ribbon. Members sign in with one tap from Members > Games. Walk the street, collect candy, avoid black cats and bats, knock on doors. Each door is a verified visit to a member's page or ad (a member video once every page has been visited), the advertiser is charged as for any visit, the player gets candy not credits; 15 doors per Central day, separate from the 20 Earn-tab visits and the 20 Drip Runner refuels. A treat is 10 candy; about 1 door in 5 is a trick (a ghost or skeleton you tap 5 times quickly; beat it for a 3 candy bonus, miss it for half the treat). If no ad is available the house is dark ("Nobody's home"): no candy and the door does not count. CANDY LADDER pays POL once per rung: 100 candy 0.1 POL, 250 0.25, 500 0.5, 1,000 1, 2,000 2 (Halloween 2026 badge at 500), paid from a season pool funded by a share of door ad spend and costume sales, only while the pool covers it; the game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. COSTUMES bought with ad credits like Gem Kingdom Crowns: witch free, vampire 300 credits (longer trick timer), bedsheet ghost 300 (black cats ignore you), Lucky caramel apple 500 (+2 candy per treat); no cash value. Top 20 by candy on the season leaderboard. Never promise earnings or call it income. +- SPOOKY DOORS (Halloween season game, 2026-10-02): https://spookydoors.com, open 2026-10-04 through Halloween night (closes at midnight Central at the end of Oct 31); its Games tab card shows only during the season, with a "Limited time, ends Oct 31" ribbon. Members sign in with one tap from Members > Games. Walk the street, collect candy, avoid black cats and bats, knock on doors. Each door is a verified visit to a member's page or ad (a member video once every page has been visited), the advertiser is charged as for any visit, the player gets candy not credits; 15 doors per Central day, separate from the 20 Earn-tab visits and the 20 Drip Runner refuels. A treat is 10 candy; about 1 door in 5 is a trick (a ghost or skeleton you tap 5 times quickly; beat it for a 3 candy bonus, miss it for half the treat). If no ad is available the house is dark ("Nobody's home"): no candy and the door does not count. CANDY LADDER pays POL once per rung: 100 candy 0.1 POL, 250 0.25, 500 0.5, 1,000 1, 2,000 2 (Halloween 2026 badge at 500), paid from a season pool funded by a share of door ad spend and costume sales, only while the pool covers it; the game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. COSTUMES bought with ad credits like Gem Kingdom Crowns: witch free, vampire 300 credits (longer trick timer), bedsheet ghost 300 (black cats ignore you), Lucky caramel apple 500 (+2 candy per treat); no cash value. Top 20 by candy on the season leaderboard. DOOR PACKS: creating a verified-visits campaign, the advertiser picks Everywhere (3 credits per visit, as before), Behind Spooky Doors (4 credits per door) or Golden Spooky Door (6 credits per door; the player gets +2 bonus candy). Paid up front like any visit pack. Door packs are served first on doors (Golden Doors before door packs), each player sees a pack at most once per Central day, they never run on the Earn tab or refuels during the season, and from Nov 1 any doors left run as normal visits; the campaign shows doors opened and unique players. Never promise earnings or call it income. - GEM KINGDOM (LIVE in the Games tab since 2026-10-02): Gem Kingdom (https://gemkingdom.app) is a free fantasy match-3: match gems so three heroes battle monsters across six chapters (Goblin Woods, the Frozen Pass, the Haunted Swamp, Dragon's Peak, the Sunken Reef, the Shadow Citadel), earn stars, and rebuild your Stronghold and forge weapons. It pays POL for FIRST clears only (stages 0.02 to 0.15 POL rising by chapter; bosses 0.25, 0.5, 2, 5, 7.5 and 10 POL for the Goblin King, Ice Queen, Bog Witch, Ember Dragon, Kraken and Shadow King); replays pay nothing. The game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. Rewards come from a pool funded by a share of Crown purchases and pay only while the pool has funds; never promise earnings or call it income. No referral bonus on game clears. Crowns, its upgrade currency, are bought with your InstantAdPay ad credits: tap Buy in the game's Crown Shop, confirm on InstantAdPay (top up with a pack if you are short), and you land back in the game with the Crowns added. Crowns buy buildings, weapons, battle boosts and a revive after a defeat. Sign in with your InstantAdPay account to save progress, earn badges and appear in the Game Achievements posts in the Crypto Team Build group. Never promise an amount beyond the posted rewards. - GAMES TAB (2026-10-01): Members > Games (/my#games) shows one card per network game (PolHunter, Drip Runner and Gem Kingdom pay POL to the member's InstantAdPay wallet), with their own progress and a Play button that signs them in with one tap; new games appear there as they launch (PolHunter is one card). DRIP RUNNER (https://driprunner.app, LIVE for every member since 2026-10-01): tap-to-hop runner; gold drips, magenta bots, orange firewalls from chapter 2; each chapter has a drip goal for one run; the FIRST clear of a chapter pays a small POL drip (amount set by the admin, shown in the game) into the game balance, replays pay nothing; the balance is sent on Polygon to the member's InstantAdPay wallet once it reaches the payout line shown in the game. REFUELS: a run that ends can be refuelled with a verified visit to a member's page (a member video once every page has been visited), up to 20 a day, separate from the 20 Earn-tab visits; the advertiser is charged as for any visit, the player gets fuel not credits. The POL pool is funded ONLY by a share of refuel ad spend plus POL spent in the hangar, so drips depend on refuels and can be zero when the pool is empty; say so honestly. HANGAR: Drip Magnet and Courier Mk II cost drips (game currency); Shield Core and Slow Field cost POL from the game balance, which returns to the pool. GUESTS can try a run without signing in; their clears pay once they sign in. REFERRALS: each player's share link /r/; when members whose InstantAdPay sponsor is that player refuel, a share (10 percent by default) of each refuel's pool income goes to the sponsor's game balance. Telegram posts achievement badges (chapters, unlocks, refuel milestones, payouts). Never promise amounts or income. - Every purchase is split by an immutable smart contract in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. No withdrawals exist; money lands in members' own wallets instantly. diff --git a/db.js b/db.js index be9c507..db17c49 100644 --- a/db.js +++ b/db.js @@ -131,6 +131,7 @@ async function bootstrap() { await alterSafe('ALTER TABLE campaigns ADD COLUMN house TINYINT NOT NULL DEFAULT 0'); // admin house ad: free, never charged await alterSafe('ALTER TABLE campaigns ADD COLUMN daily_cap INT NULL'); // optional credits/day pacing (banner + text) await alterSafe('ALTER TABLE campaigns ADD COLUMN geo VARCHAR(16) NULL'); // country tiers the campaign shows to ('1,2'); NULL = everyone + await alterSafe('ALTER TABLE campaigns ADD COLUMN placement VARCHAR(8) NULL'); // visits packs: NULL/'all' everywhere, 'doors' / 'golden' = Spooky Doors only until rates.sdSeasonEnd (2026-10-02) await q(`CREATE TABLE IF NOT EXISTS camp_geo ( campaign_id INT NOT NULL, cc CHAR(2) NOT NULL, n INT NOT NULL DEFAULT 0, PRIMARY KEY (campaign_id, cc) diff --git a/pdsync.js b/pdsync.js index c25b994..75aaff1 100644 --- a/pdsync.js +++ b/pdsync.js @@ -33,9 +33,10 @@ function bridge(action, method, body) { } // what PassiveDrip should list: every active, worldwide visits campaign with visits still to deliver +// (Spooky Doors door packs and Golden Doors stay behind the doors while the season runs: doorOnly) async function listing() { const all = await X.ads.adminList(2000); - return all.filter(c => c.type === 'visits' && c.status === 'active' && !c.geo && !(c.starts && c.starts > Date.now()) && /^https?:\/\//.test(c.targetUrl || '')) + return all.filter(c => c.type === 'visits' && c.status === 'active' && !c.doorOnly && !c.geo && !(c.starts && c.starts > Date.now()) && /^https?:\/\//.test(c.targetUrl || '')) .map(c => ({ id: c.id, title: String(c.name || c.title || 'Sponsor').slice(0, 64), desc: String((c.title && String(c.title).toLowerCase() !== String(c.name || '').toLowerCase()) ? c.title : '').slice(0, 128), url: c.targetUrl, visitsLeft: Math.max(0, Number(c.body || 0) - Number(c.imps || 0)) })) .filter(c => c.visitsLeft > 0); } diff --git a/public/admin.html b/public/admin.html index dea90ba..4aa43c0 100644 --- a/public/admin.html +++ b/public/admin.html @@ -206,6 +206,7 @@ @@ -511,6 +512,6 @@ - + diff --git a/public/assets/admin.js b/public/assets/admin.js index 869e9f1..a7577e4 100644 --- a/public/assets/admin.js +++ b/public/assets/admin.js @@ -154,9 +154,9 @@ ctaLabel: t === 'video' ? $('hVideoCta').value : $('hSoloCta').value, videoUrl: $('hVideoUrl').value, watchSecs: Number($('hWatchSecs').value), videoW: hVidDims ? hVidDims.w : null, videoH: hVidDims ? hVidDims.h : null, - days, startDay: Number($('hFeatStart').value) || 0, count, + days, startDay: Number($('hFeatStart').value) || 0, count, placement: t === 'visits' && $('hVisitPlace') ? $('hVisitPlace').value : undefined, budget: t === 'featured' ? days * (rates.featuredPerDay || 40) - : t === 'visits' ? count * (rates.visitCostPerVisit || 3) + : t === 'visits' ? count * (($('hVisitPlace') && $('hVisitPlace').value === 'golden') ? (rates.goldenDoorCost || 6) : ($('hVisitPlace') && $('hVisitPlace').value === 'doors') ? (rates.doorPackCost || 4) : (rates.visitCostPerVisit || 3)) : (Number($('hBudget').value) || 0) }; try { await api('/api/admin/campaigns', body); @@ -922,6 +922,8 @@ videoWatchCapPerDay: ['Video: rewarded watches per day', ''], featuredPerDay: ['Featured link: credits per day', ''], featuredSlotsPerDay: ['Featured link: slots per day', ''], featuredWindowDays: ['Featured link: booking window (days)', ''], featuredDurations: ['Featured link: durations offered (days)', 'comma-separated'], + doorPackCost: ['Spooky Doors: door pack, credits per door', 'placement "Behind Spooky Doors"'], goldenDoorCost: ['Spooky Doors: Golden Door, credits per door', 'placement "Golden Spooky Door"'], + goldenBonusCandy: ['Spooky Doors: Golden Door bonus candy', 'sent to the game as bonus'], sdSeasonEnd: ['Spooky Doors: season end (Central day, exclusive)', 'from this day door packs run as normal visits (YYYY-MM-DD)'], visitCostPerVisit: ['Verified visit: credits per visit', ''], visitMinPack: ['Verified visit: smallest pack', ''], visitReward: ['Verified visit: viewer reward (credits)', ''], visitDwellSeconds: ['Verified visit: seconds on site', ''], visitCapPerDay: ['Verified visit: rewarded visits per day', ''], videoTiers: ['Video ad tiers', 'watch length → advertiser cost → viewer reward'], milestoneBonus: ['Milestone bonuses (credits)', 'one-time, when a member reaches each step'] diff --git a/public/assets/door.js b/public/assets/door.js index 9e36cee..a4e63af 100644 --- a/public/assets/door.js +++ b/public/assets/door.js @@ -39,7 +39,7 @@ if (r.cap && r.ret) return msg('That is tonight’s doors', 'You have knocked on every door for today. Your candy is safe, and the doors open again at midnight Central.', r.ret, true); $('sdHint').textContent = r.error; $('sdCheck').hidden = true; var bb = $('sdBack'); bb.hidden = false; bb.onclick = function () { location.href = gameHome; }; return; } - $('sdCheck').hidden = true; $('sdHint').textContent = r.house ? 'Visit counted. A smaller treat from ' + (r.program || 'the house') + ' is on its way.' : r.host ? 'Visit counted. @' + r.host + ' has a treat for you.' : 'Visit counted. Someone has a treat for you.'; + $('sdCheck').hidden = true; $('sdHint').textContent = r.golden ? 'Visit counted. Golden Door! ' + (r.host ? '@' + r.host + ' has' : 'Someone has') + ' a treat for you, plus ' + (r.bonus || 0) + ' bonus candy.' : r.house ? 'Visit counted. A smaller treat from ' + (r.program || 'the house') + ' is on its way.' : r.host ? 'Visit counted. @' + r.host + ' has a treat for you.' : 'Visit counted. Someone has a treat for you.'; var b = $('sdDone'); b.disabled = false; b.textContent = 'Back to the street'; b.onclick = function () { location.href = r.ret; }; setTimeout(function () { location.href = r.ret; }, 1200); }); @@ -54,6 +54,7 @@ dwell = r.dwell || 8; left = Math.max(1, dwell - (r.elapsed || 0)); if (r.doors && r.doors.cap) { var ch = $('sdDoors'); ch.textContent = 'Door ' + Math.min(r.doors.cap, (r.doors.used || 0) + 1) + ' of ' + r.doors.cap; ch.hidden = false; } var who = r.house ? 'House ad' : r.host ? '@' + r.host + '’s door' : 'A member’s door'; + if (r.golden) { document.body.classList.add('gold'); $('sdGold').hidden = false; who = 'Golden Door! ' + who; } // gold variant: bonus candy on this one if (r.mode === 'video') { // no member pages left: a member video ad instead $('sdTitle').textContent = who + ': ' + (r.title || 'member video'); $('sdUrl').textContent = 'video ad'; $('sdHint').textContent = 'You have visited every member page running right now, so this door is a short member video. Keep it playing.'; @@ -67,6 +68,7 @@ } $('sdTitle').textContent = who + ': ' + (r.title || 'member site'); try { $('sdUrl').textContent = new URL(r.target).hostname; } catch (e) {} if (r.house) $('sdHint').textContent = 'A house ad: a smaller treat while the street’s ads are resting. Stay on this page.'; + if (r.golden) $('sdHint').textContent = 'A Golden Door: this one comes with ' + (r.bonus || 0) + ' bonus candy. Stay on this page; the timer only runs while it is in front.'; var f = document.createElement('iframe'); f.src = r.target; f.setAttribute('referrerpolicy', 'no-referrer'); f.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups'); $('sdFrame').innerHTML = ''; $('sdFrame').appendChild(f); var o = $('sdOpen'); o.href = r.target; o.hidden = false; ring(); timer = setInterval(tick, 1000); diff --git a/public/assets/my.js b/public/assets/my.js index aa29cb4..4bfbd28 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -1023,11 +1023,13 @@ tbl.innerHTML = '' + '' + r.campaigns.map(c => '' - + '' + + '' + '' + '' + '' - + (c.type === 'visits' ? '' + + (c.type === 'visits' ? '' : c.type === 'featured' ? '' : '') + '' @@ -1035,7 +1037,7 @@ : c.status === 'paused' ? '' : '') + (['paused', 'out', 'done'].includes(c.status) ? ' ' : '') + (c.type === 'featured' ? ' ' - : c.type === 'visits' ? ' ' + : c.type === 'visits' ? ' ' : ' ') + '').join('') + '
NameTypeViews hereNetwork viewsClicksSpentBudgetStatus
' + c.name + '' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '' + c.type + (c.type === 'banner' && c.width ? ' ' + c.width + '×' + c.height + '' : '') + (c.dailyCap ? ' cap ' + c.dailyCap + '/day' : '') + (c.geo ? ' tier ' + esc(c.geo.replace(/,/g, '+')) + '' : '') + schedChips(c) + '' + c.type + (c.type === 'banner' && c.width ? ' ' + c.width + '×' + c.height + '' : '') + (c.dailyCap ? ' cap ' + c.dailyCap + '/day' : '') + (c.geo ? ' tier ' + esc(c.geo.replace(/,/g, '+')) + '' : '') + schedChips(c) + + (c.type === 'visits' && (c.placement === 'golden' || c.placement === 'doors') ? ' ' + (c.placement === 'golden' ? 'Golden Door' : 'Spooky Doors') + '' : '') + '' + c.imps.toLocaleString() + '' + (['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() : 'n/a') + '' + c.clicks + (r.clickSources && r.clickSources[c.id] ? '
' + Object.entries(r.clickSources[c.id]).sort((a, b) => b[1] - a[1]).map(([k, v]) => '' + esc(k) + ' ' + v + '').join('') + (c.impsNas ? ' · network: see Network views' : '') + '
' : '') + '
paid up front' + c.imps.toLocaleString() + ' of ' + Number(c.body || 0).toLocaleString() + ' visitspaid up front' + c.imps.toLocaleString() + ' of ' + Number(c.body || 0).toLocaleString() + (c.placement === 'golden' || c.placement === 'doors' ? ' doors' : ' visits') + + (((r.doorStats && r.doorStats[c.id]) || c.placement === 'golden' || c.placement === 'doors') ? (ds => '
\u{1F383} ' + ds.doors.toLocaleString() + ' door' + (ds.doors === 1 ? '' : 's') + ' opened \u00b7 ' + ds.players.toLocaleString() + ' player' + (ds.players === 1 ? '' : 's') + '
')((r.doorStats && r.doorStats[c.id]) || { doors: 0, players: 0 }) : '') + '
paid up front' + featRun(c) + '' + c.spent + '' + c.budget + '' + (c.status === 'out' ? (c.type === 'visits' ? 'pack delivered' : 'budget spent') : c.status === 'done' ? '' + (c.type === 'featured' ? 'run ended' : 'ended') + '' : c.scheduled ? 'scheduled' : c.status) + '
'; el.appendChild(tbl); @@ -1055,11 +1057,12 @@ } catch (e) { IAP.status(e.message, 'bad'); } })); el.querySelectorAll('button[data-morevisits]').forEach(b => b.addEventListener('click', async () => { - const per = (r.rates && r.rates.visitCostPerVisit) || 3; - const n = await IAP.ask({ title: 'Buy more visits', text: 'How many more verified visits? ' + per + ' credits each, charged now like the original pack.', type: 'number', placeholder: 'e.g. 50', ok: 'Buy visits' }); + const per = Number(b.dataset.vper) || (r.rates && r.rates.visitCostPerVisit) || 3; const door = b.dataset.vdoor; // door packs top up at their door price + const what = door === 'golden' ? 'Golden Doors' : door ? 'doors' : 'visits'; + const n = await IAP.ask({ title: 'Buy more ' + what, text: door ? 'How many more ' + what + '? ' + per + ' credits each, charged now like the original pack.' : 'How many more verified visits? ' + per + ' credits each, charged now like the original pack.', type: 'number', placeholder: 'e.g. 50', ok: 'Buy ' + what }); if (!n) return; try { const x = await api('/api/my/campaigns/' + b.dataset.morevisits + '/topup', { credits: Math.floor(Number(n)) * per }); - IAP.status('Added ' + x.visits + ' visits (' + x.added + ' credits)' + (x.reactivated ? '. The pack is open again.' : '.'), 'ok'); + IAP.status('Added ' + x.visits + ' ' + what + ' (' + x.added + ' credits)' + (x.reactivated ? '. The pack is open again.' : '.'), 'ok'); await loadCampaigns(); loadDashboard(); } catch (e) { IAP.status(e.message, 'bad'); } })); @@ -1213,15 +1216,31 @@ + ' for ' + (dys * lastRates.featuredPerDay) + ' credits. Max ' + (s ? s.slotsPerDay : 10) + ' links share any day.'; } document.addEventListener('change', e => { if (e.target && e.target.id === 'cFeatDays') featHint(); }); + // where a visits pack runs (Spooky Doors, 2026-10-02): everywhere, behind the doors, or a Golden Door, each with its own price + // function declarations (hoisted): loadCampaigns can run before this point is reached + function visitPlace() { const x = document.querySelector('input[name="cVisitPlace"]:checked'); return x ? x.value : 'all'; } + function placeCost(pl, rr) { rr = rr || lastRates || {}; return pl === 'golden' ? (rr.goldenDoorCost || 6) : pl === 'doors' ? (rr.doorPackCost || 4) : (rr.visitCostPerVisit || 3); } + function sdSeasonOpen(rr) { return new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) < String((rr && rr.sdSeasonEnd) || '2026-11-01'); } + function sdLastDay(rr) { const t = new Date(String((rr && rr.sdSeasonEnd) || '2026-11-01') + 'T12:00:00Z'); t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); } function visitHint() { if (!lastRates) return; + const open = sdSeasonOpen(lastRates); + document.querySelectorAll('#cVisitPlaceRow .sd-place').forEach(el => { el.hidden = !open; }); + if (!open && visitPlace() !== 'all') { const a = document.querySelector('input[name="cVisitPlace"][value="all"]'); if (a) a.checked = true; } + document.querySelectorAll('[data-vpcost]').forEach(el => { const p = el.dataset.vpcost; el.textContent = '(' + placeCost(p) + ' credits a ' + (p === 'all' ? 'visit' : 'door') + ')'; }); + const pl = visitPlace(), per = placeCost(pl), min = lastRates.visitMinPack || 20; const n = Number($('cVisitCount').value) || 0; - const cost = n * (lastRates.visitCostPerVisit || 3); - $('cVisitHint').textContent = (lastRates.visitCostPerVisit || 3) + ' credits per verified visit' - + (n >= (lastRates.visitMinPack || 20) ? ' — ' + n + ' visits = ' + cost + ' credits' : ' (min ' + (lastRates.visitMinPack || 20) + ')') - + '. Each is a unique member, dwell + human-check verified.'; + const unit = pl === 'golden' ? 'Golden Door' : pl === 'doors' ? 'door' : 'verified visit'; + $('cVisitCount').placeholder = pl === 'all' ? 'How many verified visits?' : pl === 'golden' ? 'How many Golden Doors?' : 'How many doors?'; + $('cVisitHint').textContent = per + ' credits per ' + unit + + (n >= min ? ': ' + n + ' = ' + (n * per).toLocaleString() + ' credits, paid up front' : ' (min ' + min + ')') + + (pl === 'all' ? '. Each is a unique member, dwell + human-check verified.' + : '. Each door is a dwell + human-check verified visit by a Spooky Doors player, at most once a day per player' + + (pl === 'golden' ? '; Golden Doors open before every other door and give the player bonus candy' : '; door packs open before ordinary visits') + + '. They run only in Spooky Doors until the season ends on ' + sdLastDay(lastRates) + ', then any doors left run as normal visits.'); } $('cVisitCount').addEventListener('input', visitHint); + document.querySelectorAll('input[name="cVisitPlace"]').forEach(x => x.addEventListener('change', visitHint)); // video composer: tier dropdown + upload + price hint function videoHint() { if (!lastRates || !lastRates.videoTiers) return; @@ -1272,13 +1291,13 @@ videoUrl: $('cVideoUrl').value, watchSecs: Number($('cWatchSecs').value), videoW: cVidDims ? cVidDims.w : null, videoH: cVidDims ? cVidDims.h : null, days: Number($('cFeatDays').value), startDay: featStartDay, - count: Number($('cVisitCount').value), + count: Number($('cVisitCount').value), placement: t === 'visits' ? visitPlace() : undefined, dailyCap: ($('cDailyCap') && (t === 'banner' || t === 'text')) ? Number($('cDailyCap').value) || 0 : 0, geo: [...document.querySelectorAll('.geoTier:checked')].map(x => x.value).join(','), startsAt: ($('cStartAt') && $('cStartAt').value && !isFeat) ? new Date($('cStartAt').value).getTime() : 0, endsAt: ($('cEndAt') && $('cEndAt').value && !isFeat) ? new Date($('cEndAt').value).getTime() : 0, ctaLabel: isVideo ? $('cVideoCta').value : $('cCtaLabel').value, - budget: isFeat ? (Number($('cFeatDays').value) * (lastRates.featuredPerDay || 40)) : t === 'visits' ? (Number($('cVisitCount').value) * (lastRates.visitCostPerVisit || 3)) : Number($('cBudget').value) }); + budget: isFeat ? (Number($('cFeatDays').value) * (lastRates.featuredPerDay || 40)) : t === 'visits' ? (Number($('cVisitCount').value) * placeCost(visitPlace())) : Number($('cBudget').value) }); const schedStart = ($('cStartAt') && $('cStartAt').value && !isFeat) ? new Date($('cStartAt').value) : null; IAP.status(schedStart && schedStart.getTime() > Date.now() ? 'Campaign saved. It starts serving ' + schedStart.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' }) + '.' : 'Campaign is live. It starts serving right away.', 'ok'); // clear EVERY field so no target/creative carries into the next campaign @@ -1286,6 +1305,7 @@ 'cVideoUrl', 'cVideoTitle', 'cVideoCta', 'cVisitTitle', 'cVisitCount', 'cFeatTitle', 'cDailyCap', 'cStartAt', 'cEndAt'] .forEach(id => { if ($(id)) $(id).value = ''; }); document.querySelectorAll('.geoTier').forEach(x => { x.checked = true; }); + { const a = document.querySelector('input[name="cVisitPlace"][value="all"]'); if (a) a.checked = true; if (t === 'visits') visitHint(); } $('cSoloEd').innerHTML = ''; if ($('cSoloRaw')) $('cSoloRaw').value = ''; $('cVideoInfo').textContent = ''; $('cVideoPrev').hidden = true; $('cVideoPrev').innerHTML = ''; if ($('edMediaInfo')) $('edMediaInfo').textContent = ''; @@ -2128,9 +2148,10 @@ if ($('tkGo')) { $('tkGo').addEventListener('click', tkGenerate); $('tkAgain').addEventListener('click', tkGenerate); $('tkCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('tkText').value); IAP.status('Copied.', 'ok'); } catch (e) { $('tkText').select(); } }); $('tkSendBc').addEventListener('click', tkSendBroadcast); } // promo tools: pill menu switches between posts / swipes / banners / wall / videos function setPromoSub(name) { - const ids = ['toolkit', 'posts', 'text', 'swipe', 'banners', 'wall', 'objections', 'videos', 'viral', 'polhunter']; + const ids = ['toolkit', 'posts', 'text', 'swipe', 'banners', 'wall', 'objections', 'videos', 'viral', 'polhunter', 'spookydoors']; if (name === 'toolkit') loadToolkit(); - if (!ids.includes(name)) name = 'posts'; + const pill = document.querySelector('.promo-pills [data-promo="' + name + '"]'); + if (!ids.includes(name) || !pill || pill.hidden) name = 'posts'; ids.forEach(id => { const el = $('promo-' + id); if (el) el.hidden = id !== name; }); document.querySelectorAll('.promo-pills [data-promo]').forEach(b => { b.classList.toggle('on', b.dataset.promo === name); diff --git a/public/assets/promo.js b/public/assets/promo.js index 56c6431..73c8f96 100644 --- a/public/assets/promo.js +++ b/public/assets/promo.js @@ -273,6 +273,31 @@ window.IAPPromo = (function () { const d = document.createElement('div'); d.className = 'promo-block'; d.innerHTML = '
' + s + ' ' + esc(n) + '
' + s + '
' + esc(code) + '
'; const row = document.createElement('div'); row.className = 'pb-actions'; row.appendChild(copyBtn(code, 'Copy embed code')); row.appendChild(linkBtn(src, 'Open image')); d.appendChild(row); bg.appendChild(d); } } + // Spooky Doors (Halloween season, 2026-10-02): the member's game link, the share image and two short posts. Shown on the + // season window the Games card uses (the server decides; the admin gets a preview before the start), hidden after it. + const sdp = $('promo-spookydoors'); + if (sdp && token && sdp.dataset.filled !== token) { + sdp.dataset.filled = token; + fetch('/api/my/spookydoors/promo').then(r => r.json()).then(s => { + const pill = document.querySelector('.promo-pills [data-promo="spookydoors"]'); + if (!s || !s.show) { if (pill) pill.hidden = true; sdp.hidden = true; return; } + if (pill) pill.hidden = false; + const enc = encodeURIComponent, sl = String(s.base || 'https://spookydoors.com') + '/r/' + enc(token), img = s.image || 'https://spookydoors.com/og-spookydoors.jpg'; + const day = (d, back) => { const t = new Date(d + 'T12:00:00Z'); if (back) t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); }; + const ends = s.season && s.season.end ? day(s.season.end, true) : 'Oct 31'; + $('sdpSub').textContent = s.preview && s.season ? 'preview: members see this card from ' + day(s.season.start) + ' to ' + ends : 'our Halloween game, limited time, ends ' + ends; + $('sdpLink').textContent = sl; + $('sdpCopy').onclick = async () => { try { await navigator.clipboard.writeText(sl); status('Link copied.', 'ok'); } catch (e) { status('Copy failed.', 'bad'); } }; + $('sdpImg').onerror = () => { $('sdpImg').hidden = true; }; $('sdpImg').src = img; $('sdpImgOpen').href = img; + $('sdpImgCopy').onclick = async () => { try { await navigator.clipboard.writeText(img); status('Image URL copied.', 'ok'); } catch (e) { status('Copy failed.', 'bad'); } }; + const SD_POSTS = [ + { name: 'Short post', text: 'Trick or treat! \u{1F383} Spooky Doors is a free Halloween game: walk the street, dodge the black cats and bats, knock on doors and fill your candy bucket. Only until Halloween night. Play here: ' + sl }, + { name: 'Friendly post', text: 'Something fun for October: I have been playing Spooky Doors, a little Halloween game where every door you knock on opens somebody\u2019s page. Pick a costume and see how much candy you can collect before ' + ends + '. ' + sl }, + ]; + const pp = $('sdpPosts'); pp.innerHTML = ''; + for (const p of SD_POSTS) pp.appendChild(block(p.text, '' + esc(p.name) + '', [linkBtn('https://x.com/intent/tweet?text=' + enc(p.text), 'X'), linkBtn('https://www.facebook.com/sharer/sharer.php?u=' + enc(sl), 'Facebook'), linkBtn('https://t.me/share/url?url=' + enc(sl) + '&text=' + enc(p.text.replace(sl, '').trim()), 'Telegram'), linkBtn('https://wa.me/?text=' + enc(p.text), 'WhatsApp')])); + }).catch(() => {}); + } // objections const ob = $('promoObjections'); if (ob && ob.dataset.filled !== link) { diff --git a/public/door.html b/public/door.html index b01b25b..71ab558 100644 --- a/public/door.html +++ b/public/door.html @@ -33,10 +33,16 @@ body{margin:0;display:flex;flex-direction:column;background:var(--night);color:v .dr-msg p{margin:0;color:var(--muted);line-height:1.45} .dr-chip{display:inline-block;margin-left:6px;padding:2px 8px;border-radius:999px;background:rgba(20,11,36,.7);border:1px solid var(--line);color:var(--moon);font-size:12px;font-weight:600} a.dr-open{color:var(--moon);font-size:12px} +/* Golden Door (2026-10-02): an advertiser's Golden Spooky Door, served before every other door, with bonus candy */ +.dr-gold{display:inline-block;margin-left:6px;padding:2px 9px;border-radius:999px;background:linear-gradient(135deg,#FFE27A,#FFB800);color:#3a2400;font-size:12px;font-weight:700;box-shadow:0 0 12px rgba(255,200,61,.6)} +body.gold{--pumpkin:#FFC83D;--pumpkin-d:#A86F00;--line:#7A5A12} +body.gold .dr-bar,body.gold .dr-dock{background:linear-gradient(90deg,#3B2A08,#241339 60%)} +body.gold .dr-ring{box-shadow:0 0 18px rgba(255,200,61,.55)} +body.gold #sdTitle{color:#FFE27A} -
InstantAdPay · verified visit · Spooky Doors
+
InstantAdPay · verified visit · Spooky Doors

Knock knock

Opening the door...

…

Someone is coming to the door…

Stay on this page. The timer only runs while it is in front.

@@ -44,6 +50,6 @@ a.dr-open{color:var(--moon);font-size:12px}
- + diff --git a/public/my.html b/public/my.html index f99ce55..c06ae61 100644 --- a/public/my.html +++ b/public/my.html @@ -571,6 +571,12 @@ + - - + + diff --git a/qa/door.mjs b/qa/door.mjs index b073f2b..8c71b64 100644 --- a/qa/door.mjs +++ b/qa/door.mjs @@ -5,7 +5,9 @@ // Covers: open -> challenge (wrong pick, then right) -> done -> callback signature + receipt, re-open after done, // house ads when the street is empty (RM Circle first, then the next program with the player's ref; credits 0, counted), // "nobody's home" only with doorHouseAds = [] (none=1, door not counted), cap (cap=1), the door/refuel/earn caps staying separate, bad tokens, -// and the Games card season window. Exit code 1 on any failure. +// the Games card + Promo tools card season window, and door packs + Golden Doors (placement 'doors'/'golden': prices, golden first, +// door pack second, once per player per Central day, credits/golden/bonus in open + callback + receipt, never on Earn or refuels in +// season, ordinary visits from sdSeasonEnd, advertiser door stats). Exit code 1 on any failure. import http from 'node:http'; import crypto from 'node:crypto'; import fs from 'node:fs'; @@ -182,9 +184,12 @@ try { const today = new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); const gA = (await api('/api/my/games', null, { Cookie: adminCookie })).j; const sdA = gA && (gA.games || []).find(g => g.slug === 'spookydoors'); const gM = (await api('/api/my/games', null, { Cookie: playerCookie })).j; const sdM = gM && (gM.games || []).find(g => g.slug === 'spookydoors'); - if (today < '2026-10-17') { ok(sdA && sdA.preview && sdA.season && sdA.season.ends === 'Oct 31' && /opens Oct 17/.test(sdA.previewNote || ''), 'before the season: admin sees a preview card ending Oct 31', JSON.stringify(sdA ? { preview: sdA.preview, season: sdA.season, note: sdA.previewNote } : gA)); ok(!sdM, 'before the season: members do not see the card'); } - else if (today < '2026-11-01') { ok(sdA && sdA.season && sdA.season.ends === 'Oct 31', 'in season: admin sees the card with the ribbon date'); ok(!sdM, 'in season but not in gamesLive: members do not see it'); } - else { ok(!sdA && !sdM, 'after the season: nobody sees the card'); } + const pA = (await api('/api/my/spookydoors/promo', null, { Cookie: adminCookie })).j, pM = (await api('/api/my/spookydoors/promo', null, { Cookie: playerCookie })).j; + if (today < '2026-10-04') { ok(sdA && sdA.preview && sdA.season && sdA.season.start === '2026-10-04' && sdA.season.ends === 'Oct 31' && /opens Oct 4/.test(sdA.previewNote || ''), 'before the season (starts Oct 4): admin sees a preview card ending Oct 31', JSON.stringify(sdA ? { preview: sdA.preview, season: sdA.season, note: sdA.previewNote } : gA)); ok(!sdM, 'before the season: members do not see the card'); + ok(pA && pA.show && pA.preview && pA.base === SD && pA.image === SD + '/og-spookydoors.jpg' && pM && pM.show === false, 'Promo tools card: admin preview before the season, hidden for members', JSON.stringify({ pA, pM })); } + else if (today < '2026-11-01') { ok(sdA && sdA.season && sdA.season.ends === 'Oct 31', 'in season: admin sees the card with the ribbon date'); ok(!sdM, 'in season but not in gamesLive: members do not see it'); + ok(pA && pA.show && !pA.preview && pM && pM.show && !pM.preview && pM.image === SD + '/og-spookydoors.jpg', 'Promo tools card: shown to members in season', JSON.stringify({ pA, pM })); } + else { ok(!sdA && !sdM, 'after the season: nobody sees the card'); ok(pA && pA.show === false && pM && pM.show === false, 'Promo tools card: hidden after the season'); } // 7. costume shop: signed-out detour, confirm with CSRF, receipt + server callback, idempotent re-open, short of credits const order = 'qa-' + crypto.randomBytes(6).toString('hex'); @@ -212,7 +217,88 @@ try { const big = mint({ kind: 'sd-buy', order: order + 'x', email: player, memberId: 77, item: 'apple', label: 'Lucky caramel apple', credits: 999999, ret: SD + '/api/iap/receipt', cb: SD + '/api/iap/credit' }, null, 7200000); const bh = await (await fetch(B + '/sd/shop?t=' + encodeURIComponent(big), { headers: { Cookie: playerCookie } })).text(); ok(/more credits/.test(bh) && /\/sd\/shop\/topup\?t=/.test(bh), 'short of credits -> top-up offer'); -} catch (e) { fails++; console.log('FAIL exception: ' + e.message); } + + // 8. door packs + Golden Doors (launch pack A, 2026-10-02) + const rt0 = (await api('/api/admin/rates', null, adminH)).j.rates; + ok(rt0.visitCostPerVisit === 3 && rt0.doorPackCost === 4 && rt0.goldenDoorCost === 6 && rt0.goldenBonusCandy === 2 && rt0.sdSeasonEnd === '2026-11-01', 'rates: visit 3, door pack 4, Golden Door 6, golden bonus 2, season end 2026-11-01', JSON.stringify({ v: rt0.visitCostPerVisit, d: rt0.doorPackCost, g: rt0.goldenDoorCost, b: rt0.goldenBonusCandy, e: rt0.sdSeasonEnd })); + await api('/api/admin/rates', { method: 'PATCH', data: { sdSeasonEnd: '2099-01-01', doorCapPerDay: 15, doorRepeatDays: 7 } }, adminH); // in season whatever today is + const mkPack = async (title, placement) => { let x = await api('/api/admin/campaigns', { type: 'visits', name: title, targetUrl: SD + '/' + placement, title, count: 20, placement }, adminH); + if (!(x.j && x.j.ok)) x = await api('/api/admin/campaigns', { type: 'visits', name: title, targetUrl: 'https://rmcircle.team/contract', title, count: 20, placement }, adminH); return x.j; }; + const gp = await mkPack('QA golden door', 'golden'), dp = await mkPack('QA door pack', 'doors'); + ok(gp && gp.ok && gp.campaign.placement === 'golden' && gp.campaign.budget === 120 && gp.campaign.doorOnly === true, 'Golden Door pack: 20 doors = 120 credits, placement golden', JSON.stringify(gp && gp.campaign && { pl: gp.campaign.placement, budget: gp.campaign.budget, doorOnly: gp.campaign.doorOnly })); + ok(dp && dp.ok && dp.campaign.placement === 'doors' && dp.campaign.budget === 80, 'door pack: 20 doors = 80 credits, placement doors', JSON.stringify(dp && dp.campaign && { pl: dp.campaign.placement, budget: dp.campaign.budget })); + const badPl = await api('/api/admin/campaigns', { type: 'visits', name: 'x', targetUrl: 'https://rmcircle.team/contract', title: 'x', count: 20, placement: 'roof' }, adminH); + ok(badPl.status === 400 && /Pick where/.test(badPl.j && badPl.j.error || ''), 'unknown placement refused'); + // a member buys a door pack with their own credits (charged up front, 4 a door) and tops it up at the door price + const before = (await api('/api/my/campaigns', null, { Cookie: playerCookie })).j; + let mp = await api('/api/my/campaigns', { type: 'visits', name: 'QA member doors', targetUrl: SD + '/member-doors', title: 'QA member doors', count: 20, placement: 'doors', budget: 80 }, { Cookie: playerCookie }); + if (!(mp.j && mp.j.ok)) mp = await api('/api/my/campaigns', { type: 'visits', name: 'QA member doors', targetUrl: 'https://rmcircle.team/contract', title: 'QA member doors', count: 20, placement: 'doors', budget: 80 }, { Cookie: playerCookie }); + const mpc = mp.j && mp.j.campaign; + const after = (await api('/api/my/campaigns', null, { Cookie: playerCookie })).j; + ok(mpc && mpc.placement === 'doors' && mpc.budget === 80 && before.availableCredits - after.availableCredits === 80, 'member door pack charged 80 up front', JSON.stringify({ c: mpc && { pl: mpc.placement, budget: mpc.budget }, err: mp.j && mp.j.error, avail: [before.availableCredits, after.availableCredits] })); + const tu = (await api('/api/my/campaigns/' + (mpc && mpc.id) + '/topup', { credits: 12 }, { Cookie: playerCookie })).j; + ok(tu && tu.ok && tu.visits === 3 && tu.added === 12 && tu.total === 23, 'door pack top-up buys doors at 4 credits', JSON.stringify(tu)); + const T_GOLD = gp.campaign.id, T_DOORS = [dp.campaign.id, mpc && mpc.id]; + // a fresh player knocks: golden first, then door packs, then the existing chain; each pack once per Central day + const knocker = 'qa-knock@example.com'; const knockCookie = await signIn(knocker, 'qaknock'); + const cbStart = callbacks.length; + async function knock(email) { + const n = crypto.randomBytes(12).toString('hex'); + const o = (await api('/api/door/open?t=' + encodeURIComponent(mint({ kind: 'door', memberId: 88, email, nonce: n, ret: SD + '/play?door=' + n })))).j; + if (!o || o.mode !== 'visit') return { o }; + await sleep(2200); + const c2 = (await api('/api/door/challenge?n=' + n)).j; + const d = (await api('/api/door/done', { n, answer: c2.options.indexOf(CAP[c2.prompt]) })).j; + const rc2 = d && d.ret ? verify(new URL(d.ret).searchParams.get('r')) : null; + const cbx = callbacks.map(x => JSON.parse(x.raw)).find(x => x.nonce === n) || null; + return { o, d, rc: rc2, cb: cbx }; + } + const k1 = await knock(knocker); + ok(k1.o.golden === true && k1.o.bonus === 2 && k1.o.credits === 6 && k1.o.title === 'QA golden door', 'door 1: the Golden Door first (open: golden, bonus 2, credits 6)', JSON.stringify(k1.o && { title: k1.o.title, golden: k1.o.golden, bonus: k1.o.bonus, credits: k1.o.credits })); + ok(k1.cb && k1.cb.golden === true && k1.cb.bonus === 2 && k1.cb.credits === 6 && k1.cb.campaignId === T_GOLD && Object.keys(k1.cb).sort().join() === 'bonus,campaignId,credits,golden,host,memberId,nonce', 'Golden Door callback {.., credits: 6, golden: true, bonus: 2}', k1.cb && JSON.stringify(k1.cb)); + ok(k1.rc && k1.rc.kind === 'door-receipt' && k1.rc.golden === true && k1.rc.bonus === 2 && k1.rc.credits === 6 && k1.rc.campaignId === T_GOLD, 'Golden Door receipt carries golden, bonus, credits 6', JSON.stringify(k1.rc && { golden: k1.rc.golden, bonus: k1.rc.bonus, credits: k1.rc.credits })); + ok(k1.d && k1.d.golden === true && k1.d.bonus === 2 && k1.d.credits === 6, 'done response says golden too'); + const k2 = await knock(knocker), k3 = await knock(knocker); + ok(k2.cb && T_DOORS.includes(k2.cb.campaignId) && k2.cb.credits === 4 && !('golden' in k2.cb) && Object.keys(k2.cb).sort().join() === 'campaignId,credits,host,memberId,nonce' && k2.o.credits === 4 && !k2.o.golden, 'door 2: a door pack (credits 4, no golden fields)', JSON.stringify(k2.cb)); + ok(k2.rc && k2.rc.credits === 4 && !('golden' in k2.rc), 'door pack receipt credits 4'); + ok(k3.cb && T_DOORS.includes(k3.cb.campaignId) && k3.cb.campaignId !== k2.cb.campaignId && k3.cb.credits === 4, 'door 3: the other door pack, not the same one twice in a day', JSON.stringify(k3.cb)); + const k4 = await knock(knocker); + ok(k4.cb && ![T_GOLD].concat(T_DOORS).includes(k4.cb.campaignId) && k4.cb.credits === 3 && !k4.o.golden, 'door 4: packs used today, so the existing chain (a visit pack, credits 3)', JSON.stringify(k4.cb)); + await api('/api/admin/rates', { method: 'PATCH', data: { doorRepeatDays: 0 } }, adminH); // ordinary packs may repeat at once; door packs still wait for tomorrow + const k5 = await knock(knocker); + ok(!k5.cb || ![T_GOLD].concat(T_DOORS).includes(k5.cb.campaignId), 'with no repeat cooldown, golden and door packs still once per Central day', JSON.stringify(k5.cb || k5.o)); + await api('/api/admin/rates', { method: 'PATCH', data: { doorRepeatDays: 7 } }, adminH); + // advertiser stats on the member's pack + const mine = (await api('/api/my/campaigns', null, { Cookie: playerCookie })).j; + const myPack = mine && mine.campaigns.find(c => c.id === (mpc && mpc.id)); const ds = mine && mine.doorStats && mine.doorStats[mpc && mpc.id]; + ok(myPack && myPack.placement === 'doors' && myPack.doorOnly && ds && ds.doors === 1 && ds.players === 1 && myPack.imps === 1, 'campaign stats: doors opened 1, unique players 1', JSON.stringify({ ds, imps: myPack && myPack.imps })); + // in season door packs never reach the Earn tab or refuels: pause every ordinary pack, then a fresh member finds nothing there + const allCamps = (await api('/api/admin/campaigns', null, adminH)).j.campaigns.filter(c => c.type === 'visits' && c.status === 'active' && c.placement === 'all'); + for (const c of allCamps) await api('/api/admin/campaigns/' + c.id + '/pause', {}, adminH); + const earner = 'qa-earner@example.com'; const earnCookie = await signIn(earner, 'qaearner'); + const ev = (await api('/api/my/visits', null, { Cookie: earnCookie })).j; + ok(ev && ev.ad === null, 'in season: the Earn tab never serves a door pack or Golden Door', JSON.stringify(ev && ev.ad)); + await api('/api/admin/rates', { method: 'PATCH', data: { refuelCapPerDay: 20 } }, adminH); + const nrf = crypto.randomBytes(12).toString('hex'); + const rfx = (await api('/api/refuel/open?t=' + encodeURIComponent(mint({ kind: 'refuel', memberId: 89, email: earner, nonce: nrf, ret: SD + '/play?refuel=' + nrf }, DRSECRET)))).j; + ok(rfx && rfx.none && rfx.why === 'empty', 'in season: refuels never serve a door pack or Golden Door', JSON.stringify(rfx)); + const pdl = (await api('/api/admin/campaigns', null, adminH)).j.campaigns.filter(c => c.doorOnly); + ok(pdl.length >= 3, 'door-only packs are flagged doorOnly (kept off the PassiveDrip listing)', String(pdl.length)); + // from sdSeasonEnd they are ordinary visits: Earn and refuels serve them, doors no longer favour them, no golden fields + await api('/api/admin/rates', { method: 'PATCH', data: { sdSeasonEnd: today } }, adminH); + const ev2 = (await api('/api/my/visits', null, { Cookie: earnCookie })).j; + ok(ev2 && ev2.ad && ['QA golden door', 'QA door pack', 'QA member doors'].includes(ev2.ad.title), 'after sdSeasonEnd: the Earn tab serves door packs as normal visits', JSON.stringify(ev2 && ev2.ad && ev2.ad.title)); + const nrf2 = crypto.randomBytes(12).toString('hex'); + const rfy = (await api('/api/refuel/open?t=' + encodeURIComponent(mint({ kind: 'refuel', memberId: 89, email: earner, nonce: nrf2, ret: SD + '/play?refuel=' + nrf2 }, DRSECRET)))).j; + ok(rfy && rfy.mode === 'visit' && ['QA golden door', 'QA door pack', 'QA member doors'].includes(rfy.title), 'after sdSeasonEnd: refuels serve them too', JSON.stringify(rfy && { mode: rfy.mode, title: rfy.title, why: rfy.why })); + const k6 = await knock('qa-late@example.com'); + ok(k6.o && k6.o.mode === 'visit' && !k6.o.golden && k6.cb && !('golden' in k6.cb) && [6, 4].includes(k6.cb.credits), 'after sdSeasonEnd: a door gets an ordinary door (no golden), credits still what the pack paid', JSON.stringify(k6.cb || k6.o)); + const late = await api('/api/admin/campaigns', { type: 'visits', name: 'late', targetUrl: 'https://rmcircle.team/contract', title: 'late', count: 20, placement: 'golden' }, adminH); + ok(late.status === 400 && /season is over/.test(late.j && late.j.error || ''), 'after sdSeasonEnd: new door packs refused'); + const gpNow = (await api('/api/admin/campaigns', null, adminH)).j.campaigns.find(c => c.id === T_GOLD); + ok(gpNow && gpNow.placement === 'golden' && gpNow.doorOnly === false, 'after sdSeasonEnd: placement kept, doorOnly false'); + await api('/api/admin/rates', { method: 'PATCH', data: { sdSeasonEnd: '2026-11-01' } }, adminH); +} catch (e) { fails++; console.log('FAIL exception: ' + e.message + '\n' + (e.stack || '').split('\n').slice(1, 3).join('\n')); } finally { cleanup(); } console.log(fails ? '\n' + fails + ' failure(s)' : '\nall door checks passed'); process.exit(fails ? 1 : 0); diff --git a/server.js b/server.js index 8c39196..bb5e38e 100644 --- a/server.js +++ b/server.js @@ -1295,7 +1295,8 @@ async function gkCallback(cbUrl, receipt) { // lands first. Costumes are bought with ad credits through ads.gamePurchase, exactly like Gem Kingdom Crowns. const SD_SECRET = () => String(process.env.SD_SSO_SECRET || '').trim(); const SD_URL = () => String(process.env.SD_URL || 'https://spookydoors.com').replace(/\/+$/, ''); -const SD_SEASON = { start: '2026-10-17', end: '2026-11-01' }; // Central days, end exclusive (through Halloween night) +const SD_SEASON = { start: '2026-10-04', end: '2026-11-01' }; // Central days, end exclusive (through Halloween night); start moved up from 10-17 (Marty, 2026-10-02) +const sdGoldenBonus = () => { const n = Number(ads.rates().goldenBonusCandy); return Number.isFinite(n) && n >= 0 ? Math.round(n) : 2; }; // extra candy on a Golden Door const sdSign = p => drB64u(crypto.createHmac('sha256', SD_SECRET()).update(p).digest()); function sdMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims)); return drB64u(payload) + '.' + sdSign(payload); } function sdOpen(token, expiredMsg) { @@ -1358,10 +1359,18 @@ function sdPage(res, code, title, inner) { } +// the generic season window (2026-10-02), shared by the Games card and the Promo tools card: 'live' while today (Central) is in +// [start, end), 'preview' before start for the admin only, 'hidden' otherwise (and for everyone from end on) +function seasonState(season, day, admin) { + if (!season) return 'live'; + if (day >= season.end) return 'hidden'; + if (day < season.start) return admin ? 'preview' : 'hidden'; + return 'live'; +} // -- the games registry (2026-10-01). Add a game here; launch it by adding its slug to site config gamesLive. function GAMES() { return [ - { slug: 'spookydoors', name: 'Spooky Doors', tag: 'Halloween \u00b7 Oct 17 to 31', blurb: 'Trick or treat! Walk the street, knock on doors and fill your candy bucket. Every door is a short visit to a member\u2019s page or ad, and candy climbs a ladder with POL at set levels. Gone after Halloween night.', + { slug: 'spookydoors', name: 'Spooky Doors', tag: 'Halloween \u00b7 Oct 4 to 31', blurb: 'Trick or treat! Walk the street, knock on doors and fill your candy bucket. Every door is a short visit to a member\u2019s page or ad, and candy climbs a ladder with POL at set levels. Gone after Halloween night.', art: SD_URL() + '/og-spookydoors.jpg', play: '/api/my/spookydoors', pays: 'POL at set candy levels', season: { start: SD_SEASON.start, end: SD_SEASON.end }, progress: sdProgress }, { slug: 'driprunner', name: 'Drip Runner', tag: 'Arcade runner', blurb: 'Hop the network, dodge the bots, clear chapters. Each first clear drips POL into your game balance, and a refuel on a member\u2019s page keeps your run alive.', art: DR_URL() + '/og-driprunner.jpg?v=20261002', artPos: 'left', play: '/api/my/driprunner', pays: 'POL to your wallet at 0.25', progress: drProgress }, @@ -2660,6 +2669,16 @@ const server = http.createServer(async (req, res) => { return gkPage(res, 200, 'Crowns added', '

Gem Kingdom · Crown Shop

Paid!

+' + Number(c.crowns).toLocaleString('en-US') + ' Crowns

Taking you back to your kingdom...

Back to Gem Kingdom'); } // -- Spooky Doors hand-off (2026-10-02): sign the member across; the game verifies with SD_SSO_SECRET + // -- Spooky Doors promo card in Promo tools (2026-10-02): shown on the same season window as the Games card (admin preview + // before the start). The member's link is SD_URL/r/, built in the page from their own username. + if (p === '/api/my/spookydoors/promo' && req.method === 'GET') { + const s = await auth.fromRequest(req); + if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' }); + const admin = !!(ADMIN_EMAIL && String(s.email).toLowerCase() === ADMIN_EMAIL); + const ss = seasonState(SD_SEASON, todayCT(), admin); + if (ss === 'hidden') return json(res, 200, { show: false }); + return json(res, 200, { show: true, preview: ss === 'preview', base: SD_URL(), image: SD_URL() + '/og-spookydoors.jpg', season: { start: SD_SEASON.start, end: SD_SEASON.end } }); + } if (p === '/api/my/spookydoors' && req.method === 'GET') { const s = await auth.fromRequest(req); // a newcomer from a Spooky Doors post carries the poster's ?ref through to /my, where the viral-link rule sets the sponsor @@ -2821,8 +2840,11 @@ const server = http.createServer(async (req, res) => { const status = await ads.visitStatus(email, 'door'); // doors have their own daily allowance if (!t) { if (status.count >= status.cap) return json(res, 200, { none: true, why: 'cap', ret: sdJoin(c.ret, 'cap=1') }); - const ad = await ads.serveVisit(email, viewerGeo(req), { kind: 'door' }); // doors may repeat a campaign after doorRepeatDays - if (ad) t = { kind: 'visit', email, memberId: Number(c.memberId) || 0, id: ad.id, title: ad.title, target: ad.target, ts: Date.now(), ret: c.ret, challenge: null, done: false }; + // door packs + Golden Doors first (golden, then doors; once per player per Central day), then the existing chain + const pack = await ads.serveDoorPack(email, viewerGeo(req)); + const ad = pack || await ads.serveVisit(email, viewerGeo(req), { kind: 'door' }); // doors may repeat a campaign after doorRepeatDays + if (ad) t = { kind: 'visit', email, memberId: Number(c.memberId) || 0, id: ad.id, title: ad.title, target: ad.target, ts: Date.now(), ret: c.ret, challenge: null, done: false, + credits: pack ? pack.credits : (ads.rates().visitCostPerVisit || 3), golden: !!(pack && pack.golden), bonus: (pack && pack.golden) ? sdGoldenBonus() : 0 }; else { // every visit pack already visited: a member video ad instead, one door per video per person const v = await ads.serveVideo(Object.assign({ excludeEmail: email, refuel: true }, viewerGeo(req))); if (v) t = { kind: 'video', email, memberId: Number(c.memberId) || 0, id: v.id, title: v.title, videoUrl: v.videoUrl, secs: v.watchSecs, width: v.width, height: v.height, ts: Date.now(), ret: c.ret, challenge: null, done: false }; @@ -2838,7 +2860,7 @@ const server = http.createServer(async (req, res) => { const doors = { used: status.count, cap: status.cap }; if (t.kind === 'video') return json(res, 200, { mode: 'video', title: t.title, host: t.host || null, doors, video: { url: t.videoUrl, width: t.width, height: t.height }, dwell: t.secs, ret: t.ret, elapsed: Math.floor((Date.now() - t.ts) / 1000) }); if (t.kind === 'house') return json(res, 200, { mode: 'visit', house: true, program: t.program, title: t.title, host: null, doors, target: t.target, dwell: ads.rates().visitDwellSeconds || 8, ret: t.ret, elapsed: Math.floor((Date.now() - t.ts) / 1000) }); - return json(res, 200, { mode: 'visit', title: t.title, host: t.host || null, doors, target: t.target, dwell: ads.rates().visitDwellSeconds || 8, ret: t.ret, elapsed: Math.floor((Date.now() - t.ts) / 1000) }); + return json(res, 200, Object.assign({ mode: 'visit', title: t.title, host: t.host || null, doors, target: t.target, dwell: ads.rates().visitDwellSeconds || 8, ret: t.ret, elapsed: Math.floor((Date.now() - t.ts) / 1000), credits: t.credits || (ads.rates().visitCostPerVisit || 3) }, t.golden ? { golden: true, bonus: t.bonus } : {})); } if (p === '/api/door/challenge' && req.method === 'GET') { const n = String(u.searchParams.get('n') || ''); const t = doorTokens.get(n); @@ -2869,16 +2891,18 @@ const server = http.createServer(async (req, res) => { } else { const r = await ads.completeVisit(t.email, t.id, { reward: false, kind: 'door', note: 'Spooky Doors door' }); if (r.error) return json(res, 400, r); - credits = ads.rates().visitCostPerVisit || 3; + credits = r.unit || ads.rates().visitCostPerVisit || 3; // the per-door price actually charged (door pack 4, Golden Door 6, a visit pack 3) + if (t.golden && r.golden === false) t.golden = false; // the season closed between open and done: an ordinary door } t.done = true; const host = t.host || null; const house = t.kind === 'house' ? { house: true, program: t.program } : {}; // a house ad: credits 0, host null, campaignId 0 - const posted = await sdCallback(Object.assign({ nonce, memberId: t.memberId, campaignId: t.id, credits, host }, house)); - const receipt = sdMint(Object.assign({ kind: 'door-receipt', nonce, memberId: t.memberId, campaignId: t.id, credits, host }, house), 24 * 3600000); + const gold = (t.kind === 'visit' && t.golden) ? { golden: true, bonus: t.bonus } : {}; // a Golden Door: the game adds `bonus` candy + const posted = await sdCallback(Object.assign({ nonce, memberId: t.memberId, campaignId: t.id, credits, host }, house, gold)); + const receipt = sdMint(Object.assign({ kind: 'door-receipt', nonce, memberId: t.memberId, campaignId: t.id, credits, host }, house, gold), 24 * 3600000); t.doneRet = sdJoin(t.ret, 'ok=1&r=' + encodeURIComponent(receipt)); doorTokens.set(nonce, t); - return json(res, 200, Object.assign({ ok: true, posted, host, ret: t.doneRet }, house)); + return json(res, 200, Object.assign({ ok: true, posted, host, credits, ret: t.doneRet }, house, gold)); } // -- Games hub (2026-10-01): the registry is here, the live list is site config (gamesLive) if (p === '/api/my/games' && req.method === 'GET') { @@ -2891,8 +2915,8 @@ const server = http.createServer(async (req, res) => { const dayLabel = (d, back) => { const t = new Date(d + 'T12:00:00Z'); if (back) t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); }; for (const g of GAMES()) { // a seasonal game (2026-10-02) shows only while today (Central) is in [start, end); before start the admin sees a preview, after end nobody - let seasonPreview = false; - if (g.season) { if (day >= g.season.end) continue; if (day < g.season.start) { if (!admin) continue; seasonPreview = true; } } + const ss = seasonState(g.season, day, admin); if (ss === 'hidden') continue; + const seasonPreview = ss === 'preview'; const isLive = live.has(g.slug); if (!isLive && !admin) continue; const card = Object.assign({}, g, { live: isLive, preview: !isLive || seasonPreview }); if (g.season) { card.season = Object.assign({}, g.season, { opens: dayLabel(g.season.start), ends: dayLabel(g.season.end, true) }); if (seasonPreview) card.previewNote = 'preview, opens ' + card.season.opens; } @@ -3516,6 +3540,7 @@ const server = http.createServer(async (req, res) => { out.clickSources = await coach.clickSources(ids); out.hours = await ads.hoursFor(ids); // on-site views per UTC hour, last 7 days out.geo = await ads.geoFor(ids); // on-site serves per viewer country + out.doorStats = await ads.doorStats(all.filter(c => c.type === 'visits').map(c => c.id)); // Spooky Doors: doors opened + unique players per pack { const t = geo.tierLists(siteConfig()); out.tiers = { t1: [...t.t1], t2: [...t.t2] }; out.geoReady = geo.status().loaded; } const pool = await ads.balances((await myMemberIds(s)).ids, s.email); out.purchasedCredits = pool.total;