[Greasemonkey] Greasemonkey and GMail

Nikolas Coukouma lists at atrus.org
Fri Aug 19 00:09:59 EDT 2005


Tony Chang wrote:

>On Thu, Aug 18, 2005 at 05:32:30PM -0400, Nikolas Coukouma wrote:
>
>  
>
>>I think mutation events are the real answer. You can add an event
>>listener at every node for subtree mutations, to prevent a script from
>>capturing and calling stopPropogation. At the very top is document and
>>it is const(ant). Otherwise, you could copy the DOM, sans event
>>listeners, from the top-down.
>>    
>>
>
>To my knowledge, DOMSubtreeModified hasn't been added to Firefox and a
>test on Deer Park Alpha 2 seems to confirm that. [1]  I also didn't get an
>alert in your example that said "Something changed!! (mutation)".
>
>On the other hand, DOMNodeInserted and DOMNodeRemoved are valid events,
>but adding the events directly results in events being fired before the
>page finishes rendering and adding it on load is too late. [2]
>
>DOM mutation doesn't seem to be able to detect GM unless the mutations
>occur after page load.
>
>Tony
>
>[1] Actuall, I hope someone proves me wrong and tells me how to use
>DOMSubtreeModified correctly.
>
>[2] http://ponderer.org/tests/dommodified.html
>
Er, I've been testing this with FF 1.0.6, so I'm a bit confused. There's
also a bug report[1] about "DOMSubtreeModified does not bubble up to xbl
handler" filed in 2003. On the other hand, there's another bug[2] about
it not working at all. As Ian points out, the event is a catchall for:

 - DOMNodeInserted
 - DOMNodeRemoved
 - DOMNodeRemovedFromDocument
 - DOMNodeInsertedInDocument
 - DOMAttrModified
 - DOMCharacterDataModified


I've tried this with latest nightly builds from trunk and aviary. It
definitely works in one branch and not the other. I've gone back to 0.1
and moved forward through the releases. The first release that works is
1.0rc1. The oldest nightly build I've found is 10/29/2004 on the 0.11
branch.

So, I've made a new version[3] that works around the bug. I've tested it
in 1.0.6 and deer park alpha 2. The only differences are:
1) Listens for:
- DOMNodeInserted
- DOMNodeRemoved
- DOMAttrModified
- DOMCharacterDataModified
2) Uses setTimeout with a delay of 0 to avoid rendering notifications(?)
in Deer Park. No, I don't understand why it's needed or works.
3) Adds a flag to decide whether or not it's already sent an alert. This
is just to prevent receiving a pile of notifications for one page load;
clicking through all the alerts is annoying.
4) The content check is removed. I've already defeated it.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=149620
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=288392
[3] http://dent.student.umd.edu/~atrus/detect-mod-mutate2.html

-Nikolas


More information about the Greasemonkey mailing list