From 9c5a4b1bc92a35df53fef6e0e3620e3db50ea734 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 18 Sep 2022 13:06:39 +0200 Subject: Support including the d-s cookie According to one comment it was necessary for them to include this cookie as well. --- extract_token_from_browser.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'extract_token_from_browser.py') diff --git a/extract_token_from_browser.py b/extract_token_from_browser.py index d571120..5798ba0 100755 --- a/extract_token_from_browser.py +++ b/extract_token_from_browser.py @@ -34,10 +34,21 @@ except StopIteration: cookies_path = default_profile_path.joinpath("cookies.sqlite") con = sqlite3.connect(f"file:{cookies_path}?immutable=1", uri=True) -cookies_query = "SELECT value FROM moz_cookies WHERE host = '.slack.com' AND name = 'd'" -cookie_d_value = con.execute(cookies_query).fetchone()[0] +cookie_d_query = ( + "SELECT value FROM moz_cookies WHERE host = '.slack.com' AND name = 'd'" +) +cookie_d_value = con.execute(cookie_d_query).fetchone()[0] +cookie_ds_query = ( + "SELECT value FROM moz_cookies WHERE host = '.slack.com' AND name = 'd-s'" +) +cookie_ds_values = con.execute(cookie_ds_query).fetchone() con.close() +if cookie_ds_values: + cookie_value = f"d={cookie_d_value};d-s={cookie_ds_values[0]}" +else: + cookie_value = cookie_d_value + local_storage_path = default_profile_path.joinpath("webappsstore.sqlite") con = sqlite3.connect(f"file:{local_storage_path}?immutable=1", uri=True) local_storage_query = "SELECT value FROM webappsstore2 WHERE key = 'localConfig_v2'" @@ -49,7 +60,6 @@ teams = [ team for team in local_config["teams"].values() if not team["id"].startswith("E") ] register_commands = [ - f"{team['name']}:\n/slack register {team['token']}:{cookie_d_value}" - for team in teams + f"{team['name']}:\n/slack register {team['token']}:{cookie_value}" for team in teams ] print("\n\n".join(register_commands)) -- cgit