summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Parri <simonparri@ganzeria.com>2025-03-19 00:00:30 -0500
committerSimon Parri <simonparri@ganzeria.com>2025-08-13 10:38:07 -0500
commitde25e333e17f05140b82793776dbce51fdec296d (patch)
tree855b403b873e271308c59aaa455d73982552b9ea
parent312a791ae03bddd725dee063344801f959cfe44d (diff)
downloadlegacywolf-de25e333e17f05140b82793776dbce51fdec296d.tar.gz
legacywolf-de25e333e17f05140b82793776dbce51fdec296d.zip
Turn into an extension
-rw-r--r--.gitignore2
-rw-r--r--Makefile28
-rw-r--r--config.js16
-rw-r--r--defaults/pref/config-prefs.js3
-rw-r--r--legacy.base.js28
-rw-r--r--legacy.json10
-rw-r--r--legacy.manifest1
-rw-r--r--legacy/BootstrapLoader.sys.mjs19
-rw-r--r--legacy/RDFDataSource.sys.mjs6
-rw-r--r--legacy/RDFManifestConverter.sys.mjs6
-rw-r--r--manifest.json23
-rw-r--r--register.js2
12 files changed, 91 insertions, 53 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0e23131
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+legacy.js
+legacywolf.xpi
diff --git a/Makefile b/Makefile
index 9824f6c..fe19dba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,26 +1,20 @@
-.PHONY: all clean install uninstall diff
+.PHONY: all clean diff
-files := config.js
-files += defaults/pref/config-prefs.js
-files += legacy.manifest
-files += legacy/BootstrapLoader.sys.mjs
-files += legacy/RDFDataSource.sys.mjs
-files += legacy/RDFManifestConverter.sys.mjs
-archive = legacyfox.tar.gz
-DESTDIR ?= $(wildcard /usr/lib??/firefox/)
+files := manifest.json
+files += legacy.json
+files += legacy.js
+files += register.js
+archive = legacywolf.xpi
all: $(archive)
$(archive): $(files)
- tar czf $@ -- $(files)
+ zip $@ $(files)
-clean:
- rm -f $(archive)
-
-install: $(archive)
- tar xzf $(archive) -C "$(DESTDIR)"
+legacy.js: legacy/RDFDataSource.sys.mjs legacy/RDFManifestConverter.sys.mjs legacy/BootstrapLoader.sys.mjs legacy.base.js
+ cat $^ >$@
-uninstall:
- cd "$(DESTDIR)" && rm -rf -- $(files)
+clean:
+ rm -f $(archive) legacy.js
diff:
@curl -s https://hg.mozilla.org/comm-central/raw-file/8a37a90aab4ec643fce1e1ab33984613ce0b492d/common/src/BootstrapLoader.jsm | diff --color -u - legacy/BootstrapLoader.sys.mjs ||:
diff --git a/config.js b/config.js
deleted file mode 100644
index 07662f7..0000000
--- a/config.js
+++ /dev/null
@@ -1,16 +0,0 @@
-// keep this comment
-try {
- let {XPIDatabase} = ChromeUtils.importESModule('resource://gre/modules/addons/XPIDatabase.sys.mjs');
- XPIDatabase.isDisabledLegacy = (addon) => false;
- XPIDatabase.mustSign = (aType) => false;
-
- let manifest = Services.dirsvc.get('GreD', Ci.nsIFile);
- manifest.append('legacy.manifest');
- Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
-
- const {AddonManager} = ChromeUtils.importESModule('resource://gre/modules/AddonManager.sys.mjs');
- const {BootstrapLoader} = ChromeUtils.importESModule('resource://legacy/BootstrapLoader.sys.mjs');
- AddonManager.addExternalExtensionLoader(BootstrapLoader);
-} catch(ex) {
- Components.utils.reportError(ex.message);
-}
diff --git a/defaults/pref/config-prefs.js b/defaults/pref/config-prefs.js
deleted file mode 100644
index 57e8af3..0000000
--- a/defaults/pref/config-prefs.js
+++ /dev/null
@@ -1,3 +0,0 @@
-pref("general.config.obscure_value", 0);
-pref("general.config.filename", "config.js");
-pref("general.config.sandbox_enabled", false);
diff --git a/legacy.base.js b/legacy.base.js
new file mode 100644
index 0000000..0531c16
--- /dev/null
+++ b/legacy.base.js
@@ -0,0 +1,28 @@
+this.legacy = class extends ExtensionAPI {
+ getAPI() {
+ return {
+ legacy: {
+ register() {
+ let {XPIDatabase} = ChromeUtils.importESModule('resource://gre/modules/addons/XPIDatabase.sys.mjs');
+ XPIDatabase.isDisabledLegacy = (addon) => false;
+ XPIDatabase.mustSign = (aType) => false;
+
+ const {AddonManager} = ChromeUtils.importESModule('resource://gre/modules/AddonManager.sys.mjs');
+ AddonManager.addExternalExtensionLoader(BootstrapLoader);
+ },
+ finalize() {
+ // from xiaoxiaoflood's bootstrapLoader.xpi
+ const {AddonManager} = ChromeUtils.importESModule('resource://gre/modules/AddonManager.sys.mjs');
+ AddonManager.getAllAddons().then(addons => {
+ addons.forEach(addon => {
+ if (addon.type == 'extension' && !addon.isWebExtension && !addon.userDisabled) {
+ addon.disable();
+ addon.enable();
+ }
+ })
+ })
+ }
+ }
+ }
+ }
+}
diff --git a/legacy.json b/legacy.json
new file mode 100644
index 0000000..1947463
--- /dev/null
+++ b/legacy.json
@@ -0,0 +1,10 @@
+[{"namespace": "legacy",
+ "functions": [
+ {"name": "register",
+ "type": "function",
+ "parameters": []
+ },
+ {"name": "finalize",
+ "type": "function",
+ "parameters": []}]
+ }]
diff --git a/legacy.manifest b/legacy.manifest
deleted file mode 100644
index 74999b3..0000000
--- a/legacy.manifest
+++ /dev/null
@@ -1 +0,0 @@
-resource legacy legacy/
diff --git a/legacy/BootstrapLoader.sys.mjs b/legacy/BootstrapLoader.sys.mjs
index 80fc61d..d28bf22 100644
--- a/legacy/BootstrapLoader.sys.mjs
+++ b/legacy/BootstrapLoader.sys.mjs
@@ -1,19 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
+var BootstrapLoader = (function() {
"use strict";
var EXPORTED_SYMBOLS = ["BootstrapLoader"];
-import {AddonManager} from "resource://gre/modules/AddonManager.sys.mjs";
-import {AddonInternal} from "resource://gre/modules/addons/XPIDatabase.sys.mjs";
-import {InstallRDF} from "resource://legacy/RDFManifestConverter.sys.mjs";
-import {XPIProvider} from "resource://gre/modules/addons/XPIProvider.sys.mjs";
+let {AddonManager} = ChromeUtils.importESModule("resource://gre/modules/AddonManager.sys.mjs");
+let {AddonInternal} = ChromeUtils.importESModule("resource://gre/modules/addons/XPIDatabase.sys.mjs");
+let {XPIProvider} = ChromeUtils.importESModule("resource://gre/modules/addons/XPIProvider.sys.mjs");
const BOOTSTRAP_REASONS = XPIProvider.BOOTSTRAP_REASONS;
-var logger = console.createInstance({ prefix: "addons.bootstrap" });
+var logger = console;
/**
* Valid IDs fit this pattern.
@@ -92,7 +91,7 @@ function buildJarURI(aJarfile, aPath) {
return Services.io.newURI(uri);
}
-export var BootstrapLoader = {
+return BootstrapLoader = {
name: "bootstrap",
manifestFile: "install.rdf",
async loadManifest(pkg) {
@@ -294,14 +293,12 @@ export var BootstrapLoader = {
addonId: addon.id,
wantGlobalProperties: ["ChromeUtils"],
metadata: { addonID: addon.id, URI: uri },
+ console,
});
try {
Object.assign(sandbox, BOOTSTRAP_REASONS);
- ChromeUtils.defineLazyGetter(sandbox, "console", () =>
- console.createInstance({ consoleID: `addon/${addon.id}` }));
-
Services.scriptloader.loadSubScript(uri, sandbox);
} catch (e) {
logger.warn(`Error loading bootstrap.js for ${addon.id}`, e);
@@ -359,4 +356,4 @@ export var BootstrapLoader = {
};
},
};
-
+})()
diff --git a/legacy/RDFDataSource.sys.mjs b/legacy/RDFDataSource.sys.mjs
index 27687ba..67f087e 100644
--- a/legacy/RDFDataSource.sys.mjs
+++ b/legacy/RDFDataSource.sys.mjs
@@ -21,7 +21,8 @@
* property element. If a resource is first added as the subject of an assertion
* then it will be serialised at the top level of the XML.
*/
-
+var RDFDataSource = (function() {
+XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser", "Element"]);
const NS_XML = "http://www.w3.org/XML/1998/namespace";
const NS_XMLNS = "http://www.w3.org/2000/xmlns/";
const NS_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
@@ -1107,7 +1108,7 @@ class RDFBlankNode extends RDFSubject {
* changed as assertions are added and removed to the RDF. Pass a null document
* to start with an empty graph.
*/
-export class RDFDataSource {
+return class RDFDataSource {
constructor(document) {
// All known resources, indexed on URI
this._resources = {};
@@ -1509,3 +1510,4 @@ export class RDFDataSource {
return IOUtils.writeUTF8(file, this.serializeToString());
}
}
+})()
diff --git a/legacy/RDFManifestConverter.sys.mjs b/legacy/RDFManifestConverter.sys.mjs
index 12abd27..dc8df42 100644
--- a/legacy/RDFManifestConverter.sys.mjs
+++ b/legacy/RDFManifestConverter.sys.mjs
@@ -1,12 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+var InstallRDF = (function() {
"use strict";
var EXPORTED_SYMBOLS = ["InstallRDF"];
-import {RDFDataSource} from "resource://legacy/RDFDataSource.sys.mjs";
-
const RDFURI_INSTALL_MANIFEST_ROOT = "urn:mozilla:install-manifest";
function EM_R(aProperty) {
@@ -39,7 +38,7 @@ class Manifest {
}
}
-export class InstallRDF extends Manifest {
+return class InstallRDF extends Manifest {
_readProps(source, obj, props) {
for (let prop of props) {
let val = getProperty(source, prop);
@@ -107,3 +106,4 @@ export class InstallRDF extends Manifest {
return result;
}
}
+})()
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..7aafbb1
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,23 @@
+{
+ "manifest_version": 2,
+ "name": "LegacyWolf",
+ "version": "136.0.0.1",
+ "description": "LegacyFox as an add-on: Coax modern Firefox into running legacy add-ons.",
+ "author": "girst and MarsIronPI",
+ "browser_specific_settings": {
+ "gecko": {"id": "legacywolf@ba.ln.ea.cx"}
+ },
+
+ "background": {"scripts": ["register.js"]},
+ "web_accessible_resources": ["legacy/*"],
+ "experiment_apis": {
+ "legacy": {
+ "schema": "legacy.json",
+ "parent": {
+ "scopes": ["addon_parent"],
+ "paths": [["legacy"]],
+ "script": "legacy.js"
+ }
+ }
+ }
+}
diff --git a/register.js b/register.js
new file mode 100644
index 0000000..10a6a5e
--- /dev/null
+++ b/register.js
@@ -0,0 +1,2 @@
+browser.legacy.register()
+browser.legacy.finalize()