handle other tab events

This commit is contained in:
s2
2017-12-12 08:27:40 +01:00
parent 724bec321b
commit 41d70eb3f0

View File

@@ -115,21 +115,13 @@ browser.runtime.onMessageExternal.addListener((aMessage, aSender) => {
} }
}); });
//when a tab is created //when something happens with a tab
browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { let tabEvents = ['onUpdated', 'onAttached', 'onDetached', 'onMoved', 'onRemoved']
var tstTabs = await browser.runtime.sendMessage(kTST_ID, { tabEvents.forEach((ev) => {
type: 'get-tree', browser.tabs[ev].addListener(async (tabId, changeInfo, tab) => {
window: tab.windowId updateAllColorsOnAllTabs();
});
}); });
if (tab.status === 'complete') {
var t = getTabParent(tstTabs, tab.id);
browser.tabs.executeScript(tab.id, {
code: '(' + changeIcon.toString() + ')' +
'("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '")'
});
}
});
registerToTST(); // aggressive registration on initial installation registerToTST(); // aggressive registration on initial installation