2 Apr 2008 16:48
Finding events on a page added using addEventListener
Jon <jon <at> isbell.net>
2008-04-02 14:48:39 GMT
2008-04-02 14:48:39 GMT
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
(Continue reading)
RSS Feed