-
-
Save hiroshil/8d6aef3d7fff2463fe86bf8c24f2d7d5 to your computer and use it in GitHub Desktop.
List all Firefox tabs with title and URL
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
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