Skip to content

Instantly share code, notes, and snippets.

@sunfkny
Created February 23, 2022 08:15
Show Gist options
  • Save sunfkny/1376a15f965afdd1d07df461563e3601 to your computer and use it in GitHub Desktop.
Save sunfkny/1376a15f965afdd1d07df461563e3601 to your computer and use it in GitHub Desktop.
Cookie File for youtube-dl & you-get
(function() {
let S = '# Netscape HTTP Cookie File\n';
for (raw_cookie of document.cookie.split(';')) {
let cookie = raw_cookie.trim();
let separator = cookie.indexOf('=');
let name = cookie.substring(0, separator);
let value = cookie.substring(separator + 1);
let domain = window.location.hostname;
// hopefully this will convert domains like `www.test.com` and `test.com` into `.test.com`
domain = domain.replace('www.', '.');
if (domain[0] !== '.') {
domain = '.' + domain;
}
// netscape cookie file format:
// # domain HTTP PATH SECURE timestamp name value
// .test.com TRUE / FALSE 123456789 token 1234abcdef
S += `${domain}\tTRUE\t/\tTRUE\t0\t${name}\t${value}\n`
}
console.log(S)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment