Compare commits
3 Commits
v0.0.2
...
81f731ad77
Author | SHA1 | Date | |
---|---|---|---|
81f731ad77 | |||
e13a5b4c3b | |||
23564b3c29 |
41
src/bg.js
41
src/bg.js
@@ -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,26 +79,15 @@ var updateAllColorsOnAllTabs = async () => {
|
||||
window: w.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, {
|
||||
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, {
|
||||
code: '(' + changeIcon.toString() + ')' +
|
||||
'("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '")'
|
||||
});
|
||||
}
|
||||
|
||||
if (tabs[i].children && tabs[i].children.length > 0) {
|
||||
changeTabs(tabs[i].children);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
changeTabs(tstTabs);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -115,13 +104,21 @@ browser.runtime.onMessageExternal.addListener((aMessage, aSender) => {
|
||||
}
|
||||
});
|
||||
|
||||
//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();
|
||||
});
|
||||
//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
|
||||
});
|
||||
|
||||
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.4 KiB After Width: | Height: | Size: 4.0 KiB |
BIN
src/img/icon.png
BIN
src/img/icon.png
Binary file not shown.
Before Width: | Height: | Size: 432 KiB After Width: | Height: | Size: 435 KiB |
@@ -2,7 +2,7 @@
|
||||
"description": "Color tabs based on their parent.",
|
||||
"manifest_version": 2,
|
||||
"name": "Color Tab Group",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.1",
|
||||
"homepage_url": "https://git.e.tern.al/s2/tab-groupcolor",
|
||||
"icons": {
|
||||
"48": "img/icon-48.png"
|
||||
|
Reference in New Issue
Block a user