DShultz
DShultz

Reputation: 4541

Chrome extension content script - match pattern choice

I'm working on a Chrome extension that basically checks to see if certain elements exist on the current page. I have a content script that contains all the functions to do the checking. Here is my manifest.json content_scripts section:

"content_scripts": [
  {
    "matches": ["http://*/*", "https://*/*"],
    "js": ["content.js"],
    "run_at": "document_end"
  }
]

...it seems pretty clumsy to have to set the wildcard matches to just be everything. Is this the best practice? I would assume most chrome extensions would want to always run against the current active tab regardless of the url.

Upvotes: 1

Views: 2022

Answers (1)

Pavel Agarkov
Pavel Agarkov

Reputation: 3783

The following pattern means that content script will be injected into all pages:

"matches": [ "<all_urls>" ]

You can find details in the docs

Upvotes: 1

Related Questions