Last active
March 18, 2024 03:08
-
-
Save jscher2000/d7c77f90bde6f37f526faa56c6a2b19e to your computer and use it in GitHub Desktop.
Firefox Browser Console - Save Current Session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Session Backup Script for the Browser Console | |
NOTE: BEFORE RUNNING THIS SCRIPT, CHECK THIS SETTING: | |
Type or paste about:config into the address bar and press Enter | |
Click the button promising to be careful | |
In the search box type devt and pause while Firefox filters the list | |
If devtools.chrome.enabled is false, double-click it to toggle to true | |
Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j) | |
Then press Enter to run the script. A save dialog should promptly open. | |
*/ | |
ssj = SessionStore.getBrowserState(); // get Current Session State | |
if(ssj){ | |
// Set up Save As dialog | |
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); | |
try { // Fx125+ | |
fp.init(window.browsingContext, 'Open File', Components.interfaces.nsIFilePicker.modeSave); | |
} catch(e) { // Fx124 and earlier | |
fp.init(window, 'Open File', Components.interfaces.nsIFilePicker.modeSave); | |
} | |
fp.appendFilter("JSON Files", "*.json"); | |
fp.defaultString = "sessionstore-snapshot.json"; | |
// Call Save As dialog | |
fp.open((aResult) => { | |
if (aResult == Components.interfaces.nsIFilePicker.returnOK || | |
aResult == Components.interfaces.nsIFilePicker.returnReplace) { | |
try { | |
IOUtils.writeUTF8(fp.file.path, ssj); | |
alert('Look for ' + fp.file.path); | |
} catch (err) { | |
alert(err); | |
} | |
} else { | |
alert('Okay, not saving'); | |
} | |
}); | |
} |
Could not write session state file out of memory undefined
and us this:
Uncaught out of memory
Sorry for the delay in picking up your comment. I can't think of a solution for "out of memory".
The problem has been solved. I mistakenly used 32-bit Firefox. (It's really an unexpected mistake)
No one told me that the error was caused by the memory limit of the 32-bit program. A while ago, I was stuck in Firefox crash without knowing why......
Try/catch added for Firefox 125 (currently in Nightly), at lines 16-18, 20.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Had to update from
OS.File.writeAtomic()
toIOUtils.writeUTF8()
for Firefox 104.