Skip to content

Instantly share code, notes, and snippets.

@netroy
Created June 17, 2014 01:18
Show Gist options
  • Save netroy/d21347ead2e44078840d to your computer and use it in GitHub Desktop.
Save netroy/d21347ead2e44078840d to your computer and use it in GitHub Desktop.
Incercepting XHR & WebSockets
var proto = WebSocket.prototype;
var send = proto.send;
Object.defineProperty(proto, 'send', {
'writable': false,
'value': function (data) {
console.log(data);
return send.apply(this, arguments);
}
});
var proto = XMLHttpRequest.prototype;
var open = proto.open;
Object.defineProperty(proto, 'open', {
'writable': false,
'value': function (method, url) {
console.log(url);
return open.apply(this, arguments);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment