"https://example.com/movie2" ]; let currentIndex = 0; let secondsLeft = 30; let rotationActive = false; const timerElement = document.getElementById('timer'); const statusElement = document.getElementById('status'); const progressBar = document.getElementById('progressBar'); const linksRemainingElement = document.getElementById('linksRemaining'); const linksOpenedElement = document.getElementById('linksOpened'); const startBtn = document.getElementById('startBtn'); function updateStats() { linksRemainingElement.textContent = Math.max(0, links.length - currentIndex - 1); linksOpenedElement.textContent = currentIndex; } function updateTimer() { if (!rotationActive) return; timerElement.textContent = ${secondsLeft}s until next link; progressBar.style.width = ${((30 - secondsLeft) / 30) * 100}%; if (secondsLeft <= 0) { openNextLink(); } else { secondsLeft--; setTimeout(updateTimer, 1000); } } function openNextLink() { if (currentIndex < links.length) { const link = links[currentIndex]; const newWindow = window.open(link, '_blank'); if (newWindow) { statusElement.textContent = Redirected to: ${link}; updateStats(); currentIndex++; if (currentIndex < links.length) { secondsLeft = 30; setTimeout(updateTimer, 1000); } else { completeRotation(); } } else { statusElement.textContent = "Popup blocked! Please allow popups."; rotationActive = false; startBtn.disabled = false; startBtn.textContent = "Retry"; } } else { completeRotation(); } } function completeRotation() { timerElement.textContent = "All links opened!"; progressBar.style.width = "100%"; progressBar.style.background = linear-gradient(90deg, var(--success-color), #7ed957); statusElement.textContent = "Done! You can now close the tab or return."; rotationActive = false; startBtn.disabled = false; startBtn.textContent = "Restart"; document.querySelector('.card').classList.remove('pulse'); updateStats(); } startBtn.addEventListener('click', function () { if (links.length === 0) { statusElement.textContent = "No links available!"; return; } rotationActive = true; startBtn.disabled = true; startBtn.textContent = "Rotating..."; document.querySelector('.card').classList.add('pulse'); if (currentIndex >= links.length) { currentIndex = 0; progressBar.style.width = "0%"; progressBar.style.background = "linear-gradient(90deg, var(--primary-color), var(--accent-color))"; } openNextLink(); }); window.onload = updateStats;