Skip to content

Instantly share code, notes, and snippets.

@jscher2000
Created August 31, 2021 16:10
Show Gist options
  • Save jscher2000/d321a349842deb822cee1be379a26d97 to your computer and use it in GitHub Desktop.
Save jscher2000/d321a349842deb822cee1be379a26d97 to your computer and use it in GitHub Desktop.
Export Synced Tabs to CSV - Firefox Browser Console Script
// Run code in Browser Console after enabling chrome debugging --
// about:config => devtools.chrome.enabled => true
// ** first device only **
try {
var tabPromise = SyncedTabs._internal.getTabClients();
tabPromise.then((arrTabs) => {
if (arrTabs && arrTabs.length > 0){
var csv = 'Tabs from: ' + arrTabs[0].name + '\n\n"Title","URL"';
for (var i=0; i<arrTabs[0].tabs.length; i++){
csv += '\n';
csv += '"' + arrTabs[0].tabs[i].title.replace(/"/g, '""') + '","' + arrTabs[0].tabs[i].url + '"';
}
console.log(csv);
} else {
console.log('NO SYNCED TABS RETRIEVED');
}
}).catch((err) => {
console.log('Problem reading or outputting synced tabs: '+err);
});
} catch (err) {
console.log('Problem reading or outputting synced tabs: '+err);
}
@jscher2000
Copy link
Author

New variation to save a "bookmarks.html" file over here: https://gist.github.com/jscher2000/b7094b3e74b95e5ba9c26f1f685bda6e

@johannish
Copy link

Thank you for this! I modified it to handle tabs from multiple synced devices like this:

		if (arrTabs && arrTabs.length > 0){
			arrTabs.forEach(deviceTabs => {
				var csv = 'Tabs from: ' + deviceTabs.name + '\n\n"Title","URL"';
				for (var i = 0; i < deviceTabs.tabs.length; i++){
					csv += '\n';
					csv += '"' + deviceTabs.tabs[i].title.replace(/"/g, '""') + '","' + deviceTabs.tabs[i].url + '"';
				}
				console.log(csv);
			});
		} else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment