Created
May 13, 2023 01:11
-
-
Save sputnick-dev/d23a87a0f76b26f0a2cc1baa2e1156de to your computer and use it in GitHub Desktop.
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
#!/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