Skip to content

Instantly share code, notes, and snippets.

@javajosh
Created January 8, 2011 05:50
Show Gist options
  • Save javajosh/770588 to your computer and use it in GitHub Desktop.
Save javajosh/770588 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name capiche
// @namespace http://capiche.org/greasemonkey
// @description Developer tool for RESTful APIs
// @author Josh
// @homepage http://capiche.org
// @include http://localhost:8080/*
// ==/UserScript==
var p = unsafeWindow.XMLHttpRequest.prototype;
var log = unsafeWindow.console.log;
if (typeof p.oldsend != 'function') {
p.oldsend = p.send;
p.send = function() {
p.oldsend.apply(this, arguments);
this.addEventListener('readystatechange', function() {
if (this.readyState == 2) {/* LOADED */
log('xhr loaded');
} else if (this.readyState == 4) { /* COMPLETED */
log('xhr completed');
}
}, false);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment