Created
May 14, 2018 22:20
-
-
Save elfsternberg/0c11dab2713481e40a677fe7b01a92cf to your computer and use it in GitHub Desktop.
A small utility, written in nodejs (with a little C), to unpack and display your last known Firefox tab list.
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
#!/usr/bin/env nodejs | |
// ffoxsession is a little utility to dump the contents of your last | |
// known firefox session. Works with 52 through 60 (so far). Requires | |
// the lz4json utility (https://github.com/andikleen/lz4json), as | |
// Firefox uses some weird version of lz4 optimized for JSON data. | |
var fs = require("fs"); | |
var os = require("os"); | |
var execSync = require("child_process").execSync; | |
var root = require('os').homedir() + "/.mozilla/firefox/"; | |
// I use sync'd versions a lot. Performance is not a priority here. | |
var possibles = fs.readdirSync(root).filter(function(f) { | |
return f.indexOf(".default") !== -1; | |
}).map(function(f) { | |
return [root + f, fs.lstatSync(root + f)]; | |
}).sort(function(s) { | |
return [s[1].mtime]; | |
}).map(function(s) { | |
return s[0]; | |
}); | |
if (possibles.length === 0) { | |
console.log("Could not find the user's profile"); | |
process.exit(1); | |
} | |
var path = possibles[0] + "/sessionstore-backups/recovery.jsonlz4"; | |
var input = execSync("lz4jsoncat " + path, {}); | |
var data = JSON.parse(input); | |
data.windows.forEach(function(window) { | |
window.tabs.forEach(function(tab) { | |
// Skip 'about' and 'file' entries: | |
if (tab.entries && tab.entries[0].url.indexOf("http") === 0) { | |
console.log(tab.entries[0].url); | |
} | |
}) | |
}); | |
// LICENSE: | |
// https://creativecommons.org/licenses/by/4.0/ | |
// | |
// This is free software released under the CC-BY license. Users of | |
// this software enjoy the following rights and responsibilities: | |
// | |
// Share — You may copy and redistribute the material in any medium or format | |
// | |
// Adapt — You may remix, transform, and build upon the material for | |
// any purpose, even commercially. | |
// | |
// Attribution — You must give appropriate credit, provide a link to | |
// the license, and indicate if changes were made. You may do so in any | |
// reasonable manner, but not in any way that suggests the licensor | |
// endorses you or your use. | |
// | |
// You may not employ technological measures or legal terms that | |
// legally prevent others from doing anything the license permits. THE | |
// SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY | |
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment