Created
November 25, 2018 12:43
-
-
Save Enchufadoo/ec1497cbc2265ae1a24e586cc583f2d0 to your computer and use it in GitHub Desktop.
Set webextension icon color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Too slowwww **/ | |
const setIconColor = function(){ | |
let img = new Image(); | |
img.src = "icons/binoculars_white.png"; | |
img.onload = function() { | |
var canvas = document.createElement("canvas"); | |
var ctx = canvas.getContext("2d"); | |
ctx.drawImage(img, 0, 0); | |
ctx.globalCompositeOperation = "source-in"; | |
ctx.fillStyle = "#09f"; //any color | |
ctx.fillRect(0, 0, 64, 64); | |
let imageData = ctx.getImageData(0, 0, 64, 64); | |
browser.browserAction.setIcon({imageData: imageData}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment