Univers Libre

Get a list of opened Firefox tabs

Written on 6 September 2017, 21:20 CEST
Tags: firefox.

Since I usually work with 2 Firefox on 2 different computers (a personal one and a professional one), I often need to get back some of my opened tabs from the Firefox instance running on my second computer.

Firefox store all opened tabs and windows and their history in the sessionstore-backups/recovery.js in your profile's directory. So as long as this file is synchronized in some way to a remotely accessible machine (backups), you can parse the file and get the list of all your opened tabs and windows. I wrote a simple Python script to print tab's title and URL of each tabs from the recovery.js file:

#!/usr/bin/env python3

# Print title and URL for each tab of each window of the specified
# Firefox profile.

import json

with open("<path to your Firefox profile's directory>/sessionstore-backups/recovery.js", "r") as f:
    jdata = json.load(f)
    for w in jdata['windows']:
        for t in w['tabs']:
            i = t['index'] - 1
            print("%s (%s)" % (
                t['entries'][i]['title'],
                t['entries'][i]['url']
                ))

You will get a list like this:

$ show-ff-tabs.py
[…]
GitHub - devimust/easy-bookmark-manager: Easy and simple self-hosted bookmark / snippet management tool. (https://github.com/devimust/easy-bookmark-manager)
GitHub - Kickball/awesome-selfhosted: This is a list of Free Software network services and web applications which can be hosted locally. Selfhosting is the process of locally hosting and managing applications instead of renting from SaaS providers. (https://github.com/Kickball/awesome-selfhosted#personal-dashboards)
GitHub - cdevroe/unmark: An open source to do app for bookmarks. (https://github.com/cdevroe/unmark)

(you can see that I currently looking for a simple self-hosted bookmark manager :-) )

More information for the structure of recovery.js file on the Mozilla wiki.