Re Dumping currently loaded Firefox URLs

bryce posted his Perl version of Dumping currently loaded Firefox URLs.

I decided perl is unreadable ๐Ÿ™‚ and the file is json any way. So with the python-json package You can get some pretty readable code so I wrote a pretty simple Python version ff-pages.

python /path/to/location/sessionstore.js

I am starting off with python so all comments are welcome.

Update 02/06/2009:
python-json isn’t needed.
Seems to only work with firefox3.5

Tags: ,

Thursday, July 2nd, 2009 Programing

7 Comments to Re Dumping currently loaded Firefox URLs

  1. Perl is not unreadable, you’re just incompetent and never bothered to look properly.

  2. szbalint on July 2nd, 2009
  3. thanks for this! had to tweak it slightly to cope with page titles containing unicode characters and ‘Untitled’ tabs, here’s the patch:

    — old/ 2009-07-02 11:46:23.000000000 +0100
    +++ new/ 2009-07-02 12:57:57.546325791 +0100
    @@ -8,5 +8,6 @@
    print ‘Window %s’% (i+1)
    for tabs in window[‘tabs’]:
    entry = tabs[‘entries’]
    – if entry[len(entry)-1].has_key(‘title’) and entry[len(entry)-1].has_key(‘url’):
    – print ‘\tTitle: %s Url %s’% (entry[len(entry)-1][‘title’], entry[len(entry)-1][‘url’])
    + if len(entry) > 0 and entry[len(entry)-1].has_key(‘title’) and entry[len(entry)-1].has_key(‘url’):
    + s = ‘\tTitle: %s Url %s’ % (entry[len(entry)-1][‘title’], entry[len(entry)-1][‘url’])
    + print unicode(s).encode(‘utf8’)

  4. Dom on July 2nd, 2009
  5. hmm, looks like your blog dropped the formatting ๐Ÿ™‚

  6. Dom on July 2nd, 2009
  7. That might have come off as a bit harsh, however comparing your python version with the original Perl implementation, I have to say that the Perl version is a lot more robust and readable.

    Even if you don’t like parsing JSON with regular expressions, it would have been a simple fix to “use JSON;”. That is however an implementation detail and I don’t see how that would imply that Perl is unreadable.

  8. szbalint on July 2nd, 2009
  9. @szbalint: That comment “perl is unreadble” should have been qualified as a personal joke we have in #ubuntu-begginers on freenode with ibuclaw & sdennie.

    @Dom: Thanks for your patch.

  10. drubin on July 2nd, 2009
  11. @drubin: Ah I see. I’ve just seen your post in the Planet Ubuntu aggregator and I assumed you were serious ๐Ÿ™‚

  12. szbalint on July 2nd, 2009
  13. […] perl and python solutions presented for dumping Firefox current session URLs are not very accurate if you navigate […]

  14. Jani Monoses: dumping open FF tab URLs using Javascript and shell stuff | on July 4th, 2009