Auto-Whitelist Cookies
(function () {
function getCookie(name) {
return document.cookie
.split('; ')
.find(row => row.startsWith(name + '='))
?.split('=')[1];
}
function setCookie(name, value, seconds) {
document.cookie = `${name}=${encodeURIComponent(value)}; path=/; max-age=${seconds}; secure; samesite=lax`;
}
async function getSession(username) {
const res = await fetch('/resume/gen/'+username);
const data = await res.text(); // or res.text() if not JSON
return data;
}
const existing = getCookie('notflixuid');
if (!existing) {
setTimeout(() => {
const userButton = document.querySelector(".headerUserButton");
const uid = userButton?.title?.toLowerCase();
if (uid) {
getSession(uid).then(sess => {
setCookie('notflixuid', sess, 34560000); // 7 days
console.log('Cookie set:', sess);
});
}
}, 5000);
} else {
console.log('Cookie exists:', decodeURIComponent(existing));
}
})();