mirror of https://github.com/gorhill/uBlock.git
Fallback to requestAnimationFrame when requestIdleCallback is not available
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3237
This commit is contained in:
parent
7f0b2f4a5e
commit
59ffc96e89
|
@ -155,6 +155,12 @@ function safeSelf() {
|
||||||
}, []);
|
}, []);
|
||||||
return this.Object_fromEntries(entries);
|
return this.Object_fromEntries(entries);
|
||||||
},
|
},
|
||||||
|
onIdle(fn, options) {
|
||||||
|
if ( self.requestIdleCallback ) {
|
||||||
|
return self.requestIdleCallback(fn, options);
|
||||||
|
}
|
||||||
|
return self.requestAnimationFrame(fn);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
scriptletGlobals.safeSelf = safe;
|
scriptletGlobals.safeSelf = safe;
|
||||||
if ( scriptletGlobals.bcSecret === undefined ) { return safe; }
|
if ( scriptletGlobals.bcSecret === undefined ) { return safe; }
|
||||||
|
@ -2232,7 +2238,7 @@ function removeAttr(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( skip ) { return; }
|
if ( skip ) { return; }
|
||||||
timer = self.requestIdleCallback(rmattr, { timeout: 67 });
|
timer = safe.onIdle(rmattr, { timeout: 67 });
|
||||||
};
|
};
|
||||||
const start = ( ) => {
|
const start = ( ) => {
|
||||||
rmattr();
|
rmattr();
|
||||||
|
@ -2310,7 +2316,7 @@ function removeClass(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( skip ) { return; }
|
if ( skip ) { return; }
|
||||||
timer = self.requestIdleCallback(rmclass, { timeout: 67 });
|
timer = safe.onIdle(rmclass, { timeout: 67 });
|
||||||
};
|
};
|
||||||
const observer = new MutationObserver(mutationHandler);
|
const observer = new MutationObserver(mutationHandler);
|
||||||
const start = ( ) => {
|
const start = ( ) => {
|
||||||
|
@ -3523,7 +3529,7 @@ function hrefSanitizer(
|
||||||
if ( shouldSanitize ) { break; }
|
if ( shouldSanitize ) { break; }
|
||||||
}
|
}
|
||||||
if ( shouldSanitize === false ) { return; }
|
if ( shouldSanitize === false ) { return; }
|
||||||
timer = self.requestIdleCallback(( ) => {
|
timer = safe.onIdle(( ) => {
|
||||||
timer = undefined;
|
timer = undefined;
|
||||||
sanitize();
|
sanitize();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue