Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

⏳ Please wait...
`; document.body.appendChild(modal); const modalBackdrop = document.getElementById('backModal'); const countdownEl = document.getElementById('countdown'); const exitBtn = document.getElementById('exitBtn'); let allowBack = false; let timerInterval; // Initial history state history.replaceState({ preventBack: true }, ''); history.pushState({ preventBack: true }, ''); function openModal() { modalBackdrop.style.display = 'flex'; startCountdown(30); } function startCountdown(seconds) { let timeLeft = seconds; countdownEl.textContent = timeLeft; exitBtn.disabled = true; exitBtn.style.opacity = '0.5'; exitBtn.textContent = "Exit Now"; clearInterval(timerInterval); timerInterval = setInterval(() => { timeLeft--; countdownEl.textContent = timeLeft; if (timeLeft <= 0) { clearInterval(timerInterval); exitBtn.disabled = false; exitBtn.style.opacity = '1'; exitBtn.textContent = "Exit Page"; } }, 1000); } window.addEventListener('popstate', (event) => { if (allowBack) return; history.pushState({ preventBack: true }, ''); openModal(); }); exitBtn.addEventListener('click', () => { if (!exitBtn.disabled) { allowBack = true; history.back(); } }); });

1 thought on “Hello world!”

Leave a Comment