Skip to content

Instantly share code, notes, and snippets.

@mixu
Created August 17, 2013 19:36
Show Gist options
  • Save mixu/6258404 to your computer and use it in GitHub Desktop.
Save mixu/6258404 to your computer and use it in GitHub Desktop.
Get a JSON structure with all your open tabs
// Needs to be run in the context of an extension with the "tabs" permission.
chrome.tabs.query({}, function(tabs) {
var byWindow = {};
tabs.forEach(function(t) {
if(!byWindow[t.windowId]) {
byWindow[t.windowId] = []
}
byWindow[t.windowId].push(t.url);
console.log(JSON.stringify(byWindow, null, 2));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment