[Greasemonkey] Adding a link for every result in google
Jan Swartling
jan at swartling.net
Wed Jun 8 13:29:13 EDT 2005
What am I doing wrong here? I'm trying to find all the urls in the google search result and adding a
link to Alexa before the Google links "Cached" and "Similar Pages"
res = document.evaluate("//p[@class='g']", document.body, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var y=0; y<res.snapshotLength; y++) {
var p = res.snapshotItem(y);
// this does not return the correct a - it seems as if it evaluates the whole document
var a = document.evaluate("//a", p, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var font = document.evaluate("//font[@color='#008000']", p, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var nobr = document.createElement('nobr');
nobr.innerHTML = '<a href="http://alexa.com?url=' + a.href + '">Alexa Info</a> - ';
font.parentNode.insertAfter(nobr, font);
}
/ Jan
More information about the Greasemonkey
mailing list