[Greasemonkey] Adding a link for every result in google

Andrew Hayward greasemonkey at mooncalf.me.uk
Wed Jun 8 12:37:34 EDT 2005


Jan Swartling wrote:
> 
> 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"
...
>   // this does not return the correct a - it seems as if it evaluates 
> the whole document

It does indeed evaluate the whole document.

>   var a = document.evaluate("//a", p, null, 
> XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

You need to check the scope of your evaluation...

var a = document.evaluate ( ".//a", p, ... );

>   var font = document.evaluate("//font[@color='#008000']", p, null, 
> XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

I imagine you'll want to do the same with 'font'...

var font = document.evaluate ( ".//font[@color='#008000']", p, ... );

Hope this helps (and I hope it works too, or I'll look a bit stupid!)

- Andrew


More information about the Greasemonkey mailing list