5 Commits

Author SHA1 Message Date
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
s2
2c81a30231 v0.0.6 2017-12-13 08:24:16 +01:00
s2
352131be4f ws 2017-12-13 08:23:50 +01:00
s2
65aadb4624 don't clutter the page with favicons 2017-12-13 08:22:37 +01:00
2 changed files with 11 additions and 6 deletions

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,19 +14,26 @@ 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');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = canvas.toDataURL("image/x-icon");
link.id = 'tab-groupcolor' + '-favicon';
var oldicon = document.getElementById('tab-groupcolor' + '-favicon');
if (oldicon) {
oldicon.outerHTML = '';
delete oldicon;
}
document.getElementsByTagName('head')[0].appendChild(link);
}
};

View File

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