Last active
January 20, 2026 13:50
-
-
Save tmonjalo/33c4402b0d35f1233020bf427b5539fa to your computer and use it in GitHub Desktop.
List all Firefox tabs with title and URL
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
| #! /usr/bin/env python3 | |
| """ | |
| List all Firefox tabs with title and URL | |
| Supported input: json or jsonlz4 recovery files | |
| Default output: title (URL) | |
| Output format can be specified as argument | |
| """ | |
| import platform | |
| import sys | |
| import pathlib | |
| import lz4.block | |
| import json | |
| if platform.system() == 'Windows': | |
| path = pathlib.Path(os.environ['APPDATA']).joinpath('Mozilla\\Firefox\\Profiles') | |
| elif platform.system() == 'Darwin': | |
| path = pathlib.Path.home().joinpath('Library/Application Support/Firefox/Profiles') | |
| else: | |
| path = pathlib.Path.home().joinpath('.mozilla/firefox') | |
| files = path.glob('*default*/sessionstore-backups/recovery.js*') | |
| try: | |
| template = sys.argv[1] | |
| except IndexError: | |
| template = '%s (%s)' | |
| for f in files: | |
| b = f.read_bytes() | |
| if b[:8] == b'mozLz40\0': | |
| b = lz4.block.decompress(b[8:]) | |
| j = json.loads(b) | |
| for w in j['windows']: | |
| for t in w['tabs']: | |
| i = t['index'] - 1 | |
| if len(t['entries']) > i: | |
| print(template % ( | |
| t['entries'][i]['title'], | |
| t['entries'][i]['url'] | |
| )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My version that supports templates where the order of the title and the url is inverted (as in
<a href="url">title</a>): https://github.com/tpo/little_shell_scripts/blob/master/ff_tabs_list_in