mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
parent
11fe8ee3b5
commit
3db46c1728
@ -2704,7 +2704,7 @@ function cookieRemover(
|
|||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
const reName = safe.patternToRegex(needle);
|
const reName = safe.patternToRegex(needle);
|
||||||
const extraArgs = safe.getExtraArgs(Array.from(arguments), 1);
|
const extraArgs = safe.getExtraArgs(Array.from(arguments), 1);
|
||||||
const throttle = (fn, ms = 1000) => {
|
const throttle = (fn, ms = 500) => {
|
||||||
if ( throttle.timer !== undefined ) { return; }
|
if ( throttle.timer !== undefined ) { return; }
|
||||||
throttle.timer = setTimeout(( ) => {
|
throttle.timer = setTimeout(( ) => {
|
||||||
throttle.timer = undefined;
|
throttle.timer = undefined;
|
||||||
@ -2746,13 +2746,17 @@ function cookieRemover(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if ( extraArgs.when === 'scroll' ) {
|
removeCookie();
|
||||||
document.addEventListener('scroll', ( ) => {
|
window.addEventListener('beforeunload', removeCookie);
|
||||||
|
if ( typeof extraArgs.when !== 'string' ) { return; }
|
||||||
|
const supportedEventTypes = [ 'scroll', 'keydown' ];
|
||||||
|
const eventTypes = extraArgs.when.split(/\s/);
|
||||||
|
for ( const type of eventTypes ) {
|
||||||
|
if ( supportedEventTypes.includes(type) === false ) { continue; }
|
||||||
|
document.addEventListener(type, ( ) => {
|
||||||
throttle(removeCookie);
|
throttle(removeCookie);
|
||||||
}, { passive: true });
|
}, { passive: true });
|
||||||
}
|
}
|
||||||
removeCookie();
|
|
||||||
window.addEventListener('beforeunload', removeCookie);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user