Extracting open URLs from sessionstore.js?

User Help for Mozilla Firefox
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

I did, but it'd either result in a blank page or crash completely. It would also appear as sessionstore.js.txt.js; is this the reason why?

Also, how do I use the bookmarklet code when I open up the sessionstore file?
User avatar
dickvl
Posts: 54235
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

What do you see if you open that file in Firefox via File > Open File?

It is a text file and you should see readable text. If you see garbage instead then the file is that much damaged that you probably can't do much with it. You can try to open the file in a Hex Editor (Viewer) to see what is in it.

You can compare the content with a working file sessionstore.js.
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

I literally see nothing at all when I opened the sessionstore.js via File > Open File. Also tried two other methods:

1) Copying it to the ########.default file, cleared history+opened firefox (at this point Session Manager comes out with the error 'illegal character: undefined' for the sessionstore.js file)
2) Renaming the sessionstore.BAK file (from the above step) to sessionstore.json and File > Open File, then nothing comes up.

In those cases I'm convinced that the sessionstore file is at the point of nor return, but for the ones that do work via File > Open File, Firefox crashes before it could fully load itself, preventing me from using the bookmarklet. I do see a line of text starting with the word 'windows,' so I think I'm on the right track at least.
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

Sorry, for the 2nd step in my previous post, I opened the sessionstore.json file via Organize Bookmarks > Import and Backup > Restore (doesn't work). Again, sorry for the double post.
User avatar
dickvl
Posts: 54235
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

Did you check the content of the file in a hex viewer program?

http://www.x-ways.net/winhex/
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

Yea, I viewed the file in the hex viewer program; seems like there's a lot of URLs to be retrieved. I also managed to File > Open File it.

I must be missing what has to be the easiest thing to do on Earth, but how exactly do I use the bookmarklet code you provided...?
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: Extracting open URLs from sessionstore.js?

Post by trolly »

Paste it in the address bar and press ENTER.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
papuruka
Guest

Re: Extracting open URLs from sessionstore.js?

Post by papuruka »

Another problem: Firefox crashes each time I access the sessionstore.js.txt file (probably because the file is 77.6MB). Any way I can prevent this from happening?

By the way, as future reference, you edit the sessionstore.JSON (not sessionstore.js as previously mentioned) into sessionstore.js.txt to change it into a text file. Kept trying to change the js file that way and got nowhere until that moment of wisdom hit me >_>
User avatar
dickvl
Posts: 54235
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

You may have to use a more advanced editor to break that large file in a few smaller parts to prevent Firefox from stalling.
Anthonyb10
Guest

Re: Extracting open URLs from sessionstore.js?

Post by Anthonyb10 »

Is there a way I could extract ALL urls from the sessionstore.js file? even the ones that are hidden inside another sessionrestore link (i have multiple sessionrestore tabs inside eachother all containing their own relevant urls). all i see by executing the javascript bookmarklet right now is the links from the current sessionrestore
georgd
Posts: 1
Joined: January 17th, 2011, 6:22 pm

Re: Extracting open URLs from sessionstore.js?

Post by georgd »

Hi all, I extended the HTML-file by ZeePrime so it shows also closed windows, contains some help, and is more readable. It is different from the bookmarklet as it does not change the current session and also handles closed windows.

I uploaded the file to http://rapidshare.com/files/443154522/F ... r_v1.0.htm as I did not find any possiblity to add files here in the board. Feel free to extend or update it, e.g. add loading a sessionstore.js-file (has to to reside in the same directory as the html file). Cheers, Georg
User avatar
dickvl
Posts: 54235
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">

<style type="text/css">
.selectedtab { font-weight: bold; }
.closedtab { color: red; }
.closedwindow { background-color: #ccc; }
</style>
  <title>Firefox sessionstore.js displayer</title>
  <meta content="Georg Dembowski" name="author">
</head><body>
<h1 style="text-align: center;">Firefox <code>sessionstore.js</code><span style="font-weight: bold;"> </span>displayer</h1>
<h2>Infos</h2>

<ul>
<li>Zweck: Firefox <code>sessionstore.js</code> laden und Verlauf als HTML-Datei ansehen/verwenden, z.B. zum Retten.
<li>Version 1.0 &ndash; erfolgreich getestet mit Firefox 3.6, kein Anspruch auf Vollständigkeit des Tests.
</li><li>Verwendung:
  <ul>
    <li>Inhalt der  <code>sessionstore.js</code> in den Quelltext dieser Datei legen, wo <code>//PUT CONTENTS</code> steht.
    </li>
    <li>Pro offenem und geschlossenem Window/Fenster gibt es eine Liste mit seinen Tabs.
    </li>
    <li>Pro offenem und geschlossenem Tab gibt es eine Liste der URLs, die im Tab angesehen wurden, von der ersten bis zur letzten/aktuellsten.
<span class="selectedtab">Fett = aktuell sichtbares Tab (im Vordergrund)</span>, normaler Text = offenes Tab aber verdeckt, <span class="closedtab">rot = geschlossenes Tab</span>.
    </li>
  </ul>
  </li>
<li>Inspiration: Code by ZeePrime in <a href="http://forums.mozillazine.org/viewtopic.php?t=622036">http://forums.mozillazine.org/viewtopic.php?t=622036</a>
</li></ul>
<h2>Content</h2>

<input id="fileItem" type="file" onchange="processData();" >

<ul id="windows">
<script type="text/javascript">

var data = (""); //PUT CONTENTS OF sessionstore.js HERE!
var data = eval(prompt('Paste sessionstore.js data',data));
if (data) processData();

//start: define functions
function processWindow(aWindow,wname,wclass) {
   //write window name and all its tabs (open and closed ones)
   document.write("<li class=\"" + wclass + "\">");
   document.write("<b>" + wname + "</b>");
   document.write("<ol class=\"tabs\">");
   var sel = aWindow["selected"];
   //process open tabs
   var tabs = aWindow["tabs"];
   for (var j = 0; j < tabs.length; j++) {
      var tabclass = "tab";
      if (j + 1 == sel) tabclass = "selectedtab";
      processTab(tabs[j],"Tab #" + (j+1),tabclass);
   }
   //process closed tabs
   var openTabsLength = tabs.length;
   tabs = aWindow["_closedTabs"];
   for (var j = 0; j < tabs.length; j++) {
      processTab(tabs[j]["state"],"Tab #" + (openTabsLength + j + 1),"closedtab");
   }
   document.write("</ol>");
   document.write("</li>");
}
function processTab(tab,tname,tclass) {
   //write tab name and all URLs that have been open in this tab
   document.write("<li class=\"" + tclass + "\">");
   document.write(tname);
   document.write("<ol class=\"urls\">");
   var sel = tab["index"];
   var urls = tab["entries"];
   for (var j = 0; j < urls.length; j++) {
      var urlclass = "url";
      if (j + 1 == sel) urlclass = "selectedurl";
      processURL(urls[j],urlclass);
   }
   document.write("</ol>");
   document.write("</li>");
}
function processURL(url,uclass) {
   //Print URL and, if existing, URL title/name
   document.write("<li class=\"" + uclass + "\">");
   var uname = url["title"];
   if (!(uname) || uname == "") uname = url["url"];
   document.write("<a href=\"" + url["url"] + "\">" + uname + "</a>");
   document.write("</li>");
}
//end: define functions

function processData(){
data = data || eval(document.getElementById('fileItem').files[0].getAsText("utf8"));

//start: call functions for given data
//process open windows
var windows = data["windows"];
for (var i = 0; i < windows.length; i++) {
   processWindow(windows[i],"Window #" + (i+1),"window");
}
//process closed windows
var closedWindows = data["_closedWindows"];
for (var i = 0; i < closedWindows.length; i++) {
   processWindow(closedWindows[i],"Closed window #" + (i+1),"closedwindow");
}
//end: call functions for given data
document.close();
}
</script>
</ul>
</body></html>
Last edited by dickvl on January 18th, 2011, 4:58 pm, edited 3 times in total.
User avatar
dickvl
Posts: 54235
Joined: July 18th, 2005, 3:25 am

Re: Extracting open URLs from sessionstore.js?

Post by dickvl »

Can you do this without using eval ?

These worked for me with modified code.

Code: Select all

var data = eval(prompt('Sessionstore.js data',''));
var data = eval(document.getElementById('fileItem').files[0].getAsText("utf8"));

https://developer.mozilla.org/en/DOM/FileList
https://developer.mozilla.org/en/DOM/FileReader
larry54
Posts: 10
Joined: June 5th, 2010, 3:35 pm

Re: Extracting open URLs from sessionstore.js?

Post by larry54 »

I'd like to share a sucessful (though not ideal, but infinitely better than nothing) manual method of extracting your tab urls from sessionstore.js, explained in noob baby steps for other noobs out there like me who may find it useful.

I had a 87MB sessionstore.js which I think was corrupted, as firefox wouldn't restore it (I would click on the restore button but nothing would happen, it wouldn't load the pages from it and the button would then grey-out), and none of the above methods in this thread would work for my file either. So if there's nothing else that you can do, like me, this is what I did for my messed up sessionstore.js:

Firstly, I had to get rid of what was a zillion instances of "\\\\\\\" and "\\\" (it seems that this was one of the ways my file was corrupted). I did this by opening it in XVI32 hex editor and using search and replace to get rid of all instances of that stuff.

So assuming the URLs in the file are not corrupted themselves: download Windows Grep, and search the file in Grep with the following "normal (regular expressions)" search:

For http:// pages:

\"url\":\"http://[^"'\'']*

