Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
bc067d663e | |||
922de5d1d1 | |||
f15fa07880 | |||
2452acf440 | |||
e675bc4372 | |||
a1c8f5bb6e | |||
19571e036f | |||
7911e8a898 | |||
5c4ed146e6 | |||
dcd76d7240 | |||
3dc143c9d8 | |||
21dd898d44 | |||
757adc4722 | |||
26e7b44b36 | |||
675900d0c8 | |||
34d0f821a0 | |||
75e6a73f7f | |||
bd501edba3 |
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 257 KiB |
20
src/bg.js
20
src/bg.js
@@ -7,7 +7,7 @@ var changeIcon = function(color, currentIcon, options) {
|
||||
var ctx = canvas.getContext('2d');
|
||||
var img = new Image();
|
||||
|
||||
if (currentIcon && typeof(currentIcon) !== 'undefined' && currentIcon !== null && currentIcon !== 'undefined') {
|
||||
if (currentIcon && typeof(currentIcon) !== 'undefined' && currentIcon !== null && currentIcon !== "null" && currentIcon !== 'undefined') {
|
||||
img.src = currentIcon;
|
||||
} else {
|
||||
img.src = 'data:image/x-icon;base64,AAABAAEAEBACAAEAAQCwAAAAFgAAACgAAAAQAAAAIAAAAAEAAQAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA';
|
||||
@@ -39,14 +39,13 @@ var changeIcon = function(color, currentIcon, options) {
|
||||
};
|
||||
|
||||
var generateRandomColor = function(seed) {
|
||||
var selectColor = function (colorNum, colors) {
|
||||
if (colors < 1) {
|
||||
colors = 1; // defaults to one color - avoid divide by zero
|
||||
}
|
||||
return "hsl(" + (colorNum * (360 / colors) % 360) + ",100%,50%)";
|
||||
var colors = ['#e6194b', '#3cb44b', '#ffe119', '#0082c8', '#f58231', '#FFFFFF'];
|
||||
|
||||
var selectColor = function (colorNum) {
|
||||
return colors[seed % colors.length]
|
||||
}
|
||||
|
||||
return selectColor(seed, 8);
|
||||
return selectColor(seed);
|
||||
};
|
||||
|
||||
var registerToTST = async function() {
|
||||
@@ -111,12 +110,17 @@ var updateAllColorsOnAllTabs = async () => {
|
||||
if (tabs[i].status === 'complete') {
|
||||
let t = getTabParent(tstTabs, tabs[i].id);
|
||||
let options = await loadOptions();
|
||||
|
||||
let tabHost = new URL(tabs[i].url).host;
|
||||
if (tabHost) {
|
||||
tabHost = tabHost.toLowerCase();
|
||||
}
|
||||
if (!(options.globals.ignore && options.globals.ignore.split('\n').includes(tabHost))) {
|
||||
browser.tabs.executeScript(tabs[i].id, {
|
||||
code: '(' + changeIcon.toString() + ')' +
|
||||
'("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '", ' + JSON.stringify(options) + ')'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (tabs[i].children && tabs[i].children.length > 0) {
|
||||
await changeTabs(tabs[i].children);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"description": "Color tabs based on their parent.",
|
||||
"manifest_version": 2,
|
||||
"name": "Color Tab Group",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.14",
|
||||
"homepage_url": "https://git.e.tern.al/s2/tab-groupcolor",
|
||||
"icons": {
|
||||
"48": "img/icon-48.png"
|
||||
|
@@ -26,6 +26,13 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="panel-formElements-item browser-style">
|
||||
<label for="ignore">Ignore hosts (one per line - ex.: google.com):</label>
|
||||
</div>
|
||||
<div class="panel-formElements-item browser-style">
|
||||
<textarea id="ignore"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
@@ -3,7 +3,8 @@ function persistOptions() {
|
||||
|
||||
globals = {
|
||||
width: document.querySelector('#indicator-width').value,
|
||||
orientation: document.querySelector('#indicator-orientation').value
|
||||
orientation: document.querySelector('#indicator-orientation').value,
|
||||
ignore: document.querySelector('#ignore').value
|
||||
};
|
||||
|
||||
return browser.storage.local.set({
|
||||
@@ -15,10 +16,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
loadOptions().then((options) => {
|
||||
document.querySelector('#indicator-width').value = options.globals.width;
|
||||
document.querySelector('#indicator-orientation').value = options.globals.orientation;
|
||||
document.querySelector('#ignore').value = options.globals.ignore;
|
||||
});
|
||||
});
|
||||
|
||||
var list = document.querySelectorAll('select,input');
|
||||
var list = document.querySelectorAll('select,input,textarea');
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i].addEventListener('change', (ev) => {
|
||||
persistOptions();
|
||||
|
@@ -1,8 +1,9 @@
|
||||
function loadOptions() {
|
||||
return browser.storage.local.get({
|
||||
globals: {
|
||||
width: 3,
|
||||
orientation: 'vertical'
|
||||
width: 5,
|
||||
orientation: 'horizontal',
|
||||
ignore: 'web.whatsapp.com'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user