[Greasemonkey] custom element properties

Mark Pilgrim pilgrim at gmail.com
Tue Aug 23 11:34:26 EDT 2005

On 8/23/05, Timothy Babych <tim at innovativemarketing.com.ua> wrote:
> Hello everybody.
> I used to use custom properties of elements in my scripts.
> With inroduction of GM 0.5 this trick does not work anymore in Deer Park
> while working well in FF 1.0.x

Yeah, you can't do that.  In GM 0.5 + Deer Park, many things you think
of as regular objects (HTMLElement, HTMLCollection, HTMLDocument,
etc.) are actually XPCNativeWrappers around the real object.  This is
for security reasons, so that when you call (for example)
document.createElement, you get the *real* createElement method, not
some random method that the current page has redeclared to do
something evil.

Anyway, XPCNativeWrappers have a number of wacky limitations, and this
is one of them: no custom properties.  Refactor your script so you
don't need them.  If you're just tracking one element, keep the custom
property in a global variable (in your user script).  If you're
tracking multiple elements, it's more complicated.

http://diveintogreasemonkey.org/slides/ for more info.


More information about the Greasemonkey mailing list