Mystery Hunt Box + Ad Detective, badge tiers
Finish the day's Code Hunts to unlock one box a day. It opens to an Ad Detective case on one site with a fixed 0.15 POL reward shown up front: visit (the embed records the visit after the dwell, no code), then answer one question, one attempt. Paid inside the house cap, never counted as a find. 34-question bank seeded from lib/detective-bank.json; a hunter never repeats a question until they have seen every one for that site. Admin panel with per-question stats and retire/restore. New badges (all ledger-derived): Detective, Sleuth, Investigator, Master Detective; Scout, Guide, Trail Boss; Week Sweep; 7-Day Streak. Badges already earned on deploy are marked announced without posting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,12 +36,21 @@
|
||||
box.addEventListener('click', function () { var done = function () { var s = box.querySelector('[data-ph-hint]'); if (s) s.textContent = 'copied, paste it on your board'; }; try { navigator.clipboard.writeText(code).then(done, done); } catch (e) { done(); } });
|
||||
el.appendChild(box);
|
||||
}
|
||||
function note(slot) {
|
||||
var el = slotEl(slot); el.innerHTML = '';
|
||||
var box = document.createElement('div'); box.setAttribute('role', 'note');
|
||||
box.style.cssText = 'display:inline-flex;align-items:center;gap:10px;padding:12px 14px;border-radius:14px;background:linear-gradient(135deg,#1a0f3d,#2b1a63);color:#f1eefb;font:600 13px/1.35 system-ui,-apple-system,"Segoe UI",sans-serif;box-shadow:0 8px 30px rgba(130,71,229,.45),0 0 0 1px rgba(255,255,255,.08);max-width:100%';
|
||||
box.innerHTML = '<img src="' + API + '/img/coin-sm.png" alt="" width="26" height="26" style="width:26px;height:26px;object-fit:contain;flex:none"><span><span style="color:#f3be43">Ad Detective: visit recorded.</span><br><span style="font-weight:500;opacity:.85">Look around this page, then answer your question on your PolHunter board.</span></span>';
|
||||
el.appendChild(box);
|
||||
}
|
||||
var tries = 0, pending = null, done = false;
|
||||
// phones freeze a background tab's timers: when the hunter comes back to this tab, ask right away
|
||||
document.addEventListener('visibilitychange', function () { if (document.visibilityState === 'visible' && !done) { clearTimeout(pending); ask(); } });
|
||||
function ask() {
|
||||
tries++; if (tries > 80 || done) return;
|
||||
fetch(API + '/api/embed/code?t=' + encodeURIComponent(t), { mode: 'cors', credentials: 'omit' }).then(function (r) { return r.json(); }).then(function (r) {
|
||||
// an Ad Detective case: no code, just the receipt; the question is waiting on the hunter's board
|
||||
if (r && r.visited) { done = true; note(Number(r.slot) % slots); try { sessionStorage.removeItem('ph.token'); } catch (e) {} return; }
|
||||
if (r && r.code) { done = true; render(r.code, Number(r.slot) % slots); try { sessionStorage.removeItem('ph.token'); } catch (e) {} return; }
|
||||
if (r && r.wait) { pending = setTimeout(ask, Math.min(r.wait, 5) * 1000); return; }
|
||||
// expired / gone / wrong origin: say nothing
|
||||
|
||||
Reference in New Issue
Block a user