Skip to content

Instantly share code, notes, and snippets.

@ThisIsMissEm
Created September 8, 2023 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThisIsMissEm/20ed76a36e8eb1e6f360a50cfb0d8411 to your computer and use it in GitHub Desktop.
Save ThisIsMissEm/20ed76a36e8eb1e6f360a50cfb0d8411 to your computer and use it in GitHub Desktop.
This is a little script that I used to migrate my tabs from Chrome to Firefox, by using Tab Session Manager. Unfortunately though, the export file from Chrome failed silently to import to Firefox, so I needed to process the file: this produces output of the tab URLs and the title of each tab in a window, separated out by the windows that you had…
import { readFile } from 'node:fs/promises'
async function main(args) {
const file = args[2];
const contents = await readFile(args[2], { encoding: "utf8" })
const session = JSON.parse(contents)[0];
let count = 0;
for (const windowId in session.windows) {
const window = session.windows[windowId];
process.stdout.write("\n\n --- \n\n");
for (const tabId in window) {
const tab = window[tabId];
process.stdout.write(`${tab.url} ${tab.title}\n`);
}
}
};
main(process.argv).catch(console.error.bind(console));
{
"type": "module",
"name": "export-tsm-urls",
"private": true,
"version": "1.0.0",
"engines" : {
"node" : ">=18"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment