I am trying to modify websocket messages being sent out by a by a site. I want to accomplish by modifying the window.WebSocket object. When I run this code in the browser and check the network tab, no messages are being sent out.
const originalWS = window.WebSocket.prototype.send
window.WebSocket.prototype.send = function (x) {
console.log(x)
return originalWS(x)
}
However this works.
const originalWS = window.WebSocket.prototype.send
window.WebSocket.prototype.send = originalWS
Why is this?