mirror of https://github.com/gorhill/uBlock.git
Make json-prune scriptlet also trap Response.json() calls
Related discussion: - https://www.reddit.com/r/uBlockOrigin/comments/jns1t4/white_screen_skip_ad_on_youtube/gbg4aq8/
This commit is contained in:
parent
87db640653
commit
13f92756be
|
@ -433,21 +433,28 @@
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
const pruner = function(o) {
|
||||||
|
if ( log !== undefined ) {
|
||||||
|
const json = JSON.stringify(o, null, 2);
|
||||||
|
if ( reLogNeedle.test(json) ) {
|
||||||
|
log('uBO:', location.hostname, json);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
if ( mustProcess(o) === false ) { return o; }
|
||||||
|
for ( const path of prunePaths ) {
|
||||||
|
findOwner(o, path, true);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
};
|
||||||
JSON.parse = new Proxy(JSON.parse, {
|
JSON.parse = new Proxy(JSON.parse, {
|
||||||
apply: function() {
|
apply: function() {
|
||||||
const r = Reflect.apply(...arguments);
|
return pruner(Reflect.apply(...arguments));
|
||||||
if ( log !== undefined ) {
|
},
|
||||||
const json = JSON.stringify(r, null, 2);
|
});
|
||||||
if ( reLogNeedle.test(json) ) {
|
Response.prototype.json = new Proxy(Response.prototype.json, {
|
||||||
log('uBO:', location.hostname, json);
|
apply: function() {
|
||||||
}
|
return Reflect.apply(...arguments).then(o => pruner(o));
|
||||||
return r;
|
|
||||||
}
|
|
||||||
if ( mustProcess(r) === false ) { return r; }
|
|
||||||
for ( const path of prunePaths ) {
|
|
||||||
findOwner(r, path, true);
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue