Index: webrequest.js |
=================================================================== |
--- a/webrequest.js |
+++ b/webrequest.js |
@@ -14,16 +14,45 @@ |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://*/*", "https://*/*"]}, ["blocking"]); |
chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["http://*/*", "https://*/*"]}, ["responseHeaders"]); |
chrome.tabs.onRemoved.addListener(forgetTab); |
+var onFilterChangeTimeout = null; |
+function onFilterChange() |
+{ |
+ onFilterChangeTimeout = null; |
+ chrome.webRequest.handlerBehaviorChanged(); |
+} |
+ |
+var importantNotifications = { |
+ 'filter.added': true, |
+ 'filter.removed': true, |
+ 'filter.disabled': true, |
+ 'subscription.added': true, |
+ 'subscription.removed': true, |
+ 'subscription.disabled': true, |
+ 'subscription.updated': true, |
+ 'load': true |
+}; |
+ |
+require("filterNotifier").FilterNotifier.addListener(function(action) |
+{ |
+ if (action in importantNotifications) |
+ { |
+ // Execute delayed to prevent multiple executions in a quick succession |
+ if (onFilterChangeTimeout != null) |
+ window.clearTimeout(onFilterChangeTimeout); |
+ onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000); |
+ } |
+}); |
+ |
var frames = {}; |
function onBeforeRequest(details) |
{ |
if (details.tabId == -1) |
return {}; |
var type = details.type; |