[Greasemonkey] GM 0.6.4 and new DOMParser()

Aaron Boodman zboogs at gmail.com
Thu Dec 1 09:00:56 EST 2005


On 11/30/05, John Plsek <jplsek at iinet.net.au> wrote:
> OK, I need DOMParser to work ... why is it broken in GM0.6.4?? Is there
> a workaround???

E4X:

var xml = new XML(myXMLString);

You can walk around it just using property access. So if the xml was:
<foo><bar>4</bar><baz>12</baz></foo>, you'd be able to do this:

assertEqual(foo.bar, 4);
assertEqual(foo.baz, 12);

> Where is that definitive list of GM 0.6.x traps from us poor GM
> scripters??? new Image() isn't working, now new DOMParser() ....

Sorry, I should make a webpage. I really wanted to maintain
compatibility, but it was just too complex and error prone to keep
special casing things. The way I am doing it now will be much less
likely to change because we are relying on solid interfaces, not
hacks.

The defiinitive list of traps was linked from the Greaseblog post and
has been linked here a few times:

http://dunck.us/collab/GreaseMonkeyUserScripts?action=show&redirect=GreasemonkeyUserScripts#head-4ac4d1e80f8bbd66bf4f1fbea77ea2390b6a2870

Please update it with the Image, XMLHttpRequest stuff.

We are now basically constrained by whats in XPCNativeWrapper(window),
core JavaScript, and the GM APIs.

What's in XPCNativeWrapper(window) is a result of the IDL interface
that Window implements, which are listed here:

http://xulplanet.com/references/objref/Window.html

You can also access core Mozilla JavaScript, (including E4X) and the
venerable GM APIs.

Here's a list of major things people might try to use that don't exist
or don't work the way you'd expect:

* Image(), Option(), etc. Just use createElement("image");
* DOMParser, DOMSerializer. Use e4x. It's a core JS feature, and it's
simpler anyway - new XML("<foo><baz/></foo>").toXMLString().
* onclick, onmousedown, etc. Use addEventListener
* XMLHttpRequest. Use GM_xmlhttpRequest
* .forms, .images, etc. Just use getElementsByTagName("form") {forms,
images do exist, but you can't index them by name. Just use the DOM
apis}.

> when will it end

It already has! I don't expect this set of APIs to ever shrink, only
expand. Once again, sorry, but it had to be done. There are
workarounds for all the missing pieces.

- a


More information about the Greasemonkey mailing list