Answer the question
In order to leave comments, you need to log in
Websocket how to change incoming message?
Hello. I am writing a chrome extension. It is required to be embedded in websocket and modify incoming messages.
There are no problems with listening. You can listen through WebSocket.prototype.onMessage or by adding a listener to the message event:
WebSocket.addEventListener('message'...
The problem is that in both cases the text of the incoming message is readOnly. Are
there any ways to modify the incoming message?
I was thinking about making a local websocket proxy in browser, but as I understand it, in chrome it is impossible to raise
the websocket server?
Answer the question
In order to leave comments, you need to log in
try replacing the method with your own, something like this:
https://stackoverflow.com/questions/40341197/how-t...
WebSocket.prototype.oldSend = WebSocket.prototype.send;
WebSocket.prototype.send = function(data) {
console.log("ws: sending data");
WebSocket.prototype.oldSend.apply(this, [data]);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question