4

Google Chrome's extensions can be configured as a user by creating a file in /etc/chromium-browser/policies/managed/ containing e.g.

{
    "3rdparty": {
        "extensions": {
            "fiopkogmohpinncfhneadmpkcikmgkgc": {
                "youtube": 1
            }
        }
    }
}

(in Linux, for Windows, you have to set a group policy with similar content)

How can this be translated to Firefox? How can Firefox's WebExtensions be configured (as a user, not as a developer) with storage.managed?

2 Answers 2

1
+50

Perhaps more information is needed, but it seems to me that the question is answered by your own link.

If you are the extension developer, you should include in the manifest file manifest.json:

"type": "storage",
"data":
{
  "whitelist": "google",
  "starttime": "0800",
  "endtime": "1500"
}

The attribute whitelist is referenced in the code by the StorageArea.get() function:

var storageItem = browser.storage.managed.get('whitelist');
storageItem.then((res) => {
  console.log(`Whitelist is: ${res.whitelist}`);
});

If you would like to change an existing extension, then you need to do it from source-code, since not only the manifest needs to be changed, but also the code itself that references the storage items. Even if the extension uses a Native manifest, defined as "specially formatted JSON files that are provisioned on the user's computer by some means outside the extension installation process", changing the manifest is not enough.

The storage.managed page links to the example add-on of favourite-colour, which is a complete example showing the definition, access and setting of the managed data, and of creating the manifest.json file.

15
0

These are the steps to customize the favorite-color extension provided by Mozilla:

  1. download favorite-color extension at https://github.com/mdn/webextensions-examples/tree/master/favourite-colour
  2. create file with manifest content at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/managed#Provisioning_managed_storage:

    {
      "name": "[email protected]",
      "description": "ignored",
      "type": "storage",
      "data":
      {
        "colour": "management thinks it should be blue!"
      }
    }
    
  3. mkdir -p /usr/lib/mozilla/managed-storage (global install, can also save to ~/.mozilla/managed-storage for a user-based install)

  4. save file to /usr/lib/mozilla/managed-storage/[email protected]
  5. start firefox (or ESR)
  6. load extension downloaded in step 1 in about:debugging

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .