Inject the scripts specified in js and css into all frames matching the specified URL requirements, even if the frame is not the topmost frame in a tab. This does not inject into child frames where only their parent matches the URL requirements and the child frame does not match the URL requirements. The URL requirements are checked for each frame independently.
Note: This also applies to any tracker or ad that uses iframes, which means that enabling this could make your content script get called dozens of times on some pages.
false
Inject only into frames matching the URL requirements which are the topmost frame in a tab.
Insert the content scripts into pages whose URL is "about:blank" or "about:srcdoc", if the URL of the page that opened or created this page matches the patterns specified in the rest of the content_scripts key.
This is especially useful to run scripts in empty iframes, whose URL is "about:blank". To do this you should also set the all_frames key.
For example, suppose you have a content_scripts key like this:
This option determines when the files specified in css and js are injected. You can supply one of three strings here, each of which identifies a state in the process of loading a document. The states directly correspond to Document.readyState:
"document_start"
Corresponds to loading. The DOM is still loading.
"document_end"
Corresponds to interactive. The DOM has finished loading, but resources such as scripts and images may still be loading.
"document_idle"
Corresponds to complete. The document and all its resources have finished loading.
The default value is "document_idle".
In all cases, files in js are injected after files in css.
Matching URL patterns
The "content_scripts" key attaches content scripts to documents based on URL matching: if the document's URL matches the specification in the key, then the script will be attached. There are four properties inside "content_scripts" that you can use for this specification:
This injects two content scripts into all pages under mozilla.org or any of its subdomains except developer.mozilla.org, whether served over HTTP or HTTPS.
The content scripts see the same view of the DOM and are injected in the order they appear in the array, so borderify.js can see global variables added by jquery.js.
Browser compatibility
Desktop
Mobile
Chrome
Edge
Firefox
Internet Explorer
Opera
Safari
WebView Android
Chrome Android
Firefox for Android
Opera Android
Safari on IOS
Samsung Internet
content_scripts
YesContent scripts are not applied to tabs already open when the extension is loaded.
14
48
?
YesContent scripts are not applied to tabs already open when the extension is loaded.
14Content scripts are not applied to tabs until the user grants permission via the extension's access popover in the toolbar.
?
?
48
?
15Content scripts are not applied to tabs until the user grants permission via the extension's access alert.
?
all_frames
Yes
14
48
?
Yes
14
?
?
48
?
15
?
css
Yes
14
48
?
Yes
14
?
?
48
?
15
?
exclude_globs
Yes
14
48
?
Yes
No
?
?
48
?
No
?
exclude_matches
Yes
14
48
?
Yes
14
?
?
48
?
15
?
include_globs
Yes
14
48
?
Yes
No
?
?
48
?
No
?
js
Yes
14
48
?
Yes
14
?
?
48
?
15
?
match_about_blank
Yes
14
52Content scripts won't be injected into empty iframes at 'document_start' even if you specify that value in 'run_at'.
?
Yes
No
?
?
52Content scripts won't be injected into empty iframes at 'document_start' even if you specify that value in 'run_at'.
?
No
?
matches
Yes
14
48
?
Yes
14
?
?
48
?
15
?
run_at
Yes
14
48
?
Yes
14Content scripts are not applied to tabs until the user grants permission via the extension's access popover in the toolbar. Additional loads after permission is granted will respect run_at.
?
?
48
?
15Content scripts are not applied to tabs until the user grants permission via the extension's access alert. Additional loads after permission is granted will respect run_at.