diff options
Diffstat (limited to '')
-rw-r--r-- | src/js/broadcast.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/js/broadcast.js b/src/js/broadcast.js index 0bef46c..61d647f 100644 --- a/src/js/broadcast.js +++ b/src/js/broadcast.js @@ -19,9 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* globals browser */ - -'use strict'; +import webext from './webext.js'; /******************************************************************************/ @@ -47,7 +45,7 @@ export async function broadcastToAll(message) { }); const bcmessage = Object.assign({ broadcast: true }, message); for ( const tab of tabs ) { - browser.tabs.sendMessage(tab.id, bcmessage); + webext.tabs.sendMessage(tab.id, bcmessage).catch(( ) => { }); } } @@ -69,7 +67,19 @@ export function filteringBehaviorChanged(details = {}) { } filteringBehaviorChanged.throttle = vAPI.defer.create(( ) => { + const { history, max } = filteringBehaviorChanged; + const now = (Date.now() / 1000) | 0; + if ( history.length >= max ) { + if ( (now - history[0]) <= (10 * 60) ) { return; } + history.shift(); + } + history.push(now); vAPI.net.handlerBehaviorChanged(); }); +filteringBehaviorChanged.history = []; +filteringBehaviorChanged.max = Math.min( + browser.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES - 1, + 19 +); /******************************************************************************/ |