Created
June 21, 2011 11:15
-
-
Save broquaint/1037642 to your computer and use it in GitHub Desktop.
Working example of GM_xmlhttpRequest speaking XML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name gde33 XML example | |
// @namespace https://github.com/broquaint | |
// @description Working example of GM_xmlhttpRequest speaking XML | |
// @include http://en.wikipedia.org/wiki/Main_Page | |
// ==/UserScript== | |
// For some reason console.log wasn't working, too lazy to investigate why. | |
unsafeWindow.console.log("Requesting stuff!"); | |
GM_xmlhttpRequest({ | |
method: 'GET', | |
url: 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&revids=375536&rvdiffto=prev&format=xml', | |
onload: function(response) { | |
var xml = new DOMParser() | |
.parseFromString(response.responseText, "text/xml"); | |
unsafeWindow.console.log("The response was: ", xml); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment