Skip to content

Instantly share code, notes, and snippets.

@Enchufadoo
Created November 25, 2018 12:43
Show Gist options
  • Save Enchufadoo/ec1497cbc2265ae1a24e586cc583f2d0 to your computer and use it in GitHub Desktop.
Save Enchufadoo/ec1497cbc2265ae1a24e586cc583f2d0 to your computer and use it in GitHub Desktop.
Set webextension icon color
/** 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