Skip to content

Instantly share code, notes, and snippets.

@lovelaced
Created July 17, 2018 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lovelaced/6d6f3ecbf7c97e5a0d27c6c5f3d54f26 to your computer and use it in GitHub Desktop.
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
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