// ═══════════════════════════════════════════════════════════════════════ // RE TIMER — Random Encounter countdown // ═══════════════════════════════════════════════════════════════════════ let reTimerEl = null; function setupRETimer() { if (!CFG.reTimer) return; if (document.getElementById('hv-re-timer')) return; reTimerEl = document.createElement('div'); reTimerEl.id = 'hv-re-timer'; reTimerEl.style.cssText = css({ position: 'fixed', top: '2px', left: '50%', transform: 'translateX(-50%)', zIndex: '99999', background: '#1a1a2e', color: '#0f0', padding: '2px 10px', borderRadius: '0 0 6px 6px', fontSize: '10px', fontFamily: 'monospace', opacity: '0.9', }); reTimerEl.textContent = 'RE: --:--'; document.body.appendChild(reTimerEl); updateRETimer(); setInterval(updateRETimer, 30000); } function updateRETimer() { if (!reTimerEl) return; const now = Date.now(); const dt = document.body.textContent || ''; // Detect dawn if (dt.includes('Dawn of a New Day') || dt.includes('A new day dawns')) { try { localStorage[SP + 'lastDawn'] = JSON.stringify(now); } catch (e) {} } const ld = JSON.parse(localStorage[SP + 'lastDawn'] || now); const ms = (now - ld) / 60000; const nr = 30 - (ms % 30); if (nr < 1) { reTimerEl.textContent = '⚡ RE READY!'; reTimerEl.style.color = '#f00'; reTimerEl.style.fontWeight = 'bold'; } else { const mn = Math.floor(nr); const sc = Math.floor((nr - mn) * 60); reTimerEl.textContent = `RE: ${String(mn).padStart(2, '0')}:${String(sc).padStart(2, '0')}`; reTimerEl.style.color = '#0f0'; reTimerEl.style.fontWeight = 'normal'; } }