Firefox Browser Console - Save Current Session
This file contains 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); | |
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 { | |
OS.File.writeAtomic(fp.file.path, ssj); | |
alert('Look for ' + fp.file.path); | |
} catch (err) { | |
alert(err); | |
} | |
} else { | |
alert('Okay, not saving'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment