// Auto-expire after 10 minutes setTimeout(() => if (codes.get(code)?.status === 'pending') codes.delete(code);
document.getElementById('refreshBtn').addEventListener('click', () => if (pollInterval) clearInterval(pollInterval); fetchNewCode(); ); activate viaplay
activateBtn.addEventListener('click', () => code.length !== 6 ); // Auto-expire after 10 minutes setTimeout(() => if
function startPolling(code) pollInterval = setInterval(async () => try const res = await fetch('/api/check-code', method: 'POST', headers: 'Content-Type': 'application/json' , body: JSON.stringify( code ) ); const data = await res.json(); if (data.activated) clearInterval(pollInterval); document.getElementById('statusMessage').innerHTML = '✅ ACTIVATED! Enjoy Viaplay.'; document.getElementById('statusMessage').className = 'status activated'; document.getElementById('activationCode').style.opacity = '0.5'; if (pollInterval) clearInterval(pollInterval)