Firefox 2.0 crashed when I clicked on a link to a story at theonion.com. It dutifully saved my session to be recovered later. Unfortunately, some bug (probably in the beta flash 9 plugin) causes the recovery to crash at the same place. All seems lost, right? NO. Because Firefox actually stored the session in a SANE FORMAT.
Just load up your trusty python shell and:>>> import demjson
>>> store = file('sessionstore.js').read()
>>> session = demjson.decode(store.strip()[1:-1])
>>> for w in session['windows']:
... for t in w['tabs']:
... for e in t['entries']:
... if 'theonion.com' in e['url']:
>>> store = demjson.encode(session)
>>> file('sessionstore.js', 'w').write('(%s)' % store)
Et voila! Session restored, minus one theonion tab. Easy, right?
Almost. First, it puts parenthesis around the whole thing, which no python JSON parser understood. That's trivial to work around. Then, it used bare identifiers starting with '_' in objects, which no python JSON parser understood. It was a one-line fix to demjson.
Imagine how cool it would have been if any of the python JSON modules had been up to scratch though :P