| Type | Array |
|---|---|
| Mandatory | No |
| Manifest version | 2 or higher |
| Example | "content_scripts": [ { "matches": ["*://*.mozilla.org/*"], "js": ["borderify.js"] } ] |
Instructs the browser to load content scripts into web pages whose URL matches a given pattern.
This key is an array. Each item is an object which:
-
must contain a key named
matches, which specifies the URL patterns to be matched in order for the scripts to be loaded; -
may contain keys named
jsandcss, which list scripts and/or stylesheets to be loaded into matching pages; and - may contain a number of other properties that control finer aspects of how and when content scripts are loaded.
Details of all the keys you can include are given in the table below.
| Name | Type | Description |
|---|---|---|
all_frames | Boolean |
Defaults to |
css | Array | An array of paths, relative to Files are injected in the order given, and at the time specified by Note: Firefox resolves URLs in injected CSS files relative to the CSS file itself, rather than to the page it's injected into. |
exclude_globs | Array | An array of strings containing wildcards. See Matching URL patterns below. |
exclude_matches | Array | An array of match patterns. See Matching URL patterns below. |
include_globs | Array | An array of strings containing wildcards. See Matching URL patterns below. |
js | Array | An array of paths, relative to Files are injected in the order given. This means that, for example, if you include jQuery here followed by another content script, like this: "js": ["jquery.js", "my-content-script.js"] Then, The files are injected after any files in |
match_about_blank | Boolean | Insert the content scripts into pages whose URL is This is especially useful to run scripts in empty iframes, whose URL is For example, suppose you have a "content_scripts": [ { "js": ["my-script.js"], "matches": ["https://example.org/"], "match_about_blank": true, "all_frames": true } ] If the user loads Note: Note that in Firefox, content scripts won't be injected into empty iframes at |
matches | Array | An array of match patterns. See Matching URL patterns below. This is the only mandatory key. |
run_at | String | This option determines when the files specified in
The default value is |