1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-05 18:55:46 +01:00

Simplify last commit.

This commit is contained in:
Kris Maglione
2011-02-01 15:26:56 -05:00
parent b6bdac4b1f
commit 7a6f236e2d

View File

@@ -8,46 +8,33 @@ const OVERLAY_URLS = [
"chrome://mozapps/content/extensions/extensions.xul"
];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function observe(subject, topic, data) {
if (topic in observers)
observers[topic](subject, data);
function observe(window, topic, url) {
if (topic === "chrome-document-global-created")
checkDocument(window.document);
}
function init(disable) {
for (let observer in observers)
Services.obs[disable ? "removeObserver" : "addObserver"](observe, observer, false);
Services.obs[disable ? "removeObserver" : "addObserver"](observe, "chrome-document-global-created", false);
for (let doc in chromeDocuments)
checkDocument(doc, disable);
}
function cleanup() { init(true); }
var observers = {
"chrome-document-global-created": function (window, uri) {
checkDocument(window.document);
}
}
function checkPopup(event) {
try {
let doc = event.originalTarget.ownerDocument;
let binding = doc.getBindingParent(event.originalTarget);
if (binding && binding.addon && binding.addon.guid == ADDON_ID && !binding.addon.compatible) {
let elem = doc.getAnonymousElementByAttribute(binding, "anonid", "stillworks");
if (elem && elem.nextSibling) {
elem.nextSibling.disabled = true;
elem.nextSibling.setAttribute("tooltiptext", "Developer has opted out of incompatibility reports");
}
let doc = event.originalTarget.ownerDocument;
let binding = doc.getBindingParent(event.originalTarget);
if (binding && binding.addon && binding.addon.guid == ADDON_ID && !binding.addon.compatible) {
let elem = doc.getAnonymousElementByAttribute(binding, "anonid", "stillworks");
if (elem && elem.nextSibling) {
elem.nextSibling.disabled = true;
elem.nextSibling.setAttribute("tooltiptext", "Developer has opted out of incompatibility reports");
}
}
catch (e) {
Cu.reportError(e);
}
}
function checkDocument(doc, disable, force) {
@@ -57,13 +44,8 @@ function checkDocument(doc, disable, force) {
}
else {
doc.addEventListener("DOMContentLoaded", function listener() {
try {
doc.removeEventListener("DOMContentLoaded", listener, false);
checkDocument(doc, disable, true);
}
catch (e) {
Cu.reportError(e);
}
doc.removeEventListener("DOMContentLoaded", listener, false);
checkDocument(doc, disable, true);
}, false);
}
}