diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | config.js | 16 | ||||
-rw-r--r-- | defaults/pref/config-prefs.js | 3 | ||||
-rw-r--r-- | legacy.base.js | 28 | ||||
-rw-r--r-- | legacy.json | 10 | ||||
-rw-r--r-- | legacy.manifest | 1 | ||||
-rw-r--r-- | legacy/BootstrapLoader.sys.mjs | 20 | ||||
-rw-r--r-- | legacy/LegacyFoxUtils.sys.mjs | 5 | ||||
-rw-r--r-- | legacy/RDFDataSource.sys.mjs | 6 | ||||
-rw-r--r-- | legacy/RDFManifestConverter.sys.mjs | 6 | ||||
-rw-r--r-- | manifest.json | 23 | ||||
-rw-r--r-- | register.js | 2 |
13 files changed, 94 insertions, 57 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 @@ -1,27 +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/LegacyFoxUtils.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/LegacyFoxUtils.sys.mjs legacy/BootstrapLoader.sys.mjs legacy.base.js + cat $^ >$@ -uninstall: - cd "$(DESTDIR)" && rm -rf -- $(files) +clean: + rm -f $(archive) legacy.js diff: @curl -sL 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 7285ca5..bd53689 100644 --- a/legacy/BootstrapLoader.sys.mjs +++ b/legacy/BootstrapLoader.sys.mjs @@ -1,20 +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"; -import {LegacyFoxUtils} from "resource://legacy/LegacyFoxUtils.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. @@ -93,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) { @@ -295,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); @@ -368,4 +364,4 @@ export var BootstrapLoader = { }; }, }; - +})() diff --git a/legacy/LegacyFoxUtils.sys.mjs b/legacy/LegacyFoxUtils.sys.mjs index 8e101d0..6d13c2c 100644 --- a/legacy/LegacyFoxUtils.sys.mjs +++ b/legacy/LegacyFoxUtils.sys.mjs @@ -3,7 +3,7 @@ * Components.manager.removeBootstrappedManifestLocation, which have been nixed * in mozilla142. Copyright 2025 Tobias Girstmair <https://gir.st/>, MPLv2. */ - +var LegacyFoxUtils = (function() { const ZipReader = Components.Constructor( "@mozilla.org/libjar/zip-reader;1", "nsIZipReader", @@ -22,7 +22,7 @@ const FileOutputStream = Components.Constructor( "init" ); -export class LegacyFoxUtils { +return class LegacyFoxUtils { static addBootstrappedManifestLocation(file, addon, uriMaker) { // read chrome.manifest from .jar (or unpacked addon) let zipReader = new ZipReader(file); @@ -80,3 +80,4 @@ function absolutizePaths(uriMaker, file, line) { return line; } +})() 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() |