Skip to content

API > wxt > MainWorldContentScriptDefinition

Interface: MainWorldContentScriptDefinition

Contents

Extends

Properties

allFrames

allFrames?: PerBrowserOption<undefined | boolean>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
false

Inherited from

MainWorldContentScriptEntrypointOptions.allFrames

Source

src/types/index.ts:493


cssInjectionMode

cssInjectionMode?: PerBrowserOption<"ui" | "manifest" | "manual">

Customize how imported/generated styles are injected with the content script. Regardless of the mode selected, CSS will always be built and included in the output directory.

  • "manifest" - Include the CSS in the manifest, under the content script's css array.
  • "manual" - Exclude the CSS from the manifest. You are responsible for manually loading it onto the page. Use browser.runtime.getURL("content-scripts/<name>.css") to get the file's URL
  • "ui" - Exclude the CSS from the manifest. CSS will be automatically added to your UI when calling createShadowRootUi

Default

ts
"manifest"

Inherited from

MainWorldContentScriptEntrypointOptions.cssInjectionMode

Source

src/types/index.ts:512


exclude

exclude?: string[]

List of target browsers to exclude this entrypoint from. Cannot be used with include. You must choose one of the two options.

Default

ts
undefined

Inherited from

MainWorldContentScriptEntrypointOptions.exclude

Source

src/types/index.ts:443


excludeGlobs

excludeGlobs?: PerBrowserOption<undefined | string[]>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
[]

Inherited from

MainWorldContentScriptEntrypointOptions.excludeGlobs

Source

src/types/index.ts:488


excludeMatches

excludeMatches?: PerBrowserOption<undefined | string[]>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
[]

Inherited from

MainWorldContentScriptEntrypointOptions.excludeMatches

Source

src/types/index.ts:478


include

include?: string[]

List of target browsers to include this entrypoint in. Defaults to being included in all builds. Cannot be used with exclude. You must choose one of the two options.

Default

ts
undefined

Inherited from

MainWorldContentScriptEntrypointOptions.include

Source

src/types/index.ts:436


includeGlobs

includeGlobs?: PerBrowserOption<undefined | string[]>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
[]

Inherited from

MainWorldContentScriptEntrypointOptions.includeGlobs

Source

src/types/index.ts:483


matchAboutBlank

matchAboutBlank?: PerBrowserOption<undefined | boolean>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
false

Inherited from

MainWorldContentScriptEntrypointOptions.matchAboutBlank

Source

src/types/index.ts:471


matchOriginAsFallback

matchOriginAsFallback?: PerBrowserOption<boolean>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
false

Inherited from

MainWorldContentScriptEntrypointOptions.matchOriginAsFallback

Source

src/types/index.ts:498


matches

matches: PerBrowserOption<string[]>

Inherited from

MainWorldContentScriptEntrypointOptions.matches

Source

src/types/index.ts:461


registration

registration?: PerBrowserOption<"manifest" | "runtime">

Specify how the content script is registered.

  • "manifest": The content script will be added to the content_scripts entry in the manifest. This is the normal and most well known way of registering a content script.
  • "runtime": The content script's matches is added to host_permissions and you are responsible for using the scripting API to register the content script dynamically at runtime.

Default

ts
"manifest"

Inherited from

MainWorldContentScriptEntrypointOptions.registration

Source

src/types/index.ts:524


runAt

runAt?: PerBrowserOption<undefined | RunAt>

See https://developer.chrome.com/docs/extensions/mv3/content_scripts/

Default

ts
"documentIdle"

Inherited from

MainWorldContentScriptEntrypointOptions.runAt

Source

src/types/index.ts:466


world

world: "MAIN"

See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world

Inherited from

MainWorldContentScriptEntrypointOptions.world

Source

src/types/index.ts:532

Methods

main()

main(): void | Promise<void>

Main function executed when the content script is loaded.

Source

src/types/index.ts:671


Generated using typedoc-plugin-markdown and TypeDoc