mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-14 08:15:03 +12:00
Make vAPI.setIcon less Chromium specific
This commit is contained in:
parent
c04c4ad4ab
commit
847f86f947
|
@ -245,7 +245,7 @@ vAPI.tabs.injectScript = function(tabId, details, callback) {
|
|||
// Since we may be called asynchronously, the tab id may not exist
|
||||
// anymore, so this ensures it does still exist.
|
||||
|
||||
vAPI.setIcon = function(tabId, img, badge) {
|
||||
vAPI.setIcon = function(tabId, iconStatus, badge) {
|
||||
tabId = parseInt(tabId, 10);
|
||||
var onIconReady = function() {
|
||||
if ( vAPI.lastError() ) {
|
||||
|
@ -253,10 +253,18 @@ vAPI.setIcon = function(tabId, img, badge) {
|
|||
}
|
||||
chrome.browserAction.setBadgeText({ tabId: tabId, text: badge });
|
||||
if ( badge !== '' ) {
|
||||
chrome.browserAction.setBadgeBackgroundColor({ tabId: tabId, color: '#666' });
|
||||
chrome.browserAction.setBadgeBackgroundColor({
|
||||
tabId: tabId,
|
||||
color: '#666'
|
||||
});
|
||||
}
|
||||
};
|
||||
chrome.browserAction.setIcon({ tabId: tabId, path: img }, onIconReady);
|
||||
|
||||
var iconPaths = iconStatus === 'on' ?
|
||||
{ '19': 'img/browsericons/icon19.png', '38': 'img/browsericons/icon38.png' } :
|
||||
{ '19': 'img/browsericons/icon19-off.png', '38': 'img/browsericons/icon38-off.png' };
|
||||
|
||||
chrome.browserAction.setIcon({ tabId: tabId, path: iconPaths }, onIconReady);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
Loading…
Reference in a new issue