How to match all domain extensions in content script (firefox)?

Viewed 451

I need to match all domain extensions for a simple Firefox extension I am writing. For example, I need to the extension to run on:

I do not want the extension to run on anything that isn't the 'example website, e.g.,

This is important, in part, so that I do not need to get permission to access data on all website for my extension.

Notes:

1 Answers

You have to specifiy all the individual domain names you want to match

"matches": [
   "https://example.com/*",
   "https://example.org/*",
   "https://example.net/*"
]

Important: Do not forget the /* path at the end, it will not work without that.

Unfortunately it is not possible to have a pattern match for all top level domains (like https://example.*/*), since Firefox explicitly disallows such matches as mentioned in Invalid match patterns

This is because of the hierarchy of domain names (from right to left)

  • *.example.com belongs to *.com
  • www.example.com belongs to *.example.com

The closest you can get is https://*/*. Declaratively mention this to handle all hosts, but programatically filter out the hosts you need. I do see that you don't want to get permission for all websites, but there is no other way.

Related