Greasemonkey: load url using GM_xmlhttpRequest and createContextualFragment
- by Dave
I have the following GreaseMonkey Script:
GM_xmlhttpRequest({
method: 'GET',
url: "http://www.testurl.com",
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
},
onload: function(responseDetails) {
var tagString = responseDetails.responseText;
var range = document.createRange();
range.selectNode(document.body);
var documentFragment = range.createContextualFragment(tagString);
How do I now extract stuff from documentFragment? documentFragment.getElementById(''), document.body etc all returns undefined.
I suspect this is due to the createContextualFragment method returning a XPCNativeWrapper object, but how do I work around this to access the underlying DOM?
Thanks