Extracting open URLs from sessionstore.js?

User Help for Mozilla Firefox
Nubfinger
Guest

Re: Extracting open URLs from sessionstore.js?

Post by Nubfinger »

I used ZeePrime's code but it did not work. Also it seems Orsted's web app is not available anymore.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

Rename sessionstore.js to sessionstore.js.txt and open the file in Firefox (File > Open File).

Code: Select all

javascript:(function(){var E=document.getElementsByTagName('PRE')[0],T=E.innerHTML,i=0,t='';while(/[^:]\{"entries":\[\{("url":"[^"]*")(\,"title":"[^"]*"){0,1}/g.exec(T)){t+='['+(++i)+']:'+RegExp.$1+RegExp.$2+'<br>';}with(window.open().document){write(t);close();}})();


If you want the closed tabs then use:

Code: Select all

javascript:(function(){var E=document.getElementsByTagName('PRE')[0],T=E.innerHTML,i=0,t='';while(/"state":\{"entries":\[\{("url":"[^"]*")(\,"title":"[^"]*"){0,1}/g.exec(T)){t+='['+(++i)+']:'+RegExp.$1+RegExp.$2+'<br>';}with(window.open().document){write(t);close();}})();

See also http://en.wikipedia.org/wiki/Bookmarklet

(edited to make it work with Firefox 3.5 and later by adding quotes around field names)
Last edited by dickvl on May 5th, 2010, 9:27 am, edited 1 time in total.
Bashologist
Guest

Re: Extracting open URLs from sessionstore.js?

Post by Bashologist »

If you use linux you could use something like this alghough it has more urls than the tabs I had open.

Code: Select all

grep -io 'http://[^"'\'']*' $(find ~/.mozilla/ -name sessionstore.js)
Mardeg
Guest

Re: Extracting open URLs from sessionstore.js?

Post by Mardeg »

Here's a command to use in ChatZilla for generating a page of clickable links of each tab from the current session (you can replace sessionstore.js with sessionstore.bak in the code for the last session if that file exists):

Code: Select all

/evals var sn = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD",Components.interfaces.nsIFile);sn.append("sessionstore.js");sn = new LocalFile(sn.QueryInterface(Components.interfaces.nsILocalFile),"<");var snobj = eval(sn.read());sn.close();var dh = "<!DOCTYPE HTML><html><head><title>Sessionstore Links</title><style type=\"text/css\">body{background-color:#048;counter-reset:win}h1:after{counter-increment:win;content:counter(win)}h1{color:#fc3;text-shadow:0.1em 0.1em 0.2em #fcf;margin-bottom:-0.5em}ul{display:table;list-style-position:inside;padding:1em;background-color:#cfc;color:#000;-moz-border-radius:0.5em;-moz-box-shadow:inset -0.8em 0.8em 0.8em -0.4em #048,inset -0.8em -0.8em 0.6em -0.4em #048,inset 0.6em 0.8em 0.6em -0.4em #048,inset 0.6em -0.8em 0.6em -0.4em #048}</style></head><body>";for each (w in snobj.windows){dh += "<h1>Window </h1><ul>";for each (var t in w.tabs) {dh += "<li><a href=\""+t.entries[t.index-1].url+"\">"+t.entries[t.index-1].title+"</a></li>"};dh += "</ul>"};dispatch("goto-url-newtab data:text/html,"+encodeURIComponent(dh+"</body></html>"))
QonoS
Posts: 234
Joined: February 11th, 2003, 8:09 pm

Re: Try this

Post by QonoS »

ZeePrime wrote:QonoS,

Here's a "quick-and-dirty" approach to extracting info from your sessionstore.js file. Just replace the line "<PUT CONTENTS OF sessionstore.js HERE!>" with the contents of your sessionstore.js file and open this puppy in mozilla as a standard html file.

-Z'

PS: I'm *way* too lazy to make this into an extension, but if anyone else wants to, you have my full blessing. :-D


ZeePrime, thanks. I finally had occasion to use your code, and it works very well.

I tried downloading the parser from 0rsted but the server isn't responding... I'll try again.

One item that tripped me up at first, so I'm posting here in case anyone else finds themselves using this: The angle brackets (<>) surrounding PUT CONTENTS OF sessionstore.js HERE! also need to be deleted, otherwise the code won't work. Your instructions:
Just replace the line "<PUT CONTENTS OF sessionstore.js HERE!>" with the contents of your sessionstore.js file


were clear if one observes that everything between the double quotes (""), including the angle brackets, needs to be replaced with the contents of sessionstore.js.
QonoS
Posts: 234
Joined: February 11th, 2003, 8:09 pm

Re: Extracting open URLs from sessionstore.js?

Post by QonoS »

Nubfinger wrote:I used ZeePrime's code but it did not work. Also it seems Orsted's web app is not available anymore.


Late reply, but maybe someone's still watching this. As noted above, the code did work for me. Nubfinger, make sure that you're deleting the angle brackets around the text you're supposed to insert. You may also need to save the resulting file as html for your browser to pick it up correctly. Make sure you're either using a text editor or, if a word processor, you're not saving in your word processor's format or as something like RTF.
QonoS
Posts: 234
Joined: February 11th, 2003, 8:09 pm

Re: Extracting open URLs from sessionstore.js?

Post by QonoS »

Bumped this topic because of a new wrinkle. Hope that was the right thing to do -- if not, my apologies :(

Recently I upgraded my Mac OS X install to 10.4.11 (Tiger) from 10.3.9, and my FF from 2.x to the current 3.x for Mac.

Sadly, ZeePrime's code no longer works as it did so well with my previous install. It looks to me like the format of sessionstore.js has changed (a fair bit) between 2.x and 3.x.

Could someone confirm that this is the case? Or perhaps confirm that I'm nuts? (Either will do.)

And the main question: since I remain scandalously illiterate in HTML and most anything else related to code, to whom could I promise a reasonable supply of beverage of choice to do what I cannot do? (Z', are you still around?)
QonoS
Posts: 234
Joined: February 11th, 2003, 8:09 pm

Re: Extracting open URLs from sessionstore.js?

Post by QonoS »

dickvl wrote:Rename sessionstore.js to sessionstore.js.txt and open the file in Firefox (File > Open File).

Code: Select all

javascript:(function(){var E=document.getElementsByTagName('PRE')[0],T=E.innerHTML,i=0,t='';while(/[^:]\{"entries":\[\{("url":"[^"]*")(\,"title":"[^"]*"){0,1}/g.exec(T)){t+='['+(++i)+']:'+RegExp.$1+RegExp.$2+'<br>';}with(window.open().document){write(t);close();}})();


If you want the closed tabs then use:

Code: Select all

javascript:(function(){var E=document.getElementsByTagName('PRE')[0],T=E.innerHTML,i=0,t='';while(/"state":\{"entries":\[\{("url":"[^"]*")(\,"title":"[^"]*"){0,1}/g.exec(T)){t+='['+(++i)+']:'+RegExp.$1+RegExp.$2+'<br>';}with(window.open().document){write(t);close();}})();

See also http://en.wikipedia.org/wiki/Bookmarklet

(edited to make it work with Firefox 3.5 and later by adding quotes around field names)


Hi dickvl,

I just figured out how to use your bookmarklet code, and it does work, and mostly resolves the issue I just posted about directly above.

One thing ZeePrime's code did was to generate a page of clickable links (as opposed to text URIs). Any chance your code could be made to do the same thing? If so, I think we're done, with thanks :)
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

Code: Select all

javascript:(function(){var E=document.getElementsByTagName('PRE')[0],H=E.innerHTML,i=0,t='',T,U;while(/[^:]\{"entries":\[\{("url":"([^"]*)")\,("title":"([^"]*)"){0,1}/g.exec(H)){U=RegExp.$2;T=RegExp.$4;if(T.length==0){T=U;}t+='['+(++i)+']: <a href='+U+'>'+T+' ('+U+')<\/a><br>';}with(window.open().document){open();close();body.innerHTML=t;}})();


Closed tabs:

Code: Select all

javascript:(function(){var E=document.getElementsByTagName('PRE')[0],H=E.innerHTML,i=0,t='',T,U;while(/"state":\{"entries":\[\{("url":"([^"]*)")\,("title":"([^"]*)"){0,1}/g.exec(H)){U=RegExp.$2;T=RegExp.$4;if(T.length==0){T=U;}t+='['+(++i)+']: <a href='+U+'>'+T+' ('+U+')<\/a><br>';}with(window.open().document){open();close();body.innerHTML=t;}})();
QonoS
Posts: 234
Joined: February 11th, 2003, 8:09 pm

Re: Extracting open URLs from sessionstore.js?

Post by QonoS »

Oh, that's just beautiful. Where do I send the beer? (Or coffee....)
Andris76
Posts: 10
Joined: January 30th, 2007, 1:55 pm
Location: msk.ru
Contact:

Re: Extracting open URLs from sessionstore.js?

Post by Andris76 »

Thanks ZeePrime! Works like a charm.

BTW, your solution has been referenced here and the reidented version of your code is also available here.
mtb2k
Posts: 5
Joined: December 21st, 2010, 5:11 pm

Re: Extracting open URLs from sessionstore.js?

Post by mtb2k »

oh!! oh!! after 2 hours of googling! thanks! i had the same problem and needed my tabs back.. Thanks zeeprime!
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

Hi guys, I've been browsing this thread, and for the life of me, I can't/unable to figure out how I should use the bookmarklet code given. Would someone explain how to do so?
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

Really sorry or the double post, but how do I go about extracting the URLs when the sessionstore.js file is corrupt?
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

You can try to open the damaged sessionstore.js file in Firefox via File > Open File (add a .txt file extension, sessionstore.js.txt, if Firefox refuses) and use the bookmarklet that I posted above.
Locked