Skip to content

Commit

Permalink
Update top sites cookies (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey authored Oct 7, 2024
1 parent 0ecf9bd commit 0f56c6e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 47 deletions.
33 changes: 19 additions & 14 deletions scripts/parse-top.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"accounts.google.com": "__Ulll-UUUU=0:lllllUlUUUlUU_llUU0UUUl0lU0UUl:UUlUlUl0UU0UlUlU",
"apple.com": "lll=UU",
"cloudflare.com": "__ll_ll=llUUlU0U0UlUlUll.lllUUUUlUUUlUUlUU000UlllUl-0000000000-0-UllU00UUllllUUUllUl0l0llllUUlU0UlUUUlUUl0Ull/l0+lllllUlUlU0l0l00ll+0U0ll/l0UlU00lllllllUUll0lU00lUUUllUUlUUl",
"docs.google.com": "__Ulll-UUUU=0:lUlUlU0UUlUllUUlUllUUlUUlU0U:Ul0UllUUllll0UUl",
"drive.google.com": "__Ulll-UUUU=0:U0l0lUUllU0lllUlU0UU00UlllUUlU:lUUUllUlUUUllUUl",
"en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UUU-UU=lll; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0; UllllllUllllUllll=0.000",
"linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0l0ll000-0000-00ll-0000-0l000ll00000\"; llllllll=\"l=0&00000000000000l00l0l0l-l000-00l0-00ll-l0000l000000UUUUlUlUU0llll0UlllUU0UU--UUlUlU\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUU-UUlUlUUl0lUUlUlUllll0lllUUUU\"",
"maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=lU00_U0UllU-lUlUUUllUl0l0U_lUlUUUl00UUU0llllU_UUlUUU0UllUllll0l-_lUlllUU0llll0UlUUllll_UU0U0lU-llUllll00lUllUllUlUlllU_lUUUl0ll0lUUlUlllUUl0llUUl0UU0llUlllllUllUll0UUUllUU",
"microsoft.com": "UUUUU=llllll0; lllll_UllUU=0000000000~ll=00~ll=0000l0l0l0lllll0l000000000l0l00l; lllll_UllUU=0000000000~ll=00~ll=0000l0l0l0lllll0l000000000l0l00l",
"play.google.com": "UUU=000=UllU0l0UU0llUlU0UUU0lUUUl0lUlUUllUlUl0ll0UlUlllUlUlUUlUUllUll-UUll0llll0UllUlUU0U0lUUUUU0Ull0l0l0l0lUU0UlUU000lUUUU0lU_UUlUUlUUl0UU-lUlUU0lUlUllUUUllUUllll00lllU0U0UUU0Ull",
"support.google.com": "UUU=000=l0llUUlUllU0UlllU0U0U0UlU-Ulll0lUlllU0UUllUUlUUUlllllUUUU-UUllUllU0lUU0U0U00lU0UUlUl0l0lUUlUUUUl0lUU0UUllUlUlUUlUlUUUU0ll0l0UU0lllU0lllUUUU0U0lU0U00l0Ul0UlU-U0UllU00lUUl0U; UUU=000=l0llUUlUllU0UlllU0U0U0UlU-Ulll0lUlllU0UUllUUlUUUlllllUUUU-UUllUllU0lUU0U0U00lU0UUlUl0l0lUUlUUUUl0lUU0UUllUlUlUUlUlUUUU0ll0l0UU0lllU0lllUUUU0U0lU0U00l0Ul0UlU-U0UllU00lUUl0U",
"www.google.com": "0U_UUU=0000-00-00-00; UUU=Ullll0Ullll0U0llUllU00U_lllll0lUUlUl0UllUlUUl0lUlUUUl00UUl; UUU=000=lUU0U0U0U0UllUUUlUUlUUU_UlUll_l0U0UU00lUlUlUlllllUUUl00UllllUU_0ll0UllUllUUU-UUUlllU0UlUlUllUlUllUll00UllU0U00llUUl0lU00lUlUUlllUl_U00UUlU0UU0UllUlUU0lUUlUUUl00lUUlUUUU0ll",
"youtu.be": "UUU=0; UUU=ll0UU-l0lUl; UUUUUUU_UUUU0_UUUU=0_llUUlUllU; UUUUUUU_UUUUUUU_UUUUUUUU=UlUUUlUUUlU%22",
"youtube.com": "UUU=0; UUU=l0_UlUUUlUl; UUUUUUU_UUUU0_UUUU=UUUUlUUUlll; UUUUUUU_UUUUUUU_UUUUUUUU=UlUUUlUUUlU%22",
"accounts.google.com": "__Aaaa-AAAA=0:0AaaAaaaAAA0aA0aAA0aaAaAAaaaAA:AAAaAA0AAAaAAa0a",
"amazon.com": "aaaaaaa-aa=000-0000000-0000000; bbbbbbb-bb-bbbb=1111111111b; c22c-ccccc=CCC; dddd=dddddd",
"apple.com": "aaa=AA",
"cloudflare.com": "__aa_aa=aaA0aaAAaAaaaa0aaaaAAAA_0aa0a.0AAA000aAA0aa-0000000000-0.0.0.0-Aaa00aA0aaAaAA0AaaAAAA0AaAaaaAAA.AaAaAaAA_0aAaAaaAA0AAAAaaAaaaaA0aaAAAaAAAaaaaa0AAa0AAAAAaaA0aaA0a0aaaaaAAA",
"docs.google.com": "__Aaaa-AAAA=0:aAAaA00AA0A0AAaAAAaAAAAAaA_AAA:aAAA00AAaaAAaaAA",
"drive.google.com": "__Aaaa-AAAA=0:AA0a0AAaaAaaA0A-AAAA0aaA_0A-aa:0aaAa0aA0aaAAAAa",
"en.wikipedia.org": "AAA-Aaaa-Aaaaaa=00-Aaa-0000; BBB-Bbbb-Bbbbbb-Bbbbbb=11-Bbb-1111; CCC-CC=222; DddDD=DD:DD:Ddd_Ddddddddd:33.33:-333.33:d3; EeeeeeeEeeeeEeeee=4.444",
"istockphoto.com": "aaaaaaa=aAAAAAAaAAAaaa0aa0aAAAa0aAaaaAAA0A%22aaA0aAaaAaa0AAaaaaAAaAaaa0AaaaA%2200a0a00AA00A0aAaAaA0aa%22AAaaAA0000aAa00%220AaAaAAA0AaaAaAAAaaaAaAAa00AaAa0AaaaAaAaAaaaaaaa%22aAaaaAaaAaaaAAAAaAAaaAAaAaaAaaaAAa0A%22--aaA0aaAAAAAaaAAa--a0a%22A%22aAAaAAAa%22AaaAaAA%22%22; bbb=bb=1&bb=1111-11-11B11%2211%2211B; ccc=ccc=22222ccc-2c22-2c22-2222-22c2222c2222; ddd=d=DD%22dDddddDdddD3ddDddd33dddD3dDD33dDd3DDdDdddDdD33D3Dd33DDdd3dDd3dDDdDDDdD3dD3d3D3dDDdd3dddD%223DDDDdd3dD3ddd3dddDdDdD33D3DdDDd3dD3dDddDDdDdDDDdDDDDDDdddDdDdDdD3dddDDDd3DDD3D%22%2233d%22D3DDDDdDDDDDddddDDDdd3DdDDdDDDDdDdddd3ddD3D3DDddd3ddD3D3DDddDddDDDd3DDDDDdD3DDddDdDdDDD3DDDdDDddDDDdDDD3DD33DDddDDD3DDDdDDDdDDD3DDdD%223%223%223&d; eeee=e=eEEEeEee44eE4eeEEeeEEEeEE4444eeE4eE4eEE4%224e%22",
"maps.google.com": "AAA=000=aaaaAa0Aaa0aaaaaaaaaaAAAAAAaaaaAAA0AaAAA0aaaA00AAA0aAAAA0aaA0aAAAAaAAA0aAAAAaaAAaa_AAAAAaA0a0aaaAaaaaa--aa0aAAA0A0AaAA0AAaaAAa0AaAAa0A_aAAAAaAA_aAaAa0AaA0aAa0Aa-AAa0aaaAAaAA-AaaaA0aaAaAA0aaaa",
"play.google.com": "AAA=000=A0AaA-aaaA00AaAAa00A0aaAAaA0AaAaaaa0A_Aa0_AaaAAAaAaa0aa0a-0aAaA0__AaAAaaaaAAaaaaaAAaaa0aAAAa0a_a0aaAAAAAaAaa0aaaaaAaaaaAAA_aAa0aaa0aaa00aaAAAaA0AAAAa00A0A0AaAaA0AAA0A0AAaAA0aaAAa",
"policies.google.com": "AAA=000=AaAAAA_aAAa0aAaaaaAAa000A0AAaAaAAaAaaAa00-0aAaaAAaaAAAA0a0aaA0AaAaaaaaaaaAAAA0a0AAa_AaaAaaaAa_aaAAAaa00aAAAAAA_AAAAa0aA0a0AaA_00A0-0AaA-A_AAaA00aaAAAAAAaAaAaaaa0aaAAa0AaaA0aaAaaa",
"pt.wikipedia.org": "AAA-Aaaa-Aaaaaa=00-Aaa-0000; BBB-Bbbb-Bbbbbb-Bbbbbb=11-Bbb-1111; CccCC=CC:CC:Ccc_Ccccccccc:22.22:-222.22:c2; DddddddDddddDdddd=3.333",
"sites.google.com": "__Aaaa-AAAA=0:aaaAaAAA0aAAaAAAaAaaAaa0A00AAA:aAAaaaAA_aa0A0aA",
"support.google.com": "AAA=000=aaAAAaaAaaaAaA0aAA-00-AAaA0Aa0A0aaaAaaAa00_aAAAAAaaA0AAa0AAA0aAaA0aA0A0AAAAA0A0aaAAAA0aa-AAaAa00a0AaaaAaaAaa0Aaa0AA0aAAaaaaaAAAaAAAA0AA0AAaaaAa0aAAAaaaaaaAAA_0aaAaaAA0AaA0a0a0aAaA; BBB=111=bbBBBbbBbbbBbB1bBB-11-BBbB1Bb1B1bbbBbbBb11_bBBBBBbbB1BBb1BBB1bBbB1bB1B1BBBBB1B1bbBBBB1bb-BBbBb11b1BbbbBbbBbb1Bbb1BB1bBBbbbbbBBBbBBBB1BB1BBbbbBb1bBBBbbbbbbBBB_1bbBbbBB1BbB1b1b1bBbB",
"t.me": "aaaa_aaaa=aa0a00a00a000000a0_0000000000000000000",
"vk.com": "aaaaaaa=AAAAAAA; bbbbbbbbb=1; cccccccccc=2222222222222222222_CcCCccCCccc2CcCcCCCccCCCCccc2CccCC2cc2CcCCc; ddddddd=DDDDDDD; eeeeeEEEE=EEEEEEE; fffffffff=5555555555_fFfFffFfffFF55FF5ffffF5ffFFfff5f5F55FfF5fFF; ggggggg=-6%22-6%22-6%226666666666; hhhhhhh=7; iiiiiii=-8%22-8%22-8%228888888888",
"www.google.com": "AAA=AAAA0aaA00aaAaA-aaA0AaAaaAaa0aaAaAaaAAaA0AA00A0aAaAAAA0aaA; BBB=111=bbb111bBBb11-bbbBbbBBb11BbBB1bbb-bbBbbBBBbb-bbbb1BBbBBbbbb_bBb1BbbBBB1B1bBbb1b11bbBB11B11BBbBbbBB11BBBbb1b-BBbBBbBbBBB11bBbBB1BbbBBBBbbBbbBBbbB1b1bBb1B_BBb1BBB1bB1BbBBBbb1bB11b1bbbBBbbBbBBBbbbBBBb",
"youtu.be": "AAA=0; BBB=bbbBbBbbbbb; CCCCCCC_CCCC2_CCCC=Cccc-cCCcCC; DDDDDDD_DDDDDDD_DDDDDDDD=DdDDDdDDDdDdDD%22%22",
"youtube.com": "AAA=0; BBB=BbBbbbb1bBb; CCCCCCC_CCCC2_CCCC=CCc2ccCccCc; DDDDDDD_DDDDDDD_DDDDDDDD=DdDDDdDDDdDdDd%22%22",
"example.com": ""
}
74 changes: 41 additions & 33 deletions scripts/update-benchmark.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
"use strict";

