1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

code review

This commit is contained in:
gorhill 2015-05-02 00:13:19 -04:00
parent b5db231ef9
commit 5f4d975966
3 changed files with 18 additions and 19 deletions

View File

@ -13,8 +13,8 @@
"browser_action": { "browser_action": {
"default_icon": { "default_icon": {
"19": "img/browsericons/icon19-off.png", "19": "img/browsericons/icon19.png",
"38": "img/browsericons/icon38-off.png" "38": "img/browsericons/icon38.png"
}, },
"default_title": "uBlock Origin", "default_title": "uBlock Origin",
"default_popup": "popup.html" "default_popup": "popup.html"

View File

@ -747,8 +747,7 @@ vAPI.onLoadAllCompleted = function() {
} }
}; };
chrome.tabs.query({ url: 'http://*/*' }, bindToTabs); chrome.tabs.query({ url: '<all_urls>' }, bindToTabs);
chrome.tabs.query({ url: 'https://*/*' }, bindToTabs);
}; };
/******************************************************************************/ /******************************************************************************/

View File

@ -172,32 +172,32 @@ return asyncJobManager;
// Update visual of extension icon. // Update visual of extension icon.
µBlock.updateBadgeAsync = (function() { µBlock.updateBadgeAsync = (function() {
var µb = µBlock; var tabIdToTimer = Object.create(null);
var tabIdToTimer = {};
var updateBadge = function(tabId) { var updateBadge = function(tabId) {
delete tabIdToTimer[tabId]; delete tabIdToTimer[tabId];
var pageStore = µb.pageStoreFromTabId(tabId); var state = false;
if ( pageStore === null ) { var badge = '';
return;
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(); vAPI.setIcon(tabId, state ? 'on' : 'off', badge);
var badge = '';
if ( µb.userSettings.showIconBadge && netFiltering && pageStore.perLoadBlockedRequestCount ) {
badge = µb.utils.formatCount(pageStore.perLoadBlockedRequestCount);
}
vAPI.setIcon(tabId, netFiltering ? 'on' : 'off', badge);
}; };
return function(tabId) { return function(tabId) {
if ( tabIdToTimer[tabId] ) {
return;
}
if ( vAPI.isBehindTheSceneTabId(tabId) ) { if ( vAPI.isBehindTheSceneTabId(tabId) ) {
return; return;
} }
if ( tabIdToTimer.hasOwnProperty(tabId) ) { tabIdToTimer[tabId] = setTimeout(updateBadge.bind(this, tabId), 500);
return;
}
tabIdToTimer[tabId] = setTimeout(updateBadge.bind(null, tabId), 500);
}; };
})(); })();