Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ************************************************************************** //
- // XPCOM
- var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
- // https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm
- Cu.import("resource://gre/modules/Services.jsm");
- function install(data, reason) {
- }
- function startup(data, reason) {
- let windows = Services.wm.getEnumerator("navigator:browser");
- while (windows.hasMoreElements()) {
- let aWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
- aWindow.addEventListener("click", clicker, true);
- }
- Services.wm.addListener(windowListener);
- }
- function shutdown(data, reason) {
- let windows = Services.wm.getEnumerator("navigator:browser");
- while (windows.hasMoreElements()) {
- let aWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
- aWindow.removeEventListener("click", clicker, true);
- }
- }
- function uninstall(data, reason) {
- }
- var clicker = function(e) {
- let aWindow = Services.wm.getMostRecentWindow("navigator:browser");
- Services.console.logStringMessage("hello_instanceof [target]: " + e.target);
- Services.console.logStringMessage("hello_instanceof [match with]: " + aWindow.HTMLElement);
- Services.console.logStringMessage("hello_instanceof [result window]: " + (e.target instanceof aWindow.HTMLElement) );
- Services.console.logStringMessage("hello_instanceof [result nsIDOM]: " + (e.target instanceof Components.interfaces.nsIDOMHTMLElement) );
- };
- var windowListener = {
- onOpenWindow: function(aWindow) {
- // Wait for the window to finish loading
- let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
- domWindow.addEventListener("load", function() {
- domWindow.removeEventListener("load", arguments.callee, false);
- domWindow.addEventListener("click", clicker, true);
- }, false);
- },
- onCloseWindow: function(aWindow) {},
- onWindowTitleChange: function(aWindow, aTitle) {}
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement