mirror of https://github.com/gorhill/uBlock.git
Remove pointless code in spoof-css scriptlet
This commit is contained in:
parent
d4fb87b6ba
commit
db7cadae49
|
@ -2243,7 +2243,6 @@ function spoofCSS(
|
||||||
const canDebug = scriptletGlobals.has('canDebug');
|
const canDebug = scriptletGlobals.has('canDebug');
|
||||||
const shouldDebug = canDebug && propToValueMap.get('debug') || 0;
|
const shouldDebug = canDebug && propToValueMap.get('debug') || 0;
|
||||||
const shouldLog = canDebug && propToValueMap.has('log') || 0;
|
const shouldLog = canDebug && propToValueMap.has('log') || 0;
|
||||||
const proxiedStyles = new WeakSet();
|
|
||||||
const spoofStyle = (prop, real) => {
|
const spoofStyle = (prop, real) => {
|
||||||
const normalProp = toCamelCase(prop);
|
const normalProp = toCamelCase(prop);
|
||||||
const shouldSpoof = propToValueMap.has(normalProp);
|
const shouldSpoof = propToValueMap.has(normalProp);
|
||||||
|
@ -2259,7 +2258,6 @@ function spoofCSS(
|
||||||
const style = Reflect.apply(target, thisArg, args);
|
const style = Reflect.apply(target, thisArg, args);
|
||||||
const targetElements = new WeakSet(document.querySelectorAll(selector));
|
const targetElements = new WeakSet(document.querySelectorAll(selector));
|
||||||
if ( targetElements.has(args[0]) === false ) { return style; }
|
if ( targetElements.has(args[0]) === false ) { return style; }
|
||||||
proxiedStyles.add(target);
|
|
||||||
const proxiedStyle = new Proxy(style, {
|
const proxiedStyle = new Proxy(style, {
|
||||||
get(target, prop, receiver) {
|
get(target, prop, receiver) {
|
||||||
if ( typeof target[prop] === 'function' ) {
|
if ( typeof target[prop] === 'function' ) {
|
||||||
|
@ -2277,20 +2275,6 @@ function spoofCSS(
|
||||||
return Reflect.get(target, prop, receiver);
|
return Reflect.get(target, prop, receiver);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
CSSStyleDeclaration.prototype.getPropertyValue = new Proxy(CSSStyleDeclaration.prototype.getPropertyValue, {
|
|
||||||
apply: function(target, thisArg, args) {
|
|
||||||
if ( shouldDebug !== 0 ) { debugger; } // jshint ignore: line
|
|
||||||
const value = Reflect.apply(target, thisArg, args);
|
|
||||||
if ( proxiedStyles.has(thisArg) === false ) { return value; }
|
|
||||||
return spoofStyle(args[0], value);
|
|
||||||
},
|
|
||||||
get(target, prop, receiver) {
|
|
||||||
if ( prop === 'toString' ) {
|
|
||||||
return target.toString.bind(target);
|
|
||||||
}
|
|
||||||
return Reflect.get(target, prop, receiver);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Element.prototype.getBoundingClientRect = new Proxy(Element.prototype.getBoundingClientRect, {
|
Element.prototype.getBoundingClientRect = new Proxy(Element.prototype.getBoundingClientRect, {
|
||||||
apply: function(target, thisArg, args) {
|
apply: function(target, thisArg, args) {
|
||||||
if ( shouldDebug !== 0 ) { debugger; } // jshint ignore: line
|
if ( shouldDebug !== 0 ) { debugger; } // jshint ignore: line
|
||||||
|
|
Loading…
Reference in New Issue