Scenario: There's a webapp which uses massive amounts of AJAX and consists of huge piles of minified javascript. You want to fiddle around with its requests. There are some dedicated tools for that, e.g. Fiddler, which often work as proxies that intercept and modify requests. Most of them don't let you script request modification, so you have to be faster than the webapp's timeouts while doing manual changes to requests on-the-fly.

Let a nice JavaScript debugging trick come to the rescue. Ajax normally uses XMLHttpRequests and sends the data with the .send method (if it's not in the URL, in which case you'd need .open instead). So, if we can intercept calls to that method, we have reached our goal. Here's how you can do exactly that (for use in the JS console of your browser):

var _sendreq = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function(arg) { /* ...modify request... */ console.log(arg); _sendreq.call(this, arg); };

Happy testing!

Hint: If you want to change your code, just repeat this, but leave out the first line.