There are three reasonable ways to do this:
- Use Firebug's underlying code. For monitor() this is rather in flux (completely rewritten between 1.12 and jsd2 branch, as with most of the Script panel) but located in console/functionMonitor.js; for getEventListeners it's in console/commands/getEventListeners.js (slightly less in flux, but somewhat inflexible API). Probably not really recommended for those two functions, but in general it's a powerful method.
- Run code, just like the command line. You can use CommandLine.evaluate for this, see commandLine.js. The advantage is that you get exactly the same result as a user would when calling the function, the disadvantages is that it can be somewhat inflexible, and that the command line API could potentially change in the future (not terrible likely though). E.g. you can extract a command line API method through `var getEventListeners = null; CommandLine.evaluate("getEventListeners", context, null, null, function(res) { getEventListeners = res; })`, or call it in a similar manner.
- Do the same as Firebug. A good idea in case of getEventListeners, because you only care about the functionality, not Firebug's wrapper around it. In this case you can look at Firebug's implementation and copy it. (For getEventListeners the code of interest would be Events.getEventListenersForTarget in lib/events.js.)
Hope that helps,
- Simon