[Greasemonkey] Greasemonkey and GMail

Nikolas Coukouma lists at atrus.org
Thu Aug 18 18:32:30 EDT 2005


Mark Pilgrim wrote:

>On 8/18/05, dmccunney <dennis.mccunney at gmail.com> wrote:
>  
>
>>I don't offhand
>>see a way the remote server would know it was being altered after
>>receipt but before display.
>>    
>>
>
>I must not be making myself clear.
>
>http://diveintogreasemonkey.org/experiments/detect-page-modification.html
>
>Run it with Greasemonkey disabled or uninstalled, and it will display
>"No modifications detected."  Run it with Greasemonkey enabled and a
>linkify script installed (thus changing the unlinked hyperlink), and
>it will display "Modification detected!" and display the initial and
>final CRCs.
>
>The page script can then use XMLHttpRequest or any number of other
>methods (insert an <img> with special query parameters, load a URL in
>a hidden <iframe>, etc.) to report this modification to the server.
>
>  
>
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.

Demo:
  http://dent.student.umd.edu/~atrus/detect-mod-mutate.html
It includes both my mutation approach and a variation on Mark's,* along
with some notes in the comments.

* I pulled out the CRC function and just saved the string. I also used
an anonymous function wrapper.

Further thoughts?
-Nikolas


More information about the Greasemonkey mailing list