Skip to content

Commit

Permalink
Fix no-xhr-if scriptlet for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 14, 2023
1 parent fb42411 commit 6f74df9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function safeSelf() {
'jsonStringify': self.JSON.stringify.bind(self.JSON),
'log': console.log.bind(console),
uboLog(...args) {
if ( scriptletGlobals.has('canDebug') === false ) { return; }
if ( args.length === 0 ) { return; }
if ( `${args[0]}` === '' ) { return; }
this.log('[uBO]', ...args);
Expand Down Expand Up @@ -925,7 +926,7 @@ function matchObjectProperties(propNeedles, ...objs) {
}
const safe = safeSelf();
const haystack = {};
const props = Array.from(propNeedles.keys());
const props = [ ...propNeedles.keys() ];
for ( const obj of objs ) {
if ( obj instanceof Object === false ) { continue; }
matchObjectProperties.extractProperties(obj, haystack, props);
Expand Down Expand Up @@ -977,7 +978,11 @@ function jsonPruneFetchResponseFn(
if ( propNeedles.size !== 0 ) {
const objs = [ args[0] instanceof Object ? args[0] : { url: args[0] } ];
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 ) {
objs.push(args[1]);
Expand All @@ -989,7 +994,7 @@ function jsonPruneFetchResponseFn(
log(
`json-prune-fetch-response (${outcome})`,
`\n\tfetchPropsToMatch: ${JSON.stringify(Array.from(propNeedles)).slice(1,-1)}`,
'\n\tprops:', ...args,
'\n\tprops:', ...objs,
);
}
}
Expand Down

0 comments on commit 6f74df9

Please sign in to comment.