Home | Blog | LegacyFox

Coaxing modern Firefox into running legacy Extensions

Firefox 57 marked a new era of the last remaining user agent, that actually puts the user first: XPCOM-based add-ons, that essentially monkey-patch the browser, were deprecated. While this is a good development for Mozilla and its users, it also left me without a usable vi-like navigation[1]. After a long period of more and more insane hacks[2] to keep VimFx running, I have finally arrived at a relatively sane and easy to maintain solution.

First off, this is neither recommended nor endorsed by Mozilla or Fedora. It probably is fair to assume, that they'd be against you reversing the flow of time with regards to webextensions. Secondly, this won't magically forward-port APIs that have been dropped and your add-on might need. All I'm doing here is reinstating support for install.rdfbootstrapped extensions. If this doesn't work for you, maybe try Waterfox 68 (as of yet alpha and their security track record isn't great either).

The Gist

  1. Install Firefox though Fedora's repositories. This ensures up-to-date-ness (and fixed CVEs)
  2. Copy these handful of files into /usr/lib64/firefox/ by issuing make install (as root).
  3. Install VimFx v0.21.0 from GitHub. May need dis- and reenabling after the first install.
Just how I like it: VimFx running in the latest Firefox (version 68)

In Detail

Let's dive into /usr/lib64/firefox (or /usr/lib/firefox, depending on your distro)! At the heart of these shenanigans lies the AutoConfig system. AutoConfig is meant to force site-wide preferences, but is actually capable of executing Javascript, which lets us do some additional neat things.

It needs to be enabled by toggling some prefs in defaults/pref/config-prefs.js. We also disable the sandbox, so we can run our code within the context and privileges of the whole browser (Mozilla actually wants to remove unsandboxed execution, which would break this current approach).

This will then load config.js: First, we force-enable legacy extension in an awfully hacky way[3]. Then, we register a new manifest file (legacy.manifest[4]) to register additional packages for the resource:// preudo protocol. Now we can address the BootstrapLoader and RDF parser (located in legacy/) easily from within Javascript without having to rely on hardcoded paths. And finally, we engage the bootstrap loader by loading it and telling the AddonManager about it.

All this is neatly packaged up into a tarball that can be extracted on top of Firefox' install directory. The Makefile just packs all the files and (when issuing install) extracts them to the correct location (Note: as of today, the path for Fedora's Firefox directory is hardcoded).


I hate footnotes, but some stuff I couldn't cram into the main text. Press your user agent's hotkey for window.history.back() to get back to where you were coming from.