diff options
author | gorhill <rhill@raymondhill.net> | 2014-08-02 11:40:27 -0400 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2014-08-02 11:40:27 -0400 |
commit | bee017034af4314c19ac0931034ee72ed4b5e59f (patch) | |
tree | 8e53dd073560aad7ab4fa110f0cc069d0bb24d5a /js/pagestore.js | |
parent | cc69d0c2d46e659286d553b7bc9738b8c5a90b11 (diff) | |
download | uBlock-bee017034af4314c19ac0931034ee72ed4b5e59f.zip uBlock-bee017034af4314c19ac0931034ee72ed4b5e59f.tar.gz uBlock-bee017034af4314c19ac0931034ee72ed4b5e59f.tar.bz2 |
this fixes #5
Diffstat (limited to 'js/pagestore.js')
-rw-r--r-- | js/pagestore.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/js/pagestore.js b/js/pagestore.js index 1d55200..79f96f2 100644 --- a/js/pagestore.js +++ b/js/pagestore.js @@ -111,6 +111,8 @@ PageStore.prototype.init = function(tabId, pageURL) { this.pageHostname = µb.URI.hostnameFromURI(pageURL); this.pageDomain = µb.URI.domainFromHostname(this.pageHostname); this.frames = disposeFrameStores(this.frames); + this.netFiltering = true; + this.netFilteringReadTime = 0; this.perLoadBlockedRequestCount = 0; this.perLoadAllowedRequestCount = 0; this.blockedRequests = {}; @@ -122,16 +124,9 @@ PageStore.prototype.init = function(tabId, pageURL) { /******************************************************************************/ PageStore.prototype.reuse = function(pageURL) { - this.previousPageURL = this.pageURL; - this.pageURL = pageURL; - this.pageHostname = µb.URI.hostnameFromURI(pageURL); - this.pageDomain = µb.URI.domainFromHostname(this.pageHostname); - this.frames = disposeFrameStores(this.frames); - this.perLoadBlockedRequestCount = 0; - this.perLoadAllowedRequestCount = 0; - this.blockedRequests = {}; - this.allowedRequests = {}; - this.disposeTime = 0; + var previousPageURL = this.pageURL; + this.init(this.tabId, pageURL); + this.previousPageURL = previousPageURL; return this; }; @@ -169,6 +164,16 @@ PageStore.prototype.getFrame = function(frameId) { /******************************************************************************/ +PageStore.prototype.getNetFilteringSwitch = function() { + if ( this.netFilteringReadTime < µb.netWhitelistModifyTime ) { + this.netFiltering = µb.getNetFilteringSwitch(this.pageURL, this.pageDomain); + this.netFilteringReadTime = Date.now(); + } + return this.netFiltering; +}; + +/******************************************************************************/ + PageStore.prototype.recordRequest = function(type, url, reason) { var blocked = reason !== false && reason.slice(0, 2) !== '@@'; @@ -212,13 +217,13 @@ PageStore.prototype.updateBadge = function() { // https://github.com/gorhill/uBlock/issues/19 // TODO: need to check with µb object to see whether tab still exists. - var netFilteringSwitch = µb.getNetFilteringSwitch(this.pageHostname); - var iconPath = netFilteringSwitch ? 'img/browsericons/icon19.png' : 'img/browsericons/icon19-off.png'; + var netFiltering = this.getNetFilteringSwitch(); + var iconPath = netFiltering ? 'img/browsericons/icon19.png' : 'img/browsericons/icon19-off.png'; chrome.browserAction.setIcon({ tabId: this.tabId, path: iconPath }); var iconStr = ''; - if ( µb.userSettings.showIconBadge && netFilteringSwitch && this.perLoadBlockedRequestCount ) { + if ( µb.userSettings.showIconBadge && netFiltering && this.perLoadBlockedRequestCount ) { iconStr = this.perLoadBlockedRequestCount.toLocaleString(); } chrome.browserAction.setBadgeText({ |