Skip to content

Instantly share code, notes, and snippets.

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 sputnick-dev/d23a87a0f76b26f0a2cc1baa2e1156de to your computer and use it in GitHub Desktop.
Save sputnick-dev/d23a87a0f76b26f0a2cc1baa2e1156de to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://unix.stackexchange.com/questions/385023/firefox-reading-out-urls-of-opened-tabs-from-the-command-line
if [[ $1 == *jsonlz4 ]]; then
export opentabs="$1"
elif pgrep -f waterfox &>/dev/null; then
export opentabs=$(ls -t ~/.waterfox/*/sessionstore-backups/recovery.jsonlz4 | sed q)
else
export opentabs=$(ls -t ~/.mozilla/firefox*/*/sessionstore-backups/recovery.jsonlz4 | sed q);
fi
python3 <<'EOF'
import os, sys, json, lz4.block
f = open(os.environ["opentabs"], "rb")
magic = f.read(8)
c=0
jdata = json.loads(lz4.block.decompress(f.read()).decode("utf-8"))
f.close()
for win in jdata.get("windows"):
print("")
for tab in win.get("tabs"):
i = tab.get("index") - 1
urls = tab.get("entries")[i].get("url")
print(urls)
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment