extensionTypes.InjectDetails

This object is used by:

The code can be in a separate file, specified using file, or in a string, specified using code. One (and only one) of code or file must be set.

Warning:
Be careful using the code parameter. Incorrect use of it may open your extension to cross-site scripting attacks.

Type

Values of this type are objects. They contain the following properties:

allFramesOptional
boolean. If true, the code will be injected into all frames of the current page. If true and frameId is set, then the code will be injected into the specified frame and all its child frames. If it is false, code is only injected into the top frame. Defaults to false.
codeOptional
string. Code to inject, as a text string.
fileOptional
string. Path to a file containing the code to inject. In Firefox, relative URLs are resolved relative to the current page URL. In Chrome, these URLs are resolved relative to the add-on's base URL. To work cross-browser, you can specify the path as an absolute URL, starting at the add-on's root, like this: "/path/to/script.js".
frameIdOptional
integer. The frame where the code should be injected. Defaults to 0 (the top-level frame).
matchAboutBlankOptional
boolean. If true, the code will be injected into embedded "about:blank" and "about:srcdoc" frames if your add-on has access to their parent document. The code cannot be inserted in top-level about: frames. Defaults to false.
runAtOptional
extensionTypes.RunAt. The soonest that the code will be injected into the tab. Defaults to "document_idle".

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 45.0 48.0 No

Compatibility notes

Firefox

  • 'matchAboutBlank' is not supported.

Acknowledgements

This API is based on Chromium's chrome.extensionTypes API. This documentation is derived from extension_types.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, wbamberg, Jeremie, glukki, rolfedh
 Last updated by: Makyen,