Skip to content

Instantly share code, notes, and snippets.

@ajhsu
Forked from maskit/gist:2252422
Created May 31, 2018 09:28
Show Gist options
  • Save ajhsu/a40c610f4c1e508ecf288fd73af1443e to your computer and use it in GitHub Desktop.
Save ajhsu/a40c610f4c1e508ecf288fd73af1443e to your computer and use it in GitHub Desktop.
WebSocket traffic sniffer
(function() {
WebSocket.prototype.realSendFunc = WebSocket.prototype.send;
WebSocket.prototype.send = function(data) {
this.realSendFunc(data);
this.addEventListener('message', function(msg) {
console.log('>> ' + msg.data);
}, false);
this.send = function(data) {
this.realSendFunc(data);
console.log("<< " + data);
};
console.log("<< " + data);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment