Home > Mobile >  Firefox extension: apply content_scripts on all web pages but css on specific web page?
Firefox extension: apply content_scripts on all web pages but css on specific web page?

Time:02-26

I have a Firefox extension where I want to apply contentScript.js to all web pages. The manifest.json looks like this:

  "content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*"],
      "css": ["background.css"],
      "js":["contentScript.js"]
    }
  ]

However, I only want the CSS to be applied to a certain web page. Right now the CSS is applied to all web pages.

How can I solve this?

CodePudding user response:

My friend came up with a solution, change your manifest file to this:

  "content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*"],
      "js":["contentScript.js"]
    },
    {
      "matches": ["*://*.website.org/*"],
      "css": ["background.css"]
    }
  ]

Life saver.

  • Related