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

Add stackToMatch vararg to json-prune-related scriptlets

As per discussion with filter list maintainers.
This commit is contained in:
Raymond Hill 2023-10-05 11:24:35 -04:00
parent 7416340144
commit 6b211f622c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1257,6 +1257,7 @@ function jsonPruneFetchResponse(
const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, });
const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { });
const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url');
const stackNeedle = safe.initPattern(extraArgs.stackToMatch || '', { canNegate: true });
const applyHandler = function(target, thisArg, args) {
const fetchPromise = Reflect.apply(target, thisArg, args);
if ( logLevel === true ) {
@ -1289,7 +1290,7 @@ function jsonPruneFetchResponse(
objBefore,
rawPrunePaths,
rawNeedlePaths,
{ matchAll: true },
stackNeedle,
extraArgs
);
if ( typeof objAfter !== 'object' ) { return responseBefore; }
@ -1342,6 +1343,7 @@ function jsonPruneXhrResponse(
const logLevel = shouldLog({ log: rawPrunePaths === '' || extraArgs.log, });
const log = logLevel ? ((...args) => { safe.uboLog(...args); }) : (( ) => { });
const propNeedles = parsePropertiesToMatch(extraArgs.propsToMatch, 'url');
const stackNeedle = safe.initPattern(extraArgs.stackToMatch || '', { canNegate: true });
self.XMLHttpRequest = class extends self.XMLHttpRequest {
open(method, url, ...args) {
const xhrDetails = { method, url };
@ -1389,7 +1391,7 @@ function jsonPruneXhrResponse(
objBefore,
rawPrunePaths,
rawNeedlePaths,
{ matchAll: true },
stackNeedle,
extraArgs
);
let outerResponse;