Source(Changed file path) : Get all the open tabs
This snippet gets the current firefox tab url's. It uses the `recovery.js[onlz4]` file in your profile folder. That file is updated almost instantly, however it will not always be the correct url.
Get all the open tabs:
python -c '
import io, json, pathlib as p
fpath = next(iter(p.Path("~/.mozilla/firefox").expanduser().glob("*.default/sessionstore-backups/recovery.js*")))
with io.open(fpath, "rb") as fd:
if fpath.suffix == ".jsonlz4":
import lz4.block as lz4
fd.read(8) # b"mozLz40\0"
jdata = json.loads(lz4.decompress(fd.read()).decode("utf-8"))
else:
jdata = json.load(fd)
for win in jdata.get("windows"):
for tab in win.get("tabs"):
i = tab["index"] - 1
print(tab["entries"][i]["url"])
'