From 11c3a160363034f2673be10f963a2c52cfe80904 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 18 Sep 2024 10:34:18 -0400 Subject: [PATCH] Fix exception thrown in `spoof-css` in Firefox Related feedback: https://github.com/uBlockOrigin/uAssets/issues/25358#issuecomment-2358278979 --- assets/resources/scriptlets.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index dc613c46f5cbf..c5cf6cca87211 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -1524,9 +1524,9 @@ function proxyApplyFn( apply(target, thisArg, args) { return handler(new proxyApplyFn.ApplyContext(target, thisArg, args)); }, - get(target, prop, receiver) { + get(target, prop) { if ( prop === 'toString' ) { return toString; } - return Reflect.get(target, prop, receiver); + return Reflect.get(target, prop); }, }; if ( fn.prototype?.constructor === fn ) { @@ -3109,11 +3109,11 @@ function alertBuster() { apply: function(a) { console.info(a); }, - get(target, prop, receiver) { + get(target, prop) { if ( prop === 'toString' ) { return target.toString.bind(target); } - return Reflect.get(target, prop, receiver); + return Reflect.get(target, prop); }, }); } @@ -3836,7 +3836,7 @@ function spoofCSS( const targetElements = new WeakSet(document.querySelectorAll(selector)); if ( targetElements.has(args[0]) === false ) { return style; } const proxiedStyle = new Proxy(style, { - get(target, prop, receiver) { + get(target, prop) { if ( typeof target[prop] === 'function' ) { if ( prop === 'getPropertyValue' ) { return cloackFunc(function getPropertyValue(prop) { @@ -3848,7 +3848,7 @@ function spoofCSS( if ( instanceProperties.includes(prop) ) { return Reflect.get(target, prop); } - return spoofStyle(prop, Reflect.get(target, prop, receiver)); + return spoofStyle(prop, Reflect.get(target, prop)); }, getOwnPropertyDescriptor(target, prop) { if ( propToValueMap.has(prop) ) { @@ -3864,11 +3864,11 @@ function spoofCSS( }); return proxiedStyle; }, - get(target, prop, receiver) { + get(target, prop) { if ( prop === 'toString' ) { return target.toString.bind(target); } - return Reflect.get(target, prop, receiver); + return Reflect.get(target, prop); }, }); Element.prototype.getBoundingClientRect = new Proxy(Element.prototype.getBoundingClientRect, { @@ -3887,11 +3887,11 @@ function spoofCSS( } return new self.DOMRect(rect.x, rect.y, width, height); }, - get(target, prop, receiver) { + get(target, prop) { if ( prop === 'toString' ) { return target.toString.bind(target); } - return Reflect.get(target, prop, receiver); + return Reflect.get(target, prop); }, }); }