mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
parent
1d8bf95926
commit
200f6b31f3
@ -144,20 +144,18 @@
|
|||||||
const changedToStrings = new WeakMap();
|
const changedToStrings = new WeakMap();
|
||||||
scope.createProxyFunction = function createProxyFunction(window, original, replacement){
|
scope.createProxyFunction = function createProxyFunction(window, original, replacement){
|
||||||
if (!changedToStrings.get(window)){
|
if (!changedToStrings.get(window)){
|
||||||
changedToStrings.set(window, true);
|
|
||||||
const functionPrototype = scope.getWrapped(window).Function.prototype;
|
const functionPrototype = scope.getWrapped(window).Function.prototype;
|
||||||
const toString = functionPrototype.toString;
|
const originalToString = functionPrototype.toString;
|
||||||
|
changedToStrings.set(window, originalToString);
|
||||||
|
const alteredToString = scope.exportFunctionWithName(function toString(){
|
||||||
|
return proxies.get(this) || originalToString.call(this);
|
||||||
|
}, window, "toString");
|
||||||
|
proxies.set(alteredToString, originalToString.call(originalToString));
|
||||||
scope.changeProperty(window, "toString", {
|
scope.changeProperty(window, "toString", {
|
||||||
object: functionPrototype,
|
object: functionPrototype,
|
||||||
name: "toString",
|
name: "toString",
|
||||||
type: "value",
|
type: "value",
|
||||||
changed: scope.createProxyFunction(
|
changed: alteredToString
|
||||||
window,
|
|
||||||
toString,
|
|
||||||
function(){
|
|
||||||
return proxies.get(this) || toString.call(this);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const handler = scope.getWrapped(window).Object.create(null);
|
const handler = scope.getWrapped(window).Object.create(null);
|
||||||
@ -177,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
}, window, "");
|
}, window, "");
|
||||||
const proxy = new window.Proxy(original, handler);
|
const proxy = new window.Proxy(original, handler);
|
||||||
proxies.set(proxy, original.toString());
|
proxies.set(proxy, changedToStrings.get(window).call(original));
|
||||||
return scope.getWrapped(proxy);
|
return scope.getWrapped(proxy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
Version 1.10:
|
Version 1.10:
|
||||||
changes:
|
changes:
|
||||||
- added eBay and facebook.com to the convenience preset
|
- added eBay and facebook.com to the convenience preset
|
||||||
|
- do not use proxy for Function.prototype.toString (causes weird problems sometimes)
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
- added setting showPresetsOnInstallation to be able to not show the presets page upon installation
|
- added setting showPresetsOnInstallation to be able to not show the presets page upon installation
|
||||||
|
@ -181,6 +181,16 @@ addTest("toString modified", function(log){
|
|||||||
configurable: true
|
configurable: true
|
||||||
},
|
},
|
||||||
log
|
log
|
||||||
|
) | checkPropertyDescriptor(
|
||||||
|
Function.prototype,
|
||||||
|
"toString",
|
||||||
|
{
|
||||||
|
value: function toString(){},
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
},
|
||||||
|
log
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
addTest("function name", function(log){
|
addTest("function name", function(log){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user