diff --git a/webext/js/folderChange.js b/webext/js/folderChange.js index 43bfbc0..370163a 100644 --- a/webext/js/folderChange.js +++ b/webext/js/folderChange.js @@ -56,15 +56,15 @@ var folderChange = class extends ExtensionCommon.ExtensionAPI { return { // Again, this key must have the same name. folderChange: { - setVersion: function (version) { + setVersion: async function (version) { SysTrayX.setVersion(version); }, - setCountType: function (type) { + setCountType: async function (type) { SysTrayX.setCountType(type); }, - setFilters: function (filters) { + setFilters: async function (filters) { SysTrayX.setFilters(filters); }, diff --git a/webext/js/windowEvent.js b/webext/js/windowEvent.js index 681ab6d..d84f811 100644 --- a/webext/js/windowEvent.js +++ b/webext/js/windowEvent.js @@ -1,36 +1,4 @@ -/* eslint-disable object-shorthand */ - -// Get various parts of the WebExtension framework that we need. -var { ExtensionCommon } = ChromeUtils.import( - "resource://gre/modules/ExtensionCommon.jsm" -); - -// You probably already know what this does. -var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); - -// ChromeUtils.import() works in experiments for core resource urls as it did -// in legacy add-ons. However, chrome:// urls that point to add-on resources no -// longer work, as the "chrome.manifest" file is no longer supported, which -// defined the root path for each add-on. Instead, ChromeUtils.import() needs -// a url generated by -// -// let url = context.extension.rootURI.resolve("path/to/file.jsm") -// -// Instead of taking the extension object from the context, you may generate -// the extension object from a given add-on ID as shown in the example below. -// This allows to import a JSM without context, for example inside another JSM. -// -var { ExtensionParent } = ChromeUtils.import( - "resource://gre/modules/ExtensionParent.jsm" -); -var extension = ExtensionParent.GlobalManager.getExtension( - "systray-x@Ximi1970" -); -var { windowEvent } = ChromeUtils.import( - extension.rootURI.resolve("modules/windowEvent.jsm") -); - -// This is the important part. It implements the functions and events defined in schema.json. +/// This is the important part. It implements the functions and events defined in schema.json. // The variable must have the same name you've been using so far, "myapi" in this case. var windowEvent = class extends ExtensionCommon.ExtensionAPI { getAPI(context) { @@ -43,7 +11,7 @@ var windowEvent = class extends ExtensionCommon.ExtensionAPI { return { // Again, this key must have the same name. windowEvent: { - setCloseType: function (type) { + setCloseType: async function (type) { windowListener.setCloseType(type); }, @@ -136,7 +104,6 @@ var windowListener = new (class extends ExtensionCommon.EventEmitter { windowListener.onCloseButton, true ); - windowListener.hijackTitlebarCloseButton(window); } }, }); @@ -171,58 +138,4 @@ var windowListener = new (class extends ExtensionCommon.EventEmitter { if (event) event.preventDefault(); return true; } - - hijackTitlebarCloseButton(window) { - if ( - windowListener.replaceCommand(window, "titlebar-close", function () { - return windowListener.onCloseButton(null); - }) - ) { - console.log("replaced command= " + "titlebar-close"); - } - } - - replaceCommand(window, eltId, gotHidden) { - let elt = window.document.getElementById(eltId); - if (!elt) { - console.log("Element '" + eltId + "' not found. Command not replaced."); - return false; - } - - let prevent = null; - if (elt.command) { - prevent = { - event: "click", - func: function (e) { - e.preventDefault(); - }, - }; - } else if (elt.getAttribute("oncommand")) { - prevent = { - event: "command", - func: function (e) { - e.stopPropagation(); - }, - }; - } else { - console.warn("Could not replace oncommand on " + eltId); - return false; - } - - let callback = function (event) { - if (event.target.id === eltId) { - console.debug(prevent.event + " on " + eltId); - if (gotHidden()) prevent.func(event); - } - }; - - /* We put listeners on the "titlebar" parent node, because: - - we can hardly short-circuit command/oncommand (probably because they are - registered first) - - we'd have otherwise to alter "oncommand"/"command" attribute and use - Function(), which do not pass review nowadays. */ - elt.parentNode.addEventListener(prevent.event, callback, true); - - return true; - } })(); diff --git a/webext/schema_folderchange.json b/webext/schema_folderchange.json index 449fb6d..046041c 100644 --- a/webext/schema_folderchange.json +++ b/webext/schema_folderchange.json @@ -6,6 +6,7 @@ "name": "setVersion", "type": "function", "description": "Set the TB version.", + "async": true, "parameters": [ { "type": "integer", @@ -19,6 +20,7 @@ "name": "setCountType", "type": "function", "description": "Set the count type.", + "async": true, "parameters": [ { "type": "integer", @@ -32,6 +34,7 @@ "name": "setFilters", "type": "function", "description": "Set the account filters.", + "async": true, "parameters": [ { "name": "filters", diff --git a/webext/schema_windowEvent.json b/webext/schema_windowEvent.json index 668f549..a8a4c47 100644 --- a/webext/schema_windowEvent.json +++ b/webext/schema_windowEvent.json @@ -6,6 +6,7 @@ "name": "setCloseType", "type": "function", "description": "Set the close type.", + "async": true, "parameters": [ { "type": "integer",