Here I am working with chrome extension development.
my manifest.json page as show
{ "name": "DemoExtension", "version": "1.0", "description": "Official addon from demeo", "browser_action": { "default_icon": "star-on.png", "popup": "shopcmp.htm" }, "permissions": [ "tabs" ], "background_page": "background.html" } Here I want to change my default icon image at runtime.
One or more icons that represent the extension, app, or theme.
An ICON file contains image data for a computer icon used to represent files, folders, applications, and so on. ICON files are typically saved as small, square bitmap images, ranging from 16 x 16 to 256 x 256 pixels in size. Most Windows Icon files use the . ICO extension.
A browser action is a button that your extension adds to the browser's toolbar. The button has an icon, and may optionally have a popup whose content is specified using HTML, CSS, and JavaScript.
If you want to change the browser action default icon, just change
"browser_action": { "default_icon": "star-on.png", //<--this line: change "star-on.png" to the icon you want "popup": "shopcmp.htm" }, That line indicates the default icon on first load of the extension.
To change the icon in code, call chrome.browserAction.setIcon(details).
If you want to change the extension icon (the icons that shows during installation, in the Chrome Web Store, in the extension management page, and as a favicon), add an icons property to your manifest.json file.
To change the default chrome extension pragmatically you can do:
chrome.browserAction.setIcon({ path: "my-icon.png" }); or for custom sizes:
chrome.browserAction.setIcon({ path: { 19: "my-icon19.png" } }); Full docs: https://developer.chrome.com/docs/extensions/reference/browserAction/#method-setIcon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With