Preload extension

Can anyone tell me how to preload the extension in firefox source code on my own build firefox?

Firefox offers this feature (https://mzl.la/3zPUSoX), although I’m not sure if it only works for Firefox ESR (Extended Support Release) or if it will work for all flavours of Firefox.

1 Like

So, should use this version of firefox . can you tell me why this version of firefox is needed?

You can try with the regular version of Firefox, but I’m just not sure if it supports that type of control.

Firefox ESR is a version of Firefox that doesn’t get feature updates as often but it gets security updates just like the regular Firefox. It is primarily for use by businesses. Because it’s often used by businesses, it has support for all of the features that a business would want to use.

But for sure try it out on the regular Firefox first to see if it works before trying Firefox ESR.

In nightly version this is not working. And how will download or build the source code for regular one?

How can I download or build the source code of regular one

Preloading an extension in Firefox source code involves modifying the browser’s code to ensure that the extension is loaded and active when the browser starts. Here are the general steps you can follow:

  1. Locate the Extension Directory:
    Identify the directory where your extension is located within the Firefox source code.

  2. Modify browser/components/Extension.jsm:
    Open the Extension.jsm file, which is usually located in the browser/components directory.

    • Add an import statement for your extension at the beginning of the file. For example:

      const { ExtensionParent } = ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm");
      const { ExtensionTestUtils } = ChromeUtils.import("resource://testing-common/ExtensionTestUtils.jsm");
      Components.utils.import("resource://path/to/your/extension/bootstrap.jsm");
      
    • Find the loadExtensions function and locate the line where it loads extensions. Add the following line to ensure your extension is loaded:

      ExtensionTestUtils.loadExtension({
        manifest: {
          // Your extension manifest details go here
        },
        // Other extension options go here
      });
      
  3. Build Firefox:
    After making these changes, build Firefox using the build instructions provided for your platform. This typically involves running mach build from the command line.

  4. Run Firefox:
    Start the newly built Firefox instance. Your extension should now be preloaded.

Keep in mind that modifying the Firefox source code requires some familiarity with the build system and JavaScript. It’s also essential to understand the consequences of modifying the browser’s behavior, as it may lead to unexpected issues or instability.

Note: The specifics of modifying the source code may vary based on the Firefox version you are working with. Always refer to the official Mozilla documentation and source code for the version you are using.

1 Like