Skip to content

Instantly share code, notes, and snippets.

@hiroshil
Forked from tmonjalo/list-fftabs.py
Last active December 7, 2021 05:03
Show Gist options
  • Save hiroshil/8d6aef3d7fff2463fe86bf8c24f2d7d5 to your computer and use it in GitHub Desktop.
Save hiroshil/8d6aef3d7fff2463fe86bf8c24f2d7d5 to your computer and use it in GitHub Desktop.
List all Firefox tabs with title and URL
var path = require("path");
var globule = require('globule');
var jsonlz4 = require('jsonlz4-decompress');
var fs = require('fs');
function getTabs() {
var fpath;
if (process.platform == "darwin") {
fpath = path.join(process.env.HOME, 'Library/Preferences');
} else if (process.platform == "win32" || process.platform == "win64") {
fpath = path.join(process.env.APPDATA, 'Mozilla\\Firefox\\Profiles');
} else if (process.platform == "linux") {
fpath = path.join(process.env.HOME, ".mozilla/firefox");
}
var files = globule.find(fpath + '**/**/recovery.js*');
for (var i in files) {
if (files[i].includes("default") && files[i].includes("sessionstore-backups")) {
var fileBuffer = fs.readFileSync(files[i]);
let j = jsonlz4(fileBuffer);
let entries = new Array();
for (var k in j['windows']) {
let w = j['windows'][k];
for (var m in w['tabs']) {
let t = w['tabs'][m];
let i = t['index'] - 1;
var entrie = new Object();
entrie.title = t['entries'][i]['title'];
entrie.url = t['entries'][i]['url'];
entries.push(entrie);
}
}
return JSON.parse(JSON.stringify(entries));
}
}
}
console.log(getTabs());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment