From 4737812db42daaf229380a16536cd71d88947348 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Thu, 4 Apr 2024 14:00:40 +0700 Subject: [PATCH] Update main.py --- export-chrome-cookies/main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/export-chrome-cookies/main.py b/export-chrome-cookies/main.py index 4c8a11b..3356128 100644 --- a/export-chrome-cookies/main.py +++ b/export-chrome-cookies/main.py @@ -34,6 +34,17 @@ def convert_to_unix_time(expires_utc): return unix_time +def convert_samesite(samesite): + samesite_mapping = { + -1: "unspecified", + 0: "no_restriction", + 1: "lax", + 2: "strict", + 3: "none", + } + return samesite_mapping.get(samesite, "unspecified") + + def get_encryption_key(): working_local_state = "Local State" if not os.path.isfile(working_local_state): @@ -104,17 +115,19 @@ def main(): "httpOnly": bool(is_httponly), "name": name, "path": path, - "sameSite": "unspecified", # This information is not available in the SQLite database + "sameSite": convert_samesite(samesite), "secure": bool(is_secure), "session": not bool(is_persistent), "storeId": "0", # This information is not available in the SQLite database "value": decrypted_value, "id": i + 1 }) + # commit changes db.commit() # close connection db.close() + with open('cookies.json', 'w') as f: json.dump(cookies_list, f, indent=4)