Programmatically change icon of Safari browser extension?
icons, safari, safari-extension
Solution
Any toolbar items your extension has can be referenced as an array in
safari.extension.toolbarItems
Each toolbar item will have an image property which you can change. This will cause the toolbar icon to change immediately.
// Change the toolbar icon.
var changeToolbarIcon = function(newIconName) {
var iconUri = safari.extension.baseURI + 'icons/' + newIconName;
safari.extension.toolbarItems[0].image = iconUri;
};
The Safari Documentation
Problem
I have a Safari browser extension with a disabled mode. What I'd like to do is to programmatically change the toolbar icon when the user enters disabled mode. Is there an API which will allow me to achieve this and if so what is it?