diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 05:50:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 05:50:18 +0000 |
commit | 55a5d29a66503248916f249ad2a1d8b37cde5a03 (patch) | |
tree | a3beb6a90dd3bdaaf67ecb05d42152a494aff946 /src/js/broadcast.js | |
parent | Adding upstream version 1.55.0+dfsg. (diff) | |
download | ublock-origin-upstream/1.57.0+dfsg.tar.xz ublock-origin-upstream/1.57.0+dfsg.zip |
Adding upstream version 1.57.0+dfsg.upstream/1.57.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 +); /******************************************************************************/ |