# Extensions

# SeaMonkey Extensions

SeaMonkey supports toolkit/-style extensions.

## The Basics

To support SeaMonkey as a target application, you need to add it to the list of target applications in the extension's install.rdf file. The code for that will look something like this:

    <em:targetApplication>
      <!-- SeaMonkey -->
      <Description>
        <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
        <em:minVersion>2.0</em:minVersion>
        <em:maxVersion>2.*</em:maxVersion>
      </Description>
    </em:targetApplication>

The install.js is not supported any more and should be removed.

## Differences as compared to other toolkit/-based applications

- You need to overlay/open different chrome URLs as compared to Firefox. Some URLs are listed below:

  URL in Firefox | URL in SeaMonkey | Overlays
  chrome://browser/content/browser.xul | chrome://navigator/content/navigator.xul | Main browser window
  chrome://browser/content/pageinfo/pageInfo.xul | chrome://navigator/content/pageinfo/pageInfo.xul | Page Info window
  chrome://browser/content/bookmarks/bookmarksPanel.xul | chrome://communicator/content/bookmarks/bookmarksPanel.xul
  chrome://browser/content/places/places.xul | chrome://communicator/content/places/places.xul

  Old versions of Thunderbird use mostly the same chrome URLs for overlaying as SeaMonkey. There are exceptions, but these are few and far between.

- SeaMonkey also uses different IDs for the menu items. Some important menu IDs are listed below, menu IDs are based on Firefox 3 source code:

  Menu id in Firefox | Menu id in SeaMonkey | Overlays
  menu_FilePopup | menu_FilePopup | File menu popup
  menu_EditPopup | menu_EditPopup | Edit menu popup
  menu_viewPopup | menu_View_Popup | View menu popup
  goPopup | goPopup | Go menu popup
  placesPopupset | placesPopupset | History menu popup
  bookmarksMenuPopup | bookmarksMenuPopup | Bookmarks menu popup
  menu_ToolsPopup | taskPopup | Tools menu popup
  windowPopup | windowPopup | Window menu popup
  - | helpPopup | Help menu popup

## URLbar Icons

To display a button with a menupopup in the urlbar-icons for both Firefox and SeaMonkey, use this code:

`<hbox id="urlbar-icons">
<image popup="myExt-menu"/>
</hbox>
<window id="main-window">
<menupopup id="myExt-menu">
<menuitem label="menuitem"/>
<menuitem label="menuitem"/>
<menuitem label="menuitem"/>
</menupopup>
</window>`

Instead of

`<hbox id="urlbar-icons">
<button type="menu">
<menupopup>
<menuitem label="menuitem"/>
<menuitem label="menuitem"/>
<menuitem label="menuitem"/>
</menupopup>
</button>
</hbox>`

Technical Note: The code that opens the URL history popup just looks for any menupopup, so it goes wrong if you add your own. Ordinary popups are fine of course.

## The Statusbar

In Firefox a new `vbox` has been added, called "browser-bottombox", which encloses the find bar and status bar at the bottom of the browser window. Although this doesn't affect the appearance of the display, it may affect your extension if it overlays chrome relative to these elements.

For example, if you overlay some chrome before the status bar, like this:

    <vbox id="browser-bottombox">
      <something insertbefore="status-bar" />
    </vbox>

Use the following technique to make your overlay work on both SeaMonkey and Firefox (pre-57):

    <window id="main-window">
      <vbox id="browser-bottombox" insertbefore="status-bar">
        <something insertbefore="status-bar" />
      </vbox>
    </window>

## Thunderbird 3

### gFolderDisplay API

SeaMonkey only supports a reduced set of methods:

- selectedCount
- selectedMessage
- selectedMessageUri
- selectedMessageIsFeed
- selectedMessageIsImap
- selectedMessageIsNews
- selectedMessageIsExternal
- selectedIndices
- selectedMessages
- selectedMessageUris
- canArchiveSelectedMessages
- displayFolder
- focusedPane
- messageDisplay

### gMessageDisplay API

SeaMonkey only supports a reduced set of methods:

- displayedMessage
- isDummy
- visible

## Multi-browser compatibility

To make an extension compatible with SeaMonkey as well as Firefox/Thunderbird, you may need to do different things depending on which application is running the extension.

### In JavaScript code

You can use the following technique to detect the application:

    const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
    const THUNDERBIRD_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
    const SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}";
    var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
                            .getService(Components.interfaces.nsIXULAppInfo);
    if (appInfo.ID == FIREFOX_ID) {
      // running under Firefox
    } else if (appInfo.ID == THUNDERBIRD_ID) {
      // running under Thunderbird
    } else if (appInfo.ID == SEAMONKEY_ID) {
      // running under SeaMonkey
    } else {
      // another app
    }

### In manifest file

SeaMonkey uses different overlays than other applications. You can use the application flag to select which overlay should be used with which application:

    overlay chrome://browser/content/browser.xul chrome://myaddon/content/ffOverlay.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
    overlay chrome://messenger/content/mailWindowOverlay.xul chrome://myaddon/content/tbOverlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
    overlay chrome://navigator/content/navigator.xul chrome://myaddon/content/smOverlay.xul application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}