Wednesday, October 23, 2013

How to restore the precedent session from a sessionstore.bak file

This is a cross-post from https://support.mozilla.org/en-US/questions/947856

When I tried to open firefox it automatically updated and supressed the sessionstore.js file. I saved the sessionstore.bak into another folder, closed mozilla, changed the extension bak to js in the "profiles" folder of firefox and opened it again but nothing happened. Though the sessionstore.bak file is 13Ko big and seems to contain all the links of my previous session.

How could I force Firefox to start a session using the information in the sessionstore.bak or .js file as it should?


My Answer

  1. Open a sessionstore.js file in a browser. It can be a different browser (Chrome) if you like.
  2. Open Firebug/Inspector.
  3. Type:
    eval("ss = "+document.body.innerHTML.replace("<pre>", "").replace("</pre>", ""));
  4. Type:
    for (var i = 0; i < ss.windows[0].tabs.length; i++) { var ent = ss.windows[0].tabs[i].entries; var last = ent[ent.length-1]; document.write("<a href="+last.url+">"+last.url+"</a><br />"); }
Enjoy all tabs from sessionstore on your screen. You only need to Ctrl-click them one by one.

Addendum: In case you see an error "TypeError: ss.windows[0] is undefined" you need to try again but replace all references of "ss.windows" to "ss.closedWindows". This depends on the contents of your sessionstore.bak file.

2 comments:

Winterseeker said...

Hi there, I found your help post online as I am in a similar lost tabs situation for Firefox. I backed up my files and followed the step you have shared but hit the following problems:

On Firefox, typing the first line works well but I saw your edit ("There's a pre and /pre inside the replace() function, which are being corrupt by the commenting system here. ) and when I correct it then it does not work, saying: SyntaxError: syntax error

When I use the version as it shows on your blog I get: [object Object]

Mousing over that result the link is: chrome://browser/content/devtools/webconsole.xul#

Your second step leads to: TypeError: ss.windows[0] is undefined

Even with your solution it says: TypeError: ss.closedwindows[0] is undefined

Any help would be appreciated, thanks so far!

the_z said...

I just tried your suggestion but got the following message after the second step:

[Exception... "The operation is insecure." code: "18" nsresult: "0x80530012 (SecurityError)" location: ""]

Do you have any suggestions?

Thanks!