From 6f74df942dde9b5f7e90d707cc2311dcb602f459 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 13 Oct 2023 21:24:21 -0400 Subject: [PATCH] Fix `no-xhr-if` scriptlet for Firefox Related feedback: https://github.com/uBlockOrigin/uAssets/issues/20063#issuecomment-1762157408 --- assets/resources/scriptlets.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 10d108aef..76d8c6276 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -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); @@ -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); @@ -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]); @@ -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, ); } }