Created
November 29, 2017 09:13
-
-
Save teerapap/028501ad18ad2f2ee2d4338c7d36cb62 to your computer and use it in GitHub Desktop.
A hacky script to restore Quicksaver's tab groups from Firefox session backup.
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
/* | |
* restore-quicksaver-tab-groups.js | |
* Copyright (C) 2017 Teerapap Changwichukarn <[email protected]> | |
* | |
* Distributed under terms of the MIT license. | |
*/ | |
// This script restores tab groups from Firefox session backup. | |
// For my case, OSX, the session backup is at ~/Library/Application\ Support/Firefox/Profiles/{random string}.default/sessionstore-backups/previous.js | |
// Actually this backup file is a JSON file so the script just parses it and pretty-print as html file. | |
var fs = require('fs'); | |
var obj = JSON.parse(fs.readFileSync('previous.js', 'utf8')); | |
var tabgroups = JSON.parse(obj["windows"][0]["extData"]["tabview-group"]); | |
var tabs = obj["windows"][0]["tabs"]; | |
tabgroups["pin"] = {"title": "Pinned tab"}; | |
console.log("<html><head></head><body>"); | |
for (i=0;i<tabs.length;i++) { | |
var gid = "pin"; | |
if (tabs[i]["extData"]["tabview-tab"] !== "null") { | |
gid = JSON.parse(tabs[i]["extData"]["tabview-tab"])["groupID"]; | |
} | |
if (!("entries" in tabgroups[gid])) { | |
tabgroups[gid]["entries"] = []; | |
} | |
Array.prototype.push.apply(tabgroups[gid]["entries"], tabs[i]["entries"]); | |
} | |
for (gid in tabgroups) { | |
console.log("<h1>" + tabgroups[gid]["title"] + "</h2>\n"); | |
console.log("<ul>\n"); | |
if ("entries" in tabgroups[gid]) { | |
for (i=0;i<tabgroups[gid]["entries"].length;i++) { | |
var title = tabgroups[gid]["entries"][i]["title"]; | |
var url = tabgroups[gid]["entries"][i]["url"]; | |
console.log("<li> " + title + " (<a href=\"" + url +"\">" + url + "</a>)</li>\n"); | |
} | |
} | |
console.log("</ul>\n"); | |
} | |
console.log("</body></html>"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment