I'm trying to retrieve a page with greasemonkey and then extract a link from it, inserting the link into the current page. I'm having some trouble with:
GM_xmlhttpRequest({
method: "GET",
url: "http://www.test.net/search.php?file=test",
onload: function(data)
{
if (!data.responseXML)
{
data.responseXML = new DOMParser().parseFromString(data.responseText, "text/xml");
}
alert("!");
var xmldata = data.response.xml;
var tests = xmldata.getElementsByTagName('test');
alert(tests[0].innerHTML);
}
});
The page is valid, and GM_xmlhttpRequest returned it correctly as a string when I tried previously, but I can't seem to figure out how to make it so I can use node operations on it.Thanks in advance.
Edit - a second, related question
How should I refer to the current page so that I could pass it a to function, just as I would pass my fetched page? Ex
function FindTests(currentpage)
{
currentpage.getElementById('blah');
}
where initially I pass it document, but later I use the fetched page. Sorry if the wording is confusing.