mirror of https://github.com/gorhill/uBlock.git
Improve `noeval-if` scriptlet
Related feedback: https://github.com/uBlockOrigin/uBlock-discussions/discussions/841#discussioncomment-9320245
This commit is contained in:
parent
a351852268
commit
4d8ee35ef7
|
@ -2015,12 +2015,19 @@ function noEvalIf(
|
||||||
) {
|
) {
|
||||||
if ( typeof needle !== 'string' ) { return; }
|
if ( typeof needle !== 'string' ) { return; }
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
|
const logPrefix = safe.makeLogPrefix('noeval-if', needle);
|
||||||
const reNeedle = safe.patternToRegex(needle);
|
const reNeedle = safe.patternToRegex(needle);
|
||||||
window.eval = new Proxy(window.eval, { // jshint ignore: line
|
window.eval = new Proxy(window.eval, { // jshint ignore: line
|
||||||
apply: function(target, thisArg, args) {
|
apply: function(target, thisArg, args) {
|
||||||
const a = args[0];
|
const a = String(args[0]);
|
||||||
if ( reNeedle.test(a.toString()) ) { return; }
|
if ( needle !== '' && reNeedle.test(a) ) {
|
||||||
return target.apply(thisArg, args);
|
safe.uboLog(logPrefix, 'Prevented:\n', a);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( needle === '' || safe.logLevel > 1 ) {
|
||||||
|
safe.uboLog(logPrefix, 'Not prevented:\n', a);
|
||||||
|
}
|
||||||
|
return Reflect.apply(target, thisArg, args);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue