Dumping currently loaded Firefox URLs

Chris Cheney posed an interesting problem - how to get a listing of currently opened Firefox windows.

You can get this info from sessionstore.js in your firefox profile, but it's a jumble of javascript. I wrote a script ff-pages to display them in a more useful way.

Example usage:

$ ff-pages .mozilla/firefox/*.default/sessionstore.js

Window 0:
    http://shoutcast.net/directory/index.phtml
    http://www.radioparadise.com
    http://people.ubuntu.com/~bryce/Plots/
    file:///var/www/X/Graphs
Window 1:
    https://bugs.launchpad.net/ubuntu/+bug/379797
    https://bugs.freedesktop.org/show_bug.cgi?id=21315
Window 2:
    https://bugs.launchpad.net/ubuntu/+bug/360319
    https://bugs.launchpad.net/ubuntu/+bug/376092
Window 3:
    https://bugs.freedesktop.org/show_bug.cgi?id=21756
    https://bugs.freedesktop.org/show_bug.cgi?id=16702
...

bryce | Thu, 2009-07-02 19:00

Yeah I played around a lot with the JSON module. The file looks like JSON, but the format is off, and the parser chokes on it. I was able to get it to parse it by turning off most of the format checks in the JSON module, but then it just complained that the data structure had too many levels of nesting, so I opted for the regex approach instead.

Still, I'd love to see a working JSON version. I googled around but didn't spot one.

Wilmer van der Gaast (not verified) | Thu, 2009-07-02 13:15

I was looking for this a few weeks ago and wrote something too. It's really useful, and amazing how much information is stored in that file.

My script feeds the full contents of the file to a Perl JavaScript module, which may be more robust but likely quite a bit slower than your approach.

cortex (not verified) | Thu, 2009-07-02 10:06

The script is good for command line use - you could also use an extension like CopyAllURLs which does about the same. Super DragAndGo can help you with the other way round (Clipboard->Tabs)

drubin (not verified) | Thu, 2009-07-02 09:25

You could use http://search.cpan.org/~makamaka/JSON-2.15/lib/JSON.pm since it isn't javascript but rather json. Instead of regex's :)

Marko Kevac (not verified) | Thu, 2009-07-02 08:49

Does not work:

[marko@marko-work tmp]$ ./ff-pages ~/.mozilla/firefox/*.default/sessionstore.js
Window 0:

Firefox 3.5