Just like the title says, i'm using an proxy to modify WebSocket but, for some reason the toString function(of the WebSocket proxy) is returning different values even though the proxy's get handler is returning target[p].. here's the code i'm using.
// ==UserScript==
// @name proxy test
// @namespace idk
// @version 0.1
// @description testing proxy.
// @author miniscripter
// @match https://www.google.com
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
console.clear();
console.log(WebSocket.toString());
unsafeWindow.WebSocket = new Proxy(WebSocket, {
get(target, p, receiver) {
console.log(target);
return target[p]; //should return the target's property...
}
});
console.log(unsafeWindow.WebSocket.toString());
As you can see, instead of returning the same toString value, it is returning an different value which seems to be the toString value of the proxy, why is this happening?
The new toString should return the same value as the original seeing that the Proxy retuns the original one..