[Greasemonkey] Patterns

Mark Pilgrim pilgrim at gmail.com
Tue Apr 12 21:27:04 EDT 2005

> - Do something for every instance of a specific HTML element
> var elements = document.evaluate("//img", document, null,

On second thought, this would be more easily done with
document.getElementsByTagName("img").  Where XPath shines is for
things like "get me all the links", since the A tag is overloaded to
mean both anchor and link, so you need an XPath like "//a[@href]" (all
A tags that have an HREF attribute).  That would be the better
example, I suspect, since there are lots of fun things to do with


More information about the Greasemonkey mailing list