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

Add more output to logger re. scriptlets

This commit is contained in:
Raymond Hill 2024-01-28 10:58:41 -05:00
parent 55879e6014
commit 6cfba082f9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1167,7 +1167,7 @@ function matchObjectProperties(propNeedles, ...objs) {
let value = haystack[prop];
if ( value === undefined ) { continue; }
if ( typeof value !== 'string' ) {
try { value = JSON.stringify(value); }
try { value = safe.JSON_stringify(value); }
catch(ex) { }
if ( typeof value !== 'string' ) { continue; }
}
@ -1665,7 +1665,7 @@ function jsonPrune(
apply: function(target, thisArg, args) {
const objBefore = Reflect.apply(target, thisArg, args);
if ( rawPrunePaths === '' ) {
safe.uboLog(logPrefix, JSON.stringify(objBefore, null, 1));
safe.uboLog(logPrefix, safe.JSON_stringify(objBefore, null, 2));
}
const objAfter = objectPruneFn(
objBefore,
@ -1677,7 +1677,7 @@ function jsonPrune(
if ( objAfter === undefined ) { return objBefore; }
safe.uboLog(logPrefix, 'Pruned');
if ( safe.logLevel > 1 ) {
safe.uboLog(logPrefix, `After pruning:\n${JSON.stringify(objAfter, null, 1)}`);
safe.uboLog(logPrefix, `After pruning:\n${safe.JSON_stringify(objAfter, null, 2)}`);
}
return objAfter;
},
@ -1997,13 +1997,16 @@ function noFetchIf(
const details = args[0] instanceof self.Request
? args[0]
: Object.assign({ url: args[0] }, args[1]);
if ( propsToMatch === '' && responseBody === '' ) {
return safe.uboLog(logPrefix, `Called: ${safe.JSON_stringify(details, null, 2)}`);
}
let proceed = true;
try {
const props = new Map();
for ( const prop in details ) {
let v = details[prop];
if ( typeof v !== 'string' ) {
try { v = JSON.stringify(v); }
try { v = safe.JSON_stringify(v); }
catch(ex) { }
}
if ( typeof v !== 'string' ) { continue; }
@ -2524,6 +2527,9 @@ function noXhrIf(
if ( matchObjectProperties(propNeedles, haystack) ) {
xhrInstances.set(this, haystack);
}
if ( propsToMatch === '' && directive === '' ) {
return safe.uboLog(logPrefix, `Called: ${safe.JSON_stringify(haystack, null, 2)}`);
}
haystack.headers = Object.assign({}, headers);
return super.open(method, url, ...args);
}