[Greasemonkey] GM 0.6.4 and new DOMParser()

Aaron Boodman zboogs at gmail.com
Sun Dec 4 16:00:18 EST 2005


Holy crap, I didn't even know that would work. Yet another workaround
for the DOMParser/XMLSerializer issue:

new XPCNativeWrapper(window, "DOMParser").DOMParser

works great. Wish I would have known, I'd've included this with GM 0.6.4.

- a

On 12/2/05, Joe la Poutre <jsixpack at gmail.com> wrote:
> John,
>
> Have a look at Mark Pilgrim's article for O'Reilly:
> http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html
>
> This happens to be hack #12 from his excellent book Greasemonkey Hacks.
>
> Getting to your question, my work around for DOM parser:
>
> // snippet...
> if (typeof(XPCNativeWrapper) == "function") {
>         var dp = new XPCNativeWrapper(window, "DOMParser()");
>         var parser = new dp.DOMParser();
>         var DOM = parser.parseFromString(gReq.responseText, "application/xhtml+xml");
>         process(DOM);
> }
>
> Either window or unsafeWindow work as first argument to
> XPCNativeWrapper, not sure which is best (see my question earlier on
> this list).
>
> HTH,
>
> Joe.
>
> On 12/1/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???
> >
> > Where is that definitive list of GM 0.6.x traps from us poor GM
> > scripters??? new Image() isn't working, now new DOMParser() .... when
> > will it end
> >
> > John
> > _______________________________________________
> > Greasemonkey mailing list
> > Greasemonkey at mozdev.org
> > http://mozdev.org/mailman/listinfo/greasemonkey
> >
>
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>
>
>


More information about the Greasemonkey mailing list