Added options with blacklist and theme. Created a function for changing the extension icon color.
This commit is contained in:
34
assets/js/helpers/changeExtensionIcon.js
Normal file
34
assets/js/helpers/changeExtensionIcon.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* It changes the extension icon color.
|
||||
* Supported values are: 'red', 'white' and ''.
|
||||
*
|
||||
* @param string color = ''
|
||||
* @return null
|
||||
*/
|
||||
export default function changeExtensionIcon(color = '') {
|
||||
|
||||
var canvas = document.getElementById('icon');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var width = 19;
|
||||
var height = 19;
|
||||
var imageObj = new Image();
|
||||
|
||||
imageObj.onload = function() {
|
||||
context.drawImage(imageObj, x, y, width, height);
|
||||
|
||||
var imageData = context.getImageData(x, y, width, height);
|
||||
|
||||
chrome.browserAction.setIcon({
|
||||
imageData: imageData
|
||||
});
|
||||
};
|
||||
|
||||
if(color !== ''){
|
||||
color = '-' + color;
|
||||
}
|
||||
|
||||
imageObj.src = 'graphics/wakatime-logo-48' + color + '.png';
|
||||
}
|
||||
Reference in New Issue
Block a user