zboogs at gmail.com
Tue Apr 12 19:22:25 EDT 2005
Another pattern I like, especially for links or other clickable
things, is listening for clicks instead of modifying the links.
It's probably snappier, and I think way easier to read.
I used it in my version of gmailto -
On 4/12/05, Mark Pilgrim <pilgrim at gmail.com> wrote:
> On 4/12/05, Julien Couvreur <julien.couvreur at gmail.com> wrote:
> > Another pattern: url re-writing.
> Right, like changing links to the printer-friendly version, or forcing
> GMail to use https.
> > General thought on the examples in the thread so far. A number of them
> > illustrate how some things can be done in multiple ways.
> > For example, iterating over the a certain kind of element can be done
> > with getElementsByTagName or an xpath query, or even using some more
> > specific DOM APIs in some cases (document.links).
> > As I'm getting more comfortable with XPath, I tend to use it for all
> > selection, where possible. Is there a reason why you think using
> > getElementsByTagName is better?
> It looks simpler, and therefore looks easier to debug (assuming you
> haven't wrapped XPath into a helper function already). I have no idea
> if one way is significantly faster than the other. Other than that,
> no, I have no opinion on which one is "better".
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
More information about the Greasemonkey