Created
July 19, 2011 04:37
-
-
Save wbamberg/1091317 to your computer and use it in GitHub Desktop.
This file contains 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
const widgets = require("widget"); | |
const tabs = require("tabs"); | |
var tabArray = []; | |
var widget = widgets.Widget({ | |
label: "Show tab history", | |
id: 'tab history', | |
contentURL: "http://www.mozilla.org/favicon.ico", | |
onClick: function() { | |
console.log('\n tab history:'); | |
let n = 0; | |
tabArray.forEach(function(tab) { | |
console.log('tab ' + n + ':'); | |
n++; | |
tab.history.forEach(function(url) { | |
console.log(url); | |
}); | |
}); | |
} | |
}); | |
tabs.on('open', function(tab) { | |
tab.history = []; | |
tabArray.push(tab); | |
}); | |
tabs.on('ready', function(tab) { | |
// we need this special-case code | |
// because 'open' does not get generated | |
// for the first tab in the window | |
if (!tab.history) { | |
tab.history = []; | |
tabArray.push(tab); | |
} | |
tab.history.push(tab.url); | |
}); | |
tabs.on('close', function(tab) { | |
var index = tabArray.indexOf(tab); | |
if (index != -1) { | |
tabArray.splice(index, 1); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment