mirror of https://github.com/gorhill/uBlock.git
Replace requestAnimationFrame-if.js with no-requestAnimationFrame-if.js
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/981 To be consistent with no-setTimeout-if.js. requestAnimationFrame-if.js is deprecated and must no longer be used, it will be removed in the near future when it's no longer in use in default filter lists. no-requestAnimationFrame-if.js is aliased to norafif.js.
This commit is contained in:
parent
042935b22a
commit
1de0e820b8
|
@ -491,6 +491,7 @@
|
||||||
|
|
||||||
/// requestAnimationFrame-if.js
|
/// requestAnimationFrame-if.js
|
||||||
/// alias raf-if.js
|
/// alias raf-if.js
|
||||||
|
// Deprecated, use "no-requestAnimationFrame-if.js"
|
||||||
(function() {
|
(function() {
|
||||||
let needle = '{{1}}';
|
let needle = '{{1}}';
|
||||||
const not = needle.charAt(0) === '!';
|
const not = needle.charAt(0) === '!';
|
||||||
|
@ -518,6 +519,38 @@
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
/// no-requestAnimationFrame-if.js
|
||||||
|
/// alias norafif.js
|
||||||
|
(function() {
|
||||||
|
let needle = '{{1}}';
|
||||||
|
if ( needle === '{{1}}' ) { needle = ''; }
|
||||||
|
const needleNot = needle.charAt(0) === '!';
|
||||||
|
if ( needleNot ) { needle = needle.slice(1); }
|
||||||
|
if ( needle.startsWith('/') && needle.endsWith('/') ) {
|
||||||
|
needle = needle.slice(1, -1);
|
||||||
|
} else if ( needle !== '' ) {
|
||||||
|
needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
}
|
||||||
|
const log = needleNot === false && needle === '' ? console.log : undefined;
|
||||||
|
const reNeedle = new RegExp(needle);
|
||||||
|
window.requestAnimationFrame = new Proxy(window.requestAnimationFrame, {
|
||||||
|
apply: function(target, thisArg, args) {
|
||||||
|
const a = String(args[0]);
|
||||||
|
let defuse = false;
|
||||||
|
if ( log !== undefined ) {
|
||||||
|
log('uBO: requestAnimationFrame("%s")', a);
|
||||||
|
} else {
|
||||||
|
defuse = reNeedle.test(a) !== needleNot;
|
||||||
|
}
|
||||||
|
if ( defuse ) {
|
||||||
|
args[0] = function(){};
|
||||||
|
}
|
||||||
|
return target.apply(thisArg, args);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
/// set-constant.js
|
/// set-constant.js
|
||||||
/// alias set.js
|
/// alias set.js
|
||||||
(function() {
|
(function() {
|
||||||
|
|
Loading…
Reference in New Issue