1. The perl and python solutions presented for dumping Firefox current session URLs are not very accurate if you navigate around in the same tab using backwards and forward buttons while remaining on the same domain, as they always print the first visited URL. UPDATE: Actually the python one is as it too uses JSON :)

    The JSON data in that sessionstore.js file keeps a list of URLs and an index field of the current one, and the latter is changed by the back/forward navigation.

    Using Javascipt we can load that JSON object and manipulate it far more naturally that via regexps. Here's how it is done using the Mozilla JS interpreter smjs that comes in the spidermonkey-bin package. It has no file access libraries so I used this interpreter's readline along with some help from the shell (echo is needed to append a newline to the original input file, otherwise readline() choked.)

    echo | cat `locate sessionstore.js | head -n 1` - | smjs -e 'eval("pig="+readline());

    i=0;
    for each (w in pig.windows) {
    print("Window ", i++);
    for each (t in w.tabs) {
    print(" ", t.entries[t.index-1].url)
    }
    }'


    I have no idea how to do code formatting in blogger, so above code is unindented. On the plus side it can be easily copy-pasted and tested :) Change the locate invocation with you hardcoded path if you want more speed.

    Things will be even nicer when GJS and/or Seed are in wider use and you are able to manipulate files directly from JS :)
    1

    View comments

Blog Archive
About Me
About Me
Loading