Finding events on a page added using addEventListener
Jon <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <45eba92d-2854-4d1f-96c8-87803e0c3d8c@e10g2000prf.googlegroups.com> |
Hi,
I'm building a Javascript crawler using XULRunner as part of a
University project. Its easy to pull out all the element.on* events by
traversing the dom tree, however I'm having difficulties with the
addEventListener events. I can't find any interfaces that expose these
events, so I'm guessing the best way forward is to overwrite the
addEventListener function and redirect the arguments to an array
something like this:
Node.prototype.addEventListenerOld = Node.prototype.addEventListener;
Node.prototype.addEventListener = function(type, func, capture) {
events.push({this, type, func, capture});
return this.addEventListenerOld(type, func, capture);
}
This doesn't work however I can overide a single elements
eventlistener like so:
var z = browser.contentDocument.wrappedJSObject.getElementById("z");
z.addEventListenerOld = z.addEventListener;
z.addEventListener = function(type, func, capture) {
events.push({this, type, func, capture});
return z.addEventListenerOld(type, func, capture);
}
browser points to an <xul:browser>.
So my question is what would I need to overide to get this working for
all objects in my <xul:browser> element? Alternatively is there a
better method an interface I've missed. I'm open to any solutions this
is just a demo, so it doesn't matter if its insecure.
Sorry if this is the wrong group to post this, if it isn't it would be
great if you could point me in the right direction. ;)
Thanks,
Jon