mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
code review
This commit is contained in:
parent
b5db231ef9
commit
5f4d975966
@ -13,8 +13,8 @@
|
||||
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
"19": "img/browsericons/icon19-off.png",
|
||||
"38": "img/browsericons/icon38-off.png"
|
||||
"19": "img/browsericons/icon19.png",
|
||||
"38": "img/browsericons/icon38.png"
|
||||
},
|
||||
"default_title": "uBlock Origin",
|
||||
"default_popup": "popup.html"
|
||||
|
@ -747,8 +747,7 @@ vAPI.onLoadAllCompleted = function() {
|
||||
}
|
||||
};
|
||||
|
||||
chrome.tabs.query({ url: 'http://*/*' }, bindToTabs);
|
||||
chrome.tabs.query({ url: 'https://*/*' }, bindToTabs);
|
||||
chrome.tabs.query({ url: '<all_urls>' }, bindToTabs);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -172,32 +172,32 @@ return asyncJobManager;
|
||||
// Update visual of extension icon.
|
||||
|
||||
µBlock.updateBadgeAsync = (function() {
|
||||
var µb = µBlock;
|
||||
var tabIdToTimer = {};
|
||||
var tabIdToTimer = Object.create(null);
|
||||
|
||||
var updateBadge = function(tabId) {
|
||||
delete tabIdToTimer[tabId];
|
||||
|
||||
var pageStore = µb.pageStoreFromTabId(tabId);
|
||||
if ( pageStore === null ) {
|
||||
return;
|
||||
var state = false;
|
||||
var badge = '';
|
||||
|
||||
var pageStore = this.pageStoreFromTabId(tabId);
|
||||
if ( pageStore !== null ) {
|
||||
state = pageStore.getNetFilteringSwitch();
|
||||
if ( state && this.userSettings.showIconBadge && pageStore.perLoadBlockedRequestCount ) {
|
||||
badge = this.utils.formatCount(pageStore.perLoadBlockedRequestCount);
|
||||
}
|
||||
}
|
||||
|
||||
var netFiltering = pageStore.getNetFilteringSwitch();
|
||||
var badge = '';
|
||||
if ( µb.userSettings.showIconBadge && netFiltering && pageStore.perLoadBlockedRequestCount ) {
|
||||
badge = µb.utils.formatCount(pageStore.perLoadBlockedRequestCount);
|
||||
}
|
||||
vAPI.setIcon(tabId, netFiltering ? 'on' : 'off', badge);
|
||||
vAPI.setIcon(tabId, state ? 'on' : 'off', badge);
|
||||
};
|
||||
|
||||
return function(tabId) {
|
||||
if ( tabIdToTimer[tabId] ) {
|
||||
return;
|
||||
}
|
||||
if ( vAPI.isBehindTheSceneTabId(tabId) ) {
|
||||
return;
|
||||
}
|
||||
if ( tabIdToTimer.hasOwnProperty(tabId) ) {
|
||||
return;
|
||||
}
|
||||
tabIdToTimer[tabId] = setTimeout(updateBadge.bind(null, tabId), 500);
|
||||
tabIdToTimer[tabId] = setTimeout(updateBadge.bind(this, tabId), 500);
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user