5 Commits

Author SHA1 Message Date
s2
0a00b1c1f1 v0.0.2 2017-12-12 08:28:08 +01:00
s2
41d70eb3f0 handle other tab events 2017-12-12 08:27:40 +01:00
s2
724bec321b fix updateAllColorsOnAllTabs 2017-12-12 08:21:31 +01:00
s2
90f7108eee icons 2017-12-12 08:21:31 +01:00
s2
c56454a097 just text 2017-12-12 08:21:25 +01:00
5 changed files with 27 additions and 24 deletions

View File

@@ -58,7 +58,7 @@ var getTabParent = (tabs, id, currentTopLevelTabPos) => {
if (tabs[i].id === id) {
return {
parentIndex: currentTopLevelTabPos,
faviconUrl: tabs[i].faviconUrl
faviconUrl: tabs[i].favIconUrl
};
} else {
if (tabs[i].children && tabs[i].children.length > 0) {
@@ -79,15 +79,26 @@ var updateAllColorsOnAllTabs = async () => {
window: w.id
});
for (let i = 0; i < tstTabs.length; i++) {
if (tstTabs[i].status === 'complete') {
let t = getTabParent(tstTabs, tstTabs[i].id);
browser.tabs.executeScript(tstTabs[i].id, {
var changeTabs = (tabs) => {
for (let i = 0; i < tabs.length; i++) {
if (tabs[i].status === 'complete') {
let t = getTabParent(tstTabs, tabs[i].id);
browser.tabs.executeScript(tabs[i].id, {
code: '(' + changeIcon.toString() + ')' +
'("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '")'
});
}
if (tabs[i].children && tabs[i].children.length > 0) {
changeTabs(tabs[i].children);
}
}
};
changeTabs(tstTabs);
});
}
@@ -104,21 +115,13 @@ browser.runtime.onMessageExternal.addListener((aMessage, aSender) => {
}
});
//when a tab is created
browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
var tstTabs = await browser.runtime.sendMessage(kTST_ID, {
type: 'get-tree',
window: tab.windowId
//when something happens with a tab
let tabEvents = ['onUpdated', 'onAttached', 'onDetached', 'onMoved', 'onRemoved']
tabEvents.forEach((ev) => {
browser.tabs[ev].addListener(async (tabId, changeInfo, tab) => {
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 KiB

After

Width:  |  Height:  |  Size: 432 KiB

View File

@@ -2,7 +2,7 @@
"description": "Color tabs based on their parent.",
"manifest_version": 2,
"name": "Color Tab Group",
"version": "0.0.1",
"version": "0.0.2",
"homepage_url": "https://git.e.tern.al/s2/tab-groupcolor",
"icons": {
"48": "img/icon-48.png"