mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-10 08:45:45 +01:00
Simplify last commit.
This commit is contained in:
@@ -8,46 +8,33 @@ const OVERLAY_URLS = [
|
|||||||
"chrome://mozapps/content/extensions/extensions.xul"
|
"chrome://mozapps/content/extensions/extensions.xul"
|
||||||
];
|
];
|
||||||
|
|
||||||
const Cc = Components.classes;
|
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cr = Components.results;
|
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
function observe(subject, topic, data) {
|
function observe(window, topic, url) {
|
||||||
if (topic in observers)
|
if (topic === "chrome-document-global-created")
|
||||||
observers[topic](subject, data);
|
checkDocument(window.document);
|
||||||
}
|
}
|
||||||
function init(disable) {
|
function init(disable) {
|
||||||
for (let observer in observers)
|
Services.obs[disable ? "removeObserver" : "addObserver"](observe, "chrome-document-global-created", false);
|
||||||
Services.obs[disable ? "removeObserver" : "addObserver"](observe, observer, false);
|
|
||||||
for (let doc in chromeDocuments)
|
for (let doc in chromeDocuments)
|
||||||
checkDocument(doc, disable);
|
checkDocument(doc, disable);
|
||||||
}
|
}
|
||||||
function cleanup() { init(true); }
|
function cleanup() { init(true); }
|
||||||
var observers = {
|
|
||||||
"chrome-document-global-created": function (window, uri) {
|
|
||||||
checkDocument(window.document);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkPopup(event) {
|
function checkPopup(event) {
|
||||||
try {
|
let doc = event.originalTarget.ownerDocument;
|
||||||
let doc = event.originalTarget.ownerDocument;
|
let binding = doc.getBindingParent(event.originalTarget);
|
||||||
let binding = doc.getBindingParent(event.originalTarget);
|
if (binding && binding.addon && binding.addon.guid == ADDON_ID && !binding.addon.compatible) {
|
||||||
if (binding && binding.addon && binding.addon.guid == ADDON_ID && !binding.addon.compatible) {
|
let elem = doc.getAnonymousElementByAttribute(binding, "anonid", "stillworks");
|
||||||
let elem = doc.getAnonymousElementByAttribute(binding, "anonid", "stillworks");
|
if (elem && elem.nextSibling) {
|
||||||
if (elem && elem.nextSibling) {
|
elem.nextSibling.disabled = true;
|
||||||
elem.nextSibling.disabled = true;
|
elem.nextSibling.setAttribute("tooltiptext", "Developer has opted out of incompatibility reports");
|
||||||
elem.nextSibling.setAttribute("tooltiptext", "Developer has opted out of incompatibility reports");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
|
||||||
Cu.reportError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkDocument(doc, disable, force) {
|
function checkDocument(doc, disable, force) {
|
||||||
@@ -57,13 +44,8 @@ function checkDocument(doc, disable, force) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
doc.addEventListener("DOMContentLoaded", function listener() {
|
doc.addEventListener("DOMContentLoaded", function listener() {
|
||||||
try {
|
doc.removeEventListener("DOMContentLoaded", listener, false);
|
||||||
doc.removeEventListener("DOMContentLoaded", listener, false);
|
checkDocument(doc, disable, true);
|
||||||
checkDocument(doc, disable, true);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
Cu.reportError(e);
|
|
||||||
}
|
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user