7 Commits

Author SHA1 Message Date
s2
26e7b44b36 v0.0.9 2017-12-13 11:15:59 +01:00
s2
675900d0c8 move screenshots folder 2017-12-13 11:15:37 +01:00
s2
34d0f821a0 actually persist hosts option 2017-12-13 11:15:06 +01:00
s2
75e6a73f7f v0.0.8 2017-12-13 10:31:28 +01:00
s2
bd501edba3 ignore hosts option 2017-12-13 10:30:18 +01:00
s2
52e7e13957 v0.0.7 2017-12-13 09:04:28 +01:00
s2
e3fc267821 fix favicon size 2017-12-13 09:04:14 +01:00
5 changed files with 25 additions and 12 deletions

View File

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 257 KiB

View File

@@ -4,8 +4,6 @@ let tabIcons = {};
var changeIcon = function(color, currentIcon, options) {
var canvas = document.createElement('canvas');
canvas.width = 16;
canvas.height = 16;
var ctx = canvas.getContext('2d');
var img = new Image();
@@ -16,12 +14,14 @@ var changeIcon = function(color, currentIcon, options) {
}
img.onload = function() {
canvas.width = this.naturalWidth;
canvas.height = this.naturalHeight;
ctx.drawImage(img, 0, 0);
ctx.fillStyle = color;
if (options.globals.orientation === 'vertical') {
ctx.fillRect(0, 0, options.globals.width, 16);
ctx.fillRect(0, 0, (options.globals.width / 16) * canvas.width, canvas.height);
} else {
ctx.fillRect(0, 0, 16, options.globals.width);
ctx.fillRect(0, 0, canvas.width, (options.globals.width / 16) * canvas.height);
}
var link = document.createElement('link');
@@ -111,11 +111,16 @@ var updateAllColorsOnAllTabs = async () => {
if (tabs[i].status === 'complete') {
let t = getTabParent(tstTabs, tabs[i].id);
let options = await loadOptions();
browser.tabs.executeScript(tabs[i].id, {
code: '(' + changeIcon.toString() + ')' +
'("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '", ' + JSON.stringify(options) + ')'
});
let tabHost = new URL(tabs[i].url).host;
if (tabHost) {
tabHost = tabHost.toLowerCase();
}
if (!(options.ignore && options.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) {

View File

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

View File

@@ -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>

View File

@@ -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({
@@ -18,7 +19,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
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();