1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Improve compatibility with AdGuard's scriptlets

Related:
https://testcases.agrd.dev/Filters/scriptlet-rules/test-scriptlet-rules.html
This commit is contained in:
Raymond Hill 2023-07-11 18:25:21 -04:00
parent 41f1ca7d0d
commit ec06981965
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 10 additions and 6 deletions

View File

@ -1595,6 +1595,7 @@ builtinScriptlets.push({
aliases: [
'nosiif.js',
'prevent-setInterval.js',
'setInterval-defuser.js',
],
fn: noSetIntervalIf,
dependencies: [
@ -1619,7 +1620,7 @@ function noSetIntervalIf(
? console.log
: undefined;
const reNeedle = patternToRegex(needle);
window.setInterval = new Proxy(window.setInterval, {
self.setInterval = new Proxy(self.setInterval, {
apply: function(target, thisArg, args) {
const a = String(args[0]);
const b = args[1];
@ -1637,7 +1638,7 @@ function noSetIntervalIf(
args[0] = function(){};
}
}
return target.apply(thisArg, args);
return Reflect.apply(target, thisArg, args);
},
get(target, prop, receiver) {
if ( prop === 'toString' ) {
@ -1680,7 +1681,7 @@ function noSetTimeoutIf(
? console.log
: undefined;
const reNeedle = patternToRegex(needle);
window.setTimeout = new Proxy(window.setTimeout, {
self.setTimeout = new Proxy(self.setTimeout, {
apply: function(target, thisArg, args) {
const a = String(args[0]);
const b = args[1];
@ -1698,7 +1699,7 @@ function noSetTimeoutIf(
args[0] = function(){};
}
}
return target.apply(thisArg, args);
return Reflect.apply(target, thisArg, args);
},
get(target, prop, receiver) {
if ( prop === 'toString' ) {
@ -2226,6 +2227,9 @@ function disableNewtabLinks() {
builtinScriptlets.push({
name: 'cookie-remover.js',
aliases: [
'remove-cookie.js',
],
fn: cookieRemover,
world: 'ISOLATED',
dependencies: [

View File

@ -174,7 +174,7 @@ export default new Map([
alias: 'widgets.outbrain.com/outbrain.js',
} ],
[ 'popads.js', {
alias: 'popads.net.js',
alias: [ 'popads.net.js', 'prevent-popads-net.js' ],
data: 'text',
} ],
[ 'popads-dummy.js', {

View File

@ -30,7 +30,7 @@
return oe(msg, src, line, col, error);
}
}.bind();
const throwMagic = function() { throw magic; };
const throwMagic = function() { throw new ReferenceError(magic); };
delete window.PopAds;
delete window.popns;
Object.defineProperties(window, {