Greasemonkey: load url using GM_xmlhttpRequest and createContextualFragment
Posted
by Dave
on Stack Overflow
See other posts from Stack Overflow
or by Dave
Published on 2010-02-08T12:03:01Z
Indexed on
2010/04/02
14:03 UTC
Read the original article
Hit count: 376
greasemonkey
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
© Stack Overflow or respective owner