|
|
|
@ -115,12 +115,12 @@ And finally, in `/dist/background.js`, add the listener for these background act
|
|
|
|
|
```JavaScript
|
|
|
|
|
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
|
|
|
|
if (msg.action === 'updateIcon') {
|
|
|
|
|
chrome.browserAction.setIcon({ imageData: drawIcon(msg.value) });
|
|
|
|
|
chrome.action.setIcon({ imageData: drawIcon(msg.value) });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//borrowed from energy lollipop extension, nice feature!
|
|
|
|
|
function drawIcon(value) {
|
|
|
|
|
let canvas = document.createElement('canvas');
|
|
|
|
|
let canvas = new OffscreenCanvas(200, 200);
|
|
|
|
|
let context = canvas.getContext('2d');
|
|
|
|
|
|
|
|
|
|
context.beginPath();
|
|
|
|
|