mirror of
https://github.com/gorhill/uBlock.git
synced 2024-08-31 16:19:39 +02:00
Do not exceed rate-limited calls to handlerBehaviorChanged()
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3063 To prevent spurious performance warnings by chromium-based browsers.
This commit is contained in:
parent
ba3a8d58a7
commit
63fe18a761
@ -69,7 +69,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
|
||||
);
|
||||
|
||||
/******************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user