Created
July 17, 2018 22:29
-
-
Save lovelaced/6d6f3ecbf7c97e5a0d27c6c5f3d54f26 to your computer and use it in GitHub Desktop.
get the URL of the last accessed (most recently loaded?) loaded tab in firefox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export opentabs=$(find ~/.mozilla/firefox*/*.default/sessionstore-backups/recovery.jsonlz4); | |
python3 <<< $'import os, json, lz4.block | |
f = open(os.environ["opentabs"], "rb") | |
magic = f.read(8) | |
jdata = json.loads(lz4.block.decompress(f.read()).decode("utf-8")) | |
f.close() | |
last_recent = 0 | |
for win in jdata.get("windows"): | |
for tab in win.get("tabs"): | |
i = tab.get("index") - 1 | |
if last_recent < tab.get("lastAccessed"): | |
last_recent = tab.get("lastAccessed") | |
url = tab.get("entries")[i].get("url") | |
print(url)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment