2

I have a dark mode extension that injects a CSS file into a website. It works fine for all other browsers (Edge, Chrome, Opera, etc) except for Firefox where the user has to manually select the extension to have permissions to run.

This is the extension when you install it, it doesn't automatically inject the dark mode CSS theme because it needs permissions. I want it to have the permissions from the start like in other browsers.

Permission needed to read and change data

Instead, the user needs to manually enable the permissions for the extension. This is causing some users to think the extension is broken since it doesn't automatically work like other extensions.

Only When Clicked

Below is the code I used, I believe it has to do with something within the manifest file but I'm not entirely sure.

manifest.json:

{
  "manifest_version": 3,
  "name": "Dark mode",
  "version": "1.0.0",
  "content_scripts": [
    {
      "matches": ["*://example.com/*"],
      "css": ["dark-mode.css"]
    }
  ],
  "browser_specific_settings": {
    "gecko": {
      "id": "[email protected]"
    }
  }
}

dark-mode.css:

body {
  background-color: rgb(0, 0, 0) !important;
}

If you would like to recreate the extension yourself, it's just those two file in a folder. Nothing else needed or hidden.

I tried searching online and looking for documentation on MDN but couldn't find anything about adjusting the extension permissions.

The only way I got the extension to get permissions is to use Manifest v2 instead of v3 but I would prefer not to do that for obvious reasons.

2
  • Firefox doesn't grant site permissions in ManifestV3 extensions by default and the user should explicitly allow it on the site or in about:addons. BTW you may want to add * to your matches to cover the entire site. Commented Apr 21, 2024 at 6:19
  • @wOxxOm Is there any way to set site permissions anyways? I know other browsers allow this by just showing the permissions the extension needs when you install it. Commented Apr 21, 2024 at 8:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.