MozillaZine

Extracting open URLs from sessionstore.js?

User Help for Mozilla Firefox
Nubfinger
Guest
 

Post Posted August 20th, 2008, 2:57 pm

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

dickvl

User avatar
 
Posts: 52810
Joined: July 18th, 2005, 3:25 am

Post Posted August 20th, 2008, 4:05 pm

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
 

Post Posted March 10th, 2009, 11:29 am

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
 

Post Posted August 30th, 2009, 12:05 am

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: 233
Joined: February 11th, 2003, 8:09 pm

Post Posted February 3rd, 2010, 3:30 pm

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: 233
Joined: February 11th, 2003, 8:09 pm

Post Posted May 16th, 2010, 8:19 pm

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: 233
Joined: February 11th, 2003, 8:09 pm

Post Posted May 16th, 2010, 8:23 pm

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: 233
Joined: February 11th, 2003, 8:09 pm

Post Posted May 16th, 2010, 8:43 pm

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 :)

dickvl

User avatar
 
Posts: 52810
Joined: July 18th, 2005, 3:25 am

Post Posted May 17th, 2010, 11:03 am

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: 233
Joined: February 11th, 2003, 8:09 pm

Post Posted May 17th, 2010, 11:41 am

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

Post Posted May 18th, 2010, 6:57 am

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

Post Posted December 21st, 2010, 8:40 pm

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

papuruka
Guest
 

Post Posted January 10th, 2011, 12:26 pm

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
 

Post Posted January 10th, 2011, 12:39 pm

Really sorry or the double post, but how do I go about extracting the URLs when the sessionstore.js file is corrupt?

dickvl

User avatar
 
Posts: 52810
Joined: July 18th, 2005, 3:25 am

Post Posted January 10th, 2011, 12:59 pm

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.

Return to Firefox Support


Who is online

Users browsing this forum: Google [Bot] and 8 guests