mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-04 16:47:15 +02:00
Improve spoof-css
scriptlet
This commit is contained in:
parent
a5f6c35bb0
commit
277e90a4a7
@ -3606,6 +3606,9 @@ function spoofCSS(
|
|||||||
const cloackFunc = (fn, thisArg, name) => {
|
const cloackFunc = (fn, thisArg, name) => {
|
||||||
const trap = fn.bind(thisArg);
|
const trap = fn.bind(thisArg);
|
||||||
Object.defineProperty(trap, 'name', { value: name });
|
Object.defineProperty(trap, 'name', { value: name });
|
||||||
|
Object.defineProperty(trap, 'toString', {
|
||||||
|
value: ( ) => `function ${name}() { [native code] }`
|
||||||
|
});
|
||||||
return trap;
|
return trap;
|
||||||
};
|
};
|
||||||
self.getComputedStyle = new Proxy(self.getComputedStyle, {
|
self.getComputedStyle = new Proxy(self.getComputedStyle, {
|
||||||
@ -3619,7 +3622,7 @@ 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 cloackFunc(function(prop) {
|
return cloackFunc(function getPropertyValue(prop) {
|
||||||
return spoofStyle(prop, target[prop]);
|
return spoofStyle(prop, target[prop]);
|
||||||
}, target, 'getPropertyValue');
|
}, target, 'getPropertyValue');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user