Compare commits
5 Commits
81f731ad77
...
v0.0.2
Author | SHA1 | Date | |
---|---|---|---|
0a00b1c1f1 | |||
41d70eb3f0 | |||
724bec321b | |||
90f7108eee | |||
c56454a097 |
49
src/bg.js
49
src/bg.js
@@ -58,7 +58,7 @@ var getTabParent = (tabs, id, currentTopLevelTabPos) => {
|
|||||||
if (tabs[i].id === id) {
|
if (tabs[i].id === id) {
|
||||||
return {
|
return {
|
||||||
parentIndex: currentTopLevelTabPos,
|
parentIndex: currentTopLevelTabPos,
|
||||||
faviconUrl: tabs[i].faviconUrl
|
faviconUrl: tabs[i].favIconUrl
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if (tabs[i].children && tabs[i].children.length > 0) {
|
if (tabs[i].children && tabs[i].children.length > 0) {
|
||||||
@@ -79,15 +79,26 @@ var updateAllColorsOnAllTabs = async () => {
|
|||||||
window: w.id
|
window: w.id
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < tstTabs.length; i++) {
|
var changeTabs = (tabs) => {
|
||||||
if (tstTabs[i].status === 'complete') {
|
|
||||||
let t = getTabParent(tstTabs, tstTabs[i].id);
|
for (let i = 0; i < tabs.length; i++) {
|
||||||
browser.tabs.executeScript(tstTabs[i].id, {
|
|
||||||
code: '(' + changeIcon.toString() + ')' +
|
if (tabs[i].status === 'complete') {
|
||||||
'("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '")'
|
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
|
//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
|
||||||
|
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 |
BIN
src/img/icon.png
BIN
src/img/icon.png
Binary file not shown.
Before Width: | Height: | Size: 435 KiB After Width: | Height: | Size: 432 KiB |
@@ -2,7 +2,7 @@
|
|||||||
"description": "Color tabs based on their parent.",
|
"description": "Color tabs based on their parent.",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Color Tab Group",
|
"name": "Color Tab Group",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"homepage_url": "https://git.e.tern.al/s2/tab-groupcolor",
|
"homepage_url": "https://git.e.tern.al/s2/tab-groupcolor",
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "img/icon-48.png"
|
"48": "img/icon-48.png"
|
||||||
|
Reference in New Issue
Block a user