diff --git a/README.md b/README.md index e81fe00..1fee4ee 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ At the moment this is not possible because of Firefox bug [1320585](https://bugz So this extension **tries** to get the favicon of the newly opened tab, and changes the color of the favicon to match that of the parent. But it will not work -- on pages that don't have a favicon - on pages that don't allow content scripts (amo for example) - on pages that dynamically change the favicon - a lot of other cases diff --git a/src/bg.js b/src/bg.js index 5799d42..d21e5ff 100644 --- a/src/bg.js +++ b/src/bg.js @@ -7,7 +7,15 @@ var changeIcon = function(color, currentIcon) { canvas.height = 16; var ctx = canvas.getContext('2d'); var img = new Image(); - img.src = currentIcon; + + if (currentIcon && typeof(currentIcon) !== 'undefined' && currentIcon !== null && currentIcon !== 'undefined') { + console.log(currentIcon); + 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'; + } + + console.log(img.src); img.onload = function() { ctx.drawImage(img, 0, 0); ctx.fillStyle = color; @@ -85,6 +93,7 @@ var updateAllColorsOnAllTabs = async () => { if (tabs[i].status === 'complete') { let t = getTabParent(tstTabs, tabs[i].id); + browser.tabs.executeScript(tabs[i].id, { code: '(' + changeIcon.toString() + ')' + '("' + generateRandomColor(t.parentIndex) + '", "' + t.faviconUrl + '")'