Skip to content

Instantly share code, notes, and snippets.

@notpushkin
Created August 17, 2017 14:07
Show Gist options
  • Save notpushkin/7c91fa27674cf9a176f1e0c9a9e86e28 to your computer and use it in GitHub Desktop.
Save notpushkin/7c91fa27674cf9a176f1e0c9a9e86e28 to your computer and use it in GitHub Desktop.
Migrate Firefox cookies.txt to Chrome-ish JSON (should be parseable by any addon)
j = []
for line in open("cookies.txt"):
line = line.strip("\n")
if len(line) == 0: continue
domain, httponly, path, issession, expires, name, value = line.split("\t")
j.append({
"domain": domain,
"hostOnly": True,
"httpOnly": httponly == "TRUE",
"name": name,
"path": path,
"sameSite": "no_restriction",
"secure": False,
"session": issession,
"storeId": "0",
"value": value,
})
json.dump(j, open("cookies.json", "w"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment