1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 04:49:12 +02:00

Fix no-xhr-if scriptlet for Firefox

Related feedback:
https://github.com/uBlockOrigin/uAssets/issues/20063#issuecomment-1762157408
This commit is contained in:
Raymond Hill 2023-10-13 21:24:21 -04:00
parent fb42411efb
commit 6f74df942d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -63,6 +63,7 @@ function safeSelf() {
'jsonStringify': self.JSON.stringify.bind(self.JSON), 'jsonStringify': self.JSON.stringify.bind(self.JSON),
'log': console.log.bind(console), 'log': console.log.bind(console),
uboLog(...args) { uboLog(...args) {
if ( scriptletGlobals.has('canDebug') === false ) { return; }
if ( args.length === 0 ) { return; } if ( args.length === 0 ) { return; }
if ( `${args[0]}` === '' ) { return; } if ( `${args[0]}` === '' ) { return; }
this.log('[uBO]', ...args); this.log('[uBO]', ...args);
@ -925,7 +926,7 @@ function matchObjectProperties(propNeedles, ...objs) {
} }
const safe = safeSelf(); const safe = safeSelf();
const haystack = {}; const haystack = {};
const props = Array.from(propNeedles.keys()); const props = [ ...propNeedles.keys() ];
for ( const obj of objs ) { for ( const obj of objs ) {
if ( obj instanceof Object === false ) { continue; } if ( obj instanceof Object === false ) { continue; }
matchObjectProperties.extractProperties(obj, haystack, props); matchObjectProperties.extractProperties(obj, haystack, props);
@ -977,7 +978,11 @@ function jsonPruneFetchResponseFn(
if ( propNeedles.size !== 0 ) { if ( propNeedles.size !== 0 ) {
const objs = [ args[0] instanceof Object ? args[0] : { url: args[0] } ]; const objs = [ args[0] instanceof Object ? args[0] : { url: args[0] } ];
if ( extraArgs.version === 2 && objs[0] instanceof Request ) { if ( extraArgs.version === 2 && objs[0] instanceof Request ) {
try { objs[0] = safe.Request_clone.call(objs[0]); } catch(ex) {} try {
objs[0] = safe.Request_clone.call(objs[0]);
} catch(ex) {
safe.uboLog(ex);
}
} }
if ( args[1] instanceof Object ) { if ( args[1] instanceof Object ) {
objs.push(args[1]); objs.push(args[1]);
@ -989,7 +994,7 @@ function jsonPruneFetchResponseFn(
log( log(
`json-prune-fetch-response (${outcome})`, `json-prune-fetch-response (${outcome})`,
`\n\tfetchPropsToMatch: ${JSON.stringify(Array.from(propNeedles)).slice(1,-1)}`, `\n\tfetchPropsToMatch: ${JSON.stringify(Array.from(propNeedles)).slice(1,-1)}`,
'\n\tprops:', ...args, '\n\tprops:', ...objs,
); );
} }
} }