document.addEventListener("DOMContentLoaded", function () {
const timerReset = parseInt(24);
const countdownElements = document.querySelectorAll(".svcountdown");
const countdownElements2 = document.querySelectorAll('a[href="#svcountdown"]');
const countdownCodeElements = document.querySelectorAll(".svcountdowncode");
const countdownCodeElements2 = document.querySelectorAll('a[href="#svcountdowncode"]');
countdownCodeElements.forEach((element) => {
element.textContent = "GONEBYMIDNIGHT";
});
countdownCodeElements2.forEach((element) => {
element.textContent = "GONEBYMIDNIGHT";
});
function updateCountdown() {
const now = new Date();
const endTime = new Date();
if (timerReset == 1) {
endTime.setHours(endTime.getHours() + 1,0,0,0);
} else {
endTime.setHours(24, 0, 0, 0);
}
const timeLeft = endTime - now;
const hours = Math.floor(timeLeft / (1000 * 60 * 60));
const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
let text = "in ";
if (hours > 0) {
text += `${hours}h `;
}
if (minutes > 0) {
text += `${minutes}m `;
}
text += `${seconds}s`;
countdownElements.forEach((element) => {
element.textContent = text;
});
countdownElements2.forEach((element) => {
element.textContent = text;
});
}
updateCountdown();
setInterval(updateCountdown, 1000);
});