Firefox tricks

A few notes about how to get useful information from Firefox/Iceweasel on the command line. All examples were run on using Bash on Debian. A post I found interesting while researching how to do the below was this post on the new way Firefox does session restores in version 33 and up. Also of note if you have an SSD beware of the heavy writes Firefox does as part of the session save process.

Firefox open tabs

Finding open tabs turns out to be pretty easy, this guy has a python one-liner to do it. He also has some other information about stuff you can pull out of the JSON which is worth checking out. I felt like something a bit more compact so I decided to see if jq could grab the data for open tabs.

At first glance I throught the python script was filtering by index of 1 so I wrote up this:

cat sessionstore-backups/recovery.js |jq '.windows[].tabs[] |select (.index == 1) | .entries[].url'

Neat, except I was getting the wrong URL's on some of the entries. Seems you need to take the index and use that value to grab the correct entry within entries. Turns out after looking through the manual jq can actually do just that:

jq -r '.windows[].tabs[] |.index as $i |.entries[$i-1].url' sessionstore-backups/recovery.js

Firefox history

Next up lets say you closed that tab, no worries we can grab it from history with sqlite like so:

sqlite3 places.sqlite 'select url from moz_places;'

That's all for now, feel free to head back to the mostly empty home page