Skip to content
Permalink
Browse files
Replace requestAnimationFrame-if.js with no-requestAnimationFrame-if.js
Related issue:
- uBlockOrigin/uBlock-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.
  • Loading branch information
gorhill authored and JustOff committed Jun 14, 2020
1 parent 58978f4 commit d1d35591c156f608735fcef2a3de22298d31b3e5
Showing with 32 additions and 0 deletions.
  1. +32 −0 assets/resources/resources.txt
@@ -1893,6 +1893,38 @@ requestAnimationFrame-if.js application/javascript
})();


# https://github.com/gorhill/uBlock/commit/1de0e820b87fdd3717b9f2653baaa7a934075055
no-requestAnimationFrame-if.js application/javascript
(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);
}
});
})();


damoh-defuser.js application/javascript
(function() {
var handled = new WeakSet();

0 comments on commit d1d3559

Please sign in to comment.