There is a page (game), which communicate via WebSocket to the server. I can see the data (frames) in the Chrome Developer Tool. Is it possible to access / modify this communica
I came across this question and tried solutions above, unfortunately the scripts in my target site still found WebSocket has been tampered and broke, which is bad.
So I come up with my own solution:
var ws = window.WebSocket;
window.WebSocket = function(a,b){
var ret = new ws(a,b);
let handle = setInterval(function(){
if(ret.onmessage){
clearInterval(handle);
let o = ret.onmessage;
ret.onmessage = function(m){
//do what your want to m
o(m);
};
}
},50);
return ret;
}
If the site you want to inspect does use WebSocket, I will definitely assign to onmessage
sometime after creating WebSocket object, just check it periodically and reassign it with your own function.