mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-13 02:14:17 +01:00
Improve spoof-css
scriptlet
This commit is contained in:
parent
a086ae1f19
commit
603239970d
1 changed files with 8 additions and 3 deletions
|
@ -3568,6 +3568,11 @@ function spoofCSS(
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
const cloackFunc = (fn, thisArg, name) => {
|
||||||
|
const trap = fn.bind(thisArg);
|
||||||
|
Object.defineProperty(trap, 'name', { value: name });
|
||||||
|
return trap;
|
||||||
|
};
|
||||||
self.getComputedStyle = new Proxy(self.getComputedStyle, {
|
self.getComputedStyle = new Proxy(self.getComputedStyle, {
|
||||||
apply: function(target, thisArg, args) {
|
apply: function(target, thisArg, args) {
|
||||||
if ( shouldDebug !== 0 ) { debugger; } // jshint ignore: line
|
if ( shouldDebug !== 0 ) { debugger; } // jshint ignore: line
|
||||||
|
@ -3578,11 +3583,11 @@ function spoofCSS(
|
||||||
get(target, prop, receiver) {
|
get(target, prop, receiver) {
|
||||||
if ( typeof target[prop] === 'function' ) {
|
if ( typeof target[prop] === 'function' ) {
|
||||||
if ( prop === 'getPropertyValue' ) {
|
if ( prop === 'getPropertyValue' ) {
|
||||||
return (function(prop) {
|
return cloackFunc(function(prop) {
|
||||||
return spoofStyle(prop, target[prop]);
|
return spoofStyle(prop, target[prop]);
|
||||||
}).bind(target);
|
}, target, 'getPropertyValue');
|
||||||
}
|
}
|
||||||
return target[prop].bind(target);
|
return cloackFunc(target[prop], target, prop);
|
||||||
}
|
}
|
||||||
return spoofStyle(prop, Reflect.get(target, prop, receiver));
|
return spoofStyle(prop, Reflect.get(target, prop, receiver));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue