mirror of
https://github.com/microsoft/Web-Dev-For-Beginners.git
synced 2025-08-15 03:06:02 +02:00
folder names
This commit is contained in:
17
5-browser-extension/solution/dist/background.js
vendored
Normal file
17
5-browser-extension/solution/dist/background.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||
if (msg.action === 'updateIcon') {
|
||||
chrome.browserAction.setIcon({ imageData: drawIcon(msg.value) });
|
||||
}
|
||||
});
|
||||
//borrowed from energy lollipop extension, nice feature!
|
||||
function drawIcon(value) {
|
||||
let canvas = document.createElement('canvas');
|
||||
let context = canvas.getContext('2d');
|
||||
|
||||
context.beginPath();
|
||||
context.fillStyle = value.color;
|
||||
context.arc(100, 100, 50, 0, 2 * Math.PI);
|
||||
context.fill();
|
||||
|
||||
return context.getImageData(50, 50, 100, 100);
|
||||
}
|
Reference in New Issue
Block a user