Ryan Luu
Ryan Luu

Reputation: 625

Extension on Firefox running with only on clicked

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.

Upvotes: 2

Views: 464

Answers (0)

Related Questions