How to create a Pale Moon targeted extension

Post your tutorials for using Pale Moon or performing related tasks here.
Note: Not for "how do I...?" Questions!

Moderator: satrow

Forum rules
Tutorials and Howtos should only relate to Pale Moon, and not to third party applications. e.g.: Don't post a Howto for configuring your firewall.
If you have a question how to do something, you should use one of the support boards, not this board. It is meant for people to document and post instructions.
User avatar
Pale Moon guru
Pale Moon guru
Posts: 23627
Joined: 2011-08-28, 17:27
Location: 58°2'16"N 14°58'31"E

How to create a Pale Moon targeted extension

Unread post by Moonchild » 2017-09-24, 19:02

Mainly aimed at add-on developers
If you are an extension developer looking to create or adapt an extension to target Pale Moon specifically, there are a few important points to target Pale Moon:

What is Pale Moon's application GUID?
The GUID of Pale Moon from version 25.0 onwards is unique to Pale Moon, and not the same as Firefox.
The GUID is:
Please note this down, you will need it for the instructions below.

What do I need to do to create a Pale Moon specific/compatible extension?
Not all Firefox extensions will work in Pale Moon as-is because of the different feature set and slight differences in the UI.
As an add-on developer, you may need to create a Pale Moon specific version of your extension, or add specifically adjusted overlays to your existing Firefox extension.

There are a few options here:
  1. Create a separate, Pale Moon exclusive extension:
    To do this, you need to remove the Firefox target application block from your install.rdf, and add a Pale Moon specific one with the Pale Moon GUID, and Pale Moon specific version range (the Pale Moon application version). For example:

    Code: Select all

    		<em:targetApplication><!-- Pale Moon -->
    IMPORTANT: You should also change the extension's ID in this case to prevent incorrect automatic updates of the extension with an incompatible Firefox one.
  2. Create a hybrid extension that caters to both Firefox and Pale Moon in a single package:
    To do this, you need to add a Pale Moon specific target application block with the Pale Moon GUID and version range, as above.
    Of note is that the Pale Moon GUID is checked first, so any block with Pale Moon GUID will take precedence over the Firefox block. This means that an extension can be compatible with Firefox 16-31, but if the Pale Moon block indicates 25.0-25.* and you try to install it in Pale Moon 27, it will fail if (you use strict compatibility checking).
    Note, you may also have to take the steps listed in the next point if you use overlays.
  3. Add Pale Moon to a multi-app extension (Create a Mozilla extension that caters to Pale Moon and other applications):
    In some cases, Firefox extensions will fail to work properly on Pale Moon as-is because they have defined application-specific overlays (as is the case with a number of add-ons that support Firefox, Seamonkey and Thunderbird in one package). The new GUID means that those overlays (tied to the Firefox GUID in application={}) will no longer apply to Pale Moon and the extension will break because it won't have an overlay for Pale Moon.
    You can continue to supply the Firefox extension as-is with minimal edits, by adding Pale Moon GUID-specific overlays to chrome.manifest in your extension:

    Code: Select all

        # Firefox windows
        overlay chrome://browser/content/browser.xul      chrome://myextension/content/overlay.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
        # Pale Moon windows
        overlay chrome://browser/content/browser.xul      chrome://myextension/content/overlay.xul application={8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}
If you have created a Jetpack/SDK extension that hard-codes application GUIDs in its bootstrap script, then you will, of course, also have to add Pale Moon's GUID to it.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne
"I'm afraid you have me mistaken for someone who can be shamed by a child." -- Quillspawn