For https pagaes:

\"url\":\"https://[^"'\'']*

I found that this brought up the full list of closed as well as currently open tabs. It definitely covers ALL open http/s tabs, so you don't have to worry that you're not catching some of them.

But boy, since you literally catch everything, you may catch an awful lot. If you want to minimise the amount of closed tab urls (by a big amount), try:

\{\"entries\":\[\{\"url\":\"http://[^"'\'']*

\{\"entries\":\[\{\"url\":\"https://[^"'\'']*


However I found that it omits some open tabs too [not just most closed tabs], so YMMV.

So then in Grep search results, untick "whole line" and "line numbers" and so forth, select all and copy, and you more or less have your tab URLs. Although in this last step it would crash when trying to copy so many lines from my mega js files. So I printed the results to PDF and merely copied the urls from there.

...I worked these strings out from just looking at the sessionstore.js file and using my brain for a few minutes, probably there's more exact strings one could work out but I can't be bothered myself lol.
User avatar
magoood
Posts: 294
Joined: October 16th, 2007, 1:57 am

Re: simple parser

Post by magoood »

0rsted wrote:I wrote a simple parser (that actually works) in asp and uploaded it to my server

http://server.oe-web.dk/sessionstore.asp

Paste the content of the sessionstore.js file into this, and make your selections, then you can see the tabs and the windows of the session

Could you please re-upload this to another server because the site is not working. I need it because of the same problem reported in this thread (FF crashed and I want to extract the URLs from the useless corrupted sessionstore.js)
Locked