Skip to content

Instantly share code, notes, and snippets.

@wbamberg
Created July 19, 2011 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbamberg/1091317 to your computer and use it in GitHub Desktop.
Save wbamberg/1091317 to your computer and use it in GitHub Desktop.
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