diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2022-09-18 13:06:39 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2022-09-18 16:36:55 +0200 |
commit | 9c5a4b1bc92a35df53fef6e0e3620e3db50ea734 (patch) | |
tree | eae335927cce5c20f71d04f9febfa9d8f8110a28 /extract_token_from_browser.py | |
parent | f205c37dc9e43e7c159a5d36a1b11b78365492ea (diff) | |
download | wee-slack-9c5a4b1bc92a35df53fef6e0e3620e3db50ea734.tar.gz |
Support including the d-s cookie
According to one comment it was necessary for them to include this
cookie as well.
Diffstat (limited to 'extract_token_from_browser.py')
-rwxr-xr-x | extract_token_from_browser.py | 18 |
1 files changed, 14 insertions, 4 deletions
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)) |