var fs = require("fs");
var http = require("http");
var https = require("https");
var path = require("path");
var topSites = require("top-sites");
var url = require("url");
const fs = require("fs");
const http = require("http");
const https = require("https");
const path = require("path");
const topSites = require("top-sites");
const url = require("url");

var BENCH_COOKIES_FILE = path.join(__dirname, "parse-top.json");
const BENCH_COOKIES_FILE = path.join(__dirname, "parse-top.json");
const domains = topSites.slice(0, 30).map((x) => x.rootDomain);

getAllCookies(topSites.slice(0, 20), function (err, cookies) {
getAllCookies(domains, function (err, cookies) {
if (err) throw err;
var str =
"{\n" +
Object.keys(cookies)
.sort()
.map(function (key) {
return " " + JSON.stringify(key) + ": " + JSON.stringify(cookies[key]);
})
.join(",\n") +
"\n}\n";
fs.writeFileSync(BENCH_COOKIES_FILE, str);

const str = JSON.stringify(
Object.fromEntries(
Object.keys(cookies)
.sort()
.map((key) => [key, cookies[key]])
.concat([["example.com", ""]]),
),
null,
2,
);

fs.writeFile(BENCH_COOKIES_FILE, `${str}\n`, function (err) {
if (err) throw err;
console.log("Cookies saved to", BENCH_COOKIES_FILE);
process.exit();
});
});

function get(href, callback) {
var protocol = url.parse(href, false, true).protocol;
var proto = protocol === "https:" ? https : http;
const protocol = url.parse(href, false, true).protocol;
const proto = protocol === "https:" ? https : http;

proto
.get(href)
Expand All @@ -43,14 +51,14 @@ function get(href, callback) {
});
}

function getAllCookies(sites, callback) {
var all = Object.create(null);
var wait = sites.length;
function getAllCookies(domains, callback) {
const all = Object.create(null);
let wait = domains.length;

sites.forEach(function (site) {
getCookies(site, function (err, cookies) {
domains.forEach(function (domain) {
getCookies(domain, function (err, cookies) {
if (!err && cookies.length) {
all[site.rootDomain] = cookies.map(obfuscate).join("; ");
all[domain] = cookies.map(obfuscate).join("; ");
}
if (!--wait) {
callback(null, all);
Expand All @@ -59,30 +67,30 @@ function getAllCookies(sites, callback) {
});
}

function getCookies(site, callback) {
var href = url.format({ hostname: site.rootDomain, protocol: "http" });
function getCookies(domain, callback) {
const href = url.format({ hostname: domain, protocol: "http" });
get(href, function (err, res) {
if (err) return callback(err);
var cookies = (res.headers["set-cookie"] || []).map(function (c) {
const cookies = (res.headers["set-cookie"] || []).map(function (c) {
return c.split(";")[0];
});
callback(null, cookies);
});
}

function obfuscate(str) {
function obfuscate(str, index) {
return str
.replace(/%[0-9a-f]{2}/gi, function () {
return "%__";
})
.replace(/[a-z]/g, function () {
return "l";
return String.fromCharCode(97 + ((index || 0) % 26));
})
.replace(/[A-Z]/g, function () {
return "U";
return String.fromCharCode(65 + ((index || 0) % 26));
})
.replace(/[0-9]/g, function () {
return "0";
return (index || 0) % 10;
})
.replace(/%__/g, function () {
return "%22";
Expand Down

0 comments on commit 0f56c6e

Please # to comment.