In Chrome 51, incognito windows now have a dark toolbar background, while previous versions used a light background. It's generally infeasible for a single 16x16 image to provide good contrast in both situations:
When displaying information to the user through a browserAction
icon, by what mechanism can an extension provide dark-themed and light-themed icons, and switch between them depending on the current toolbar color?
Link to source code for the pictured extension
1a : something that makes vision possible. b : the sensation aroused by stimulation of the visual receptors. c : electromagnetic radiation of any wavelength that travels in a vacuum with a speed of 299,792,458 meters (about 186,000 miles) per second specifically : such radiation that is visible to the human eye.
As an adjective, light is something that is not heavy, burdensome, or somber. A knapsack could be light, as could a topic of conversation, or a piece of music.
What is light in physics? Light is electromagnetic radiation that can be detected by the human eye. Electromagnetic radiation occurs over an extremely wide range of wavelengths, from gamma rays with wavelengths less than about 1 × 10−11 metres to radio waves measured in metres.
There is no such simple mechanism (yet), and it sounds like an excellent feature request to make at the very least for the manifest.
It's possible to approximate this though, by detecting incognito tabs being open and replacing the browser action icon for that tab only.
var incognitoIcons = {
19: "incognito19.png",
38: "incognito38.png"
};
chrome.tabs.onCreated.addListener(function(tab) {
if (tab.incognito) {
chrome.browserAction.setIcon({
path: incognitoIcons,
tabId: tab.id
});
}
});
If you're using a "split"
incognito behavior (non-default), you can simply detect that and change the global icon for the incognito instance:
// Somewhere in background during initialization
if (chrome.extension.inIncognitoContext) {
chrome.browserAction.setIcon({path: incognitoIcons});
}
Note that content scripts can always rely on inIncognitoContext
, so if you trigger a browser action icon change from them you can pass that along.
Obviously, you can do that with imageData
instead of path
, as is your case.
You may want to check the Chrome version while you're at it; I'm not aware of a better way than mentioned here.
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