1 // By Kris Maglione. Public Domain.
2 // Please feel free to copy and use at will.
8 "chrome://mozapps/content/extensions/extensions.xul"
11 const Ci = Components.interfaces;
12 const Cu = Components.utils;
14 Cu.import("resource://gre/modules/Services.jsm");
15 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
17 function observe(window, topic, url) {
18 if (topic === "chrome-document-global-created")
19 checkDocument(window.document);
25 Services.obs[id ? "addObserver" : "removeObserver"](observe, "chrome-document-global-created", false);
26 for (let doc in chromeDocuments)
27 checkDocument(doc, !id);
29 function cleanup() { init(null); }
31 function checkPopup(event) {
32 let doc = event.originalTarget.ownerDocument;
33 let binding = doc.getBindingParent(event.originalTarget);
34 if (binding && binding.addon && binding.addon.guid == ADDON_ID && !binding.addon.compatible) {
35 let elem = doc.getAnonymousElementByAttribute(binding, "anonid", "stillworks");
36 if (elem && elem.nextSibling) {
37 elem.nextSibling.disabled = true;
38 elem.nextSibling.setAttribute("tooltiptext", "Developer has opted out of incompatibility reports\n"+
39 "Development versions are available with updated support");
44 function checkDocument(doc, disable, force) {
45 if (["interactive", "complete"].indexOf(doc.readyState) >= 0 || force && doc.readyState === "uninitialized") {
46 if (OVERLAY_URLS.indexOf(doc.documentURI) >= 0)
47 doc[disable ? "removeEventListener" : "addEventListener"]("popupshowing", checkPopup, false);
50 doc.addEventListener("DOMContentLoaded", function listener() {
51 doc.removeEventListener("DOMContentLoaded", listener, false);
52 checkDocument(doc, disable, true);
57 function chromeDocuments() {
58 let windows = services.windowMediator.getXULWindowEnumerator(null);
59 while (windows.hasMoreElements()) {
60 let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
61 for each (let type in ["typeChrome", "typeContent"]) {
62 let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type],
63 Ci.nsIDocShell.ENUMERATE_FORWARDS);
64 while (docShells.hasMoreElements())
65 yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument;
70 var EXPORTED_SYMBOLS = ["cleanup", "init"];
72 // vim: set fdm=marker sw=4 ts=4 et ft=javascript: