export cookies with https://github.com/hrdl-github/cookies-txt
import cookies with
function importCookies(cookieFileContent) {
// Split the content into lines
const lines = cookieFileContent.split('\n');
// Filter out comments and empty lines
const cookieLines = lines.filter(line =>
line.trim() && !line.startsWith('#')
);
// Process each cookie line
cookieLines.forEach(line => {
const parts = line.split('\t');
if (parts.length >= 6) {
const [domain, , path, secure, , name, value] = parts;
// Create cookie string
const cookieString = `${name}=${value}; path=${path}; domain=${domain}${secure.toLowerCase() === 'true' ? '; secure' : ''}`;
try {
document.cookie = cookieString;
console.log(`Attempting to set cookie: ${cookieString}`);
} catch (e) {
console.error(`Failed to set cookie: ${name}`, e);
}
}
});
}
// Your cookie file content
const cookieFileContent = `# Netscape HTTP Cookie File
# https://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file! Do not edit.
`;
importCookies(cookieFileContent);