Skip to content

Commit

Permalink
Improve spoof-css scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 10, 2024
1 parent a5f6c35 commit 277e90a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,9 @@ function spoofCSS(
const cloackFunc = (fn, thisArg, name) => {
const trap = fn.bind(thisArg);
Object.defineProperty(trap, 'name', { value: name });
Object.defineProperty(trap, 'toString', {
value: ( ) => `function ${name}() { [native code] }`
});
return trap;
};
self.getComputedStyle = new Proxy(self.getComputedStyle, {
Expand All @@ -3619,7 +3622,7 @@ function spoofCSS(
get(target, prop, receiver) {
if ( typeof target[prop] === 'function' ) {
if ( prop === 'getPropertyValue' ) {
return cloackFunc(function(prop) {
return cloackFunc(function getPropertyValue(prop) {
return spoofStyle(prop, target[prop]);
}, target, 'getPropertyValue');
}
Expand Down

0 comments on commit 277e90a

Please sign in to comment.