Firefox – How to enable extension when running Firefox for the first time

firefoxfirefox-extensions

I need to run Firefox each time in a new profile directory with my extension enabled. What I do is the following:

  • Create temporary directory for storing profile (/tmp/profile.123)
  • Create extensions directory (/tmp/profile.123/extensions)
  • Create extension proxy as described here (/tmp/profile.123/extensions/myextension@my.domain)

My command line looks like this:

firefox -no-remote -profile /tmp/profile.123 -url http://www.google.com

The problem is that my extension starts disabled, and I'm forced to enable it manually and restart the Firefox. Is it possible to make it start enabled in first place?

Thanks!

Workaround I've found:

Create extensions.sqlite database file in the newly created profile folder. This file must contain my extension entry under the "addon" table.

Best Answer

It looks like workaround with modifying extensions.sqlite doesn't work anymore and such database doesn't exist. It was described here: http://research.zscaler.com/2012/09/how-to-install-silently-malicious.html

To enable extension automatically on first run, add following entry to the extensions.json located in newly create profile:

my example of extensions.json

{
  "schemaVersion": 16,
  "addons": [
    {
      "id": "jid1-ZS4Xlocq0DBhdg@jetpack",
      "syncGUID": "1DNxcuq4WubL",
      "location": "app-profile",
      "version": "1.0",
      "type": "extension",
      "internalName": null,
      "updateURL": null,
      "updateKey": null,
      "optionsURL": null,
      "optionsType": null,
      "aboutURL": null,
      "iconURL": null,
      "icon64URL": null,
      "defaultLocale": {
        "name": "My cool extension name",
        "description": "Description",
        "creator": "hacker_1998",
        "homepageURL": null
      },
      "visible": true,
      "active": true,
      "userDisabled": false,
      "appDisabled": false,
      "descriptor": "c:\\tmp\\firefox001\\extensions\\jid1-ZS4Xlocq0DBhdg@jetpack.xpi",
      "installDate": 1419414549006,
      "updateDate": 1419414549006,
      "applyBackgroundUpdates": 1,
      "bootstrap": true,
      "size": 54426,
      "sourceURI": null,
      "releaseNotesURI": null,
      "softDisabled": false,
      "foreignInstall": true,
      "hasBinaryComponents": false,
      "strictCompatibility": false,
      "locales": [

      ],
      "targetApplications": [
        {
          "id": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
          "minVersion": "26.0",
          "maxVersion": "30.0"
        }
      ],
      "targetPlatforms": [

      ],
      "multiprocessCompatible": false
    }
  ]
}

enter image description here

"active": true and "userDisabled": false are the keys to activate extension silently

The file extensions.json doesn't exist after "-CreateProfile" command, so you should create it manually.

Be careful with different versions of Firefox.

Update

If you want to use extension immediately after first run of profile, prefs.js file should also contain something like: user_pref("extensions.bootstrappedAddons", "{\"CoolAddon@jetpack\":{\"version\":\"1.0\",\"type\":\"extension\",\"descriptor\":\"C:\\\\Users\\\\superuser\\\\AppData\\\\Roaming\\\\Mozilla\\\\Firefox\\\\Profiles\\\\7hkjishf.Default User\\\\extensions\\\\CoolAddon@jetpack.xpi\",\"multiprocessCompatible\":false}}");

Be aware of weird quotes escaping.

Related Question