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