Skip to content

API > wxt/browser > WxtRuntime

Interface: WxtRuntime

Contents

Extends

  • Static

Properties

id

id: string

The ID of the extension/app.

Inherited from

Runtime.Static.id

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:480


lastError

lastError?: PropertyLastErrorType

This will be defined during an API method callback if there was an error Optional.

Inherited from

Runtime.Static.lastError

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:475


onConnect

onConnect: Event<(port) => void>

Fired when a connection is made from either an extension process or a content script.

Param

Inherited from

Runtime.Static.onConnect

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:430


onConnectExternal

onConnectExternal: Event<(port) => void>

Fired when a connection is made from another extension.

Param

Inherited from

Runtime.Static.onConnectExternal

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:437


onInstalled

onInstalled: Event<(details) => void>

Fired when the extension is first installed, when the extension is updated to a new version, and when the browser is updated to a new version.

Param

Inherited from

Runtime.Static.onInstalled

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:396


onMessage

onMessage: Event<(message, sender, sendResponse) => true | void | Promise<any>>

Fired when a message is sent from either an extension process or a content script.

Param

Optional. The message sent by the calling script.

Param

Param

Function to call (at most once) when you have a response. This is an alternative to returning a Promise. The argument should be any JSON-ifiable object. If you have more than one <code> onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code> sendResponse</code> is called).

Inherited from

Runtime.Static.onMessage

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:450


onMessageExternal

onMessageExternal: Event<(message, sender, sendResponse) => true | void | Promise<any>>

Fired when a message is sent from another extension/app. Cannot be used in a content script.

Param

Optional. The message sent by the calling script.

Param

Param

Function to call (at most once) when you have a response. This is an alternative to returning a Promise. The argument should be any JSON-ifiable object. If you have more than one <code> onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code> sendResponse</code> is called).

Inherited from

Runtime.Static.onMessageExternal

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:466


onStartup

onStartup: Event<() => void>

Fired when a profile that has this extension installed first starts up. This event is not fired for incognito profiles.

Inherited from

Runtime.Static.onStartup

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:388


onSuspend

onSuspend: Event<() => void>

Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded.

Inherited from

Runtime.Static.onSuspend

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:404


onSuspendCanceled

onSuspendCanceled: Event<() => void>

Sent after onSuspend to indicate that the app won't be unloaded after all.

Inherited from

Runtime.Static.onSuspendCanceled

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:409


onUpdateAvailable

onUpdateAvailable: Event<(details) => void>

Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call $(ref:runtime.reload). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call $(ref:runtime.reload) manually in response to this event the update will not get installed until the next time the browser itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if $(ref:runtime.reload) is called in response to this event.

Param

The manifest details of the available update.

Inherited from

Runtime.Static.onUpdateAvailable

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:423

Methods

connect()

connect(extensionId, connectInfo)

connect(extensionId?, connectInfo?): Port

Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and $(topic:manifest/externally_connectable)[web messaging]. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).

Parameters

extensionId?: string

Optional. The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for $(topic:manifest/externally_connectable)[web messaging].

connectInfo?: ConnectConnectInfoType

Optional.

Returns

Port through which messages can be sent and received. The port's $(ref:runtime.Port onDisconnect) event is fired if the extension/app does not exist.

Inherited from

Runtime.Static.connect

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:314

connect(connectInfo)

connect(connectInfo?): Port

Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and $(topic:manifest/externally_connectable)[web messaging]. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).

Parameters

connectInfo?: ConnectConnectInfoType

Optional.

Returns

Port through which messages can be sent and received. The port's $(ref:runtime.Port onDisconnect) event is fired if the extension/app does not exist.

Inherited from

Runtime.Static.connect

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:326


connectNative()

connectNative(application): Port

Connects to a native application in the host machine.

Parameters

application: string

The name of the registered application to connect to.

Returns

Port through which messages can be sent and received with the application

Inherited from

Runtime.Static.connectNative

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:334


getBackgroundPage()

getBackgroundPage(): Promise<Window>

Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set.

Inherited from

Runtime.Static.getBackgroundPage

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:247


getBrowserInfo()

getBrowserInfo(): Promise<BrowserInfo>

Returns information about the current browser.

Returns

Called with results

Inherited from

Runtime.Static.getBrowserInfo

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:376


getFrameId()

getFrameId(target): number

Get the frameId of any window global or frame element.

Parameters

target: any

A WindowProxy or a Browsing Context container element (IFrame, Frame, Embed, Object) for the target frame.

Returns

The frameId of the target frame, or -1 if it doesn't exist.

Inherited from

Runtime.Static.getFrameId

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:279


getManifest()

getManifest(): WebExtensionManifest

Returns details about the app or extension from the manifest. The object returned is a serialization of the full $(topic:manifest)[manifest file].

Returns

The manifest details.

Inherited from

Runtime.Static.getManifest

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:263


getPlatformInfo()

getPlatformInfo(): Promise<PlatformInfo>

Returns information about the current platform.

Returns

Called with results

Inherited from

Runtime.Static.getPlatformInfo

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:383


getURL()

getURL(path): string

Converts a relative path within an app/extension install directory to a fully-qualified URL.

Parameters

path: string

A path to a resource within an app/extension expressed relative to its install directory.

Returns

The fully-qualified URL to the resource.

Inherited from

Runtime.Static.getURL

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:271


openOptionsPage()

openOptionsPage(): Promise<void>

Open your Extension's options page, if possible.

The precise behavior may depend on your manifest's `` $(topic:optionsV2)[options_ui]`` or `` $(topic:options)[options_page]`` key, or what the browser happens to support at the time.

If your Extension does not declare an options page, or the browser failed to create one for some other reason, the callback will set $(ref:lastError).

Inherited from

Runtime.Static.openOptionsPage

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:255


reload()

reload(): void

Reloads the app or extension.

Inherited from

Runtime.Static.reload

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:294


requestUpdateCheck()

requestUpdateCheck(): Promise<[RequestUpdateCheckStatus, RequestUpdateCheckCallbackDetailsType]>

Requests an update check for this app/extension.

Inherited from

Runtime.Static.requestUpdateCheck

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:299


sendMessage()

sendMessage(extensionId, message, options)

sendMessage(extensionId, message, options?): Promise<any>

Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime. onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $(ref:tabs.sendMessage).

Parameters

extensionId: undefined | string

Optional. The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for $(topic:manifest/externally_connectable)[web messaging].

message: any

options?: SendMessageOptionsType

Optional.

Inherited from

Runtime.Static.sendMessage

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:349

sendMessage(message, options)

sendMessage(message, options?): Promise<any>

Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime. onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $(ref:tabs.sendMessage).

Parameters

message: any

options?: SendMessageOptionsType

Optional.

Inherited from

Runtime.Static.sendMessage

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:361


sendNativeMessage()

sendNativeMessage(application, message): Promise<any>

Send a single message to a native application.

Parameters

application: string

The name of the native messaging host.

message: any

The message that will be passed to the native messaging host.

Inherited from

Runtime.Static.sendNativeMessage

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:369


setUninstallURL()

setUninstallURL(url?): Promise<void>

Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics, and implement surveys. Maximum 1023 characters.

Parameters

url?: string

Optional. URL to be opened after the extension is uninstalled. This URL must have an http: or https: scheme. Set an empty string to not open a new tab upon uninstallation.

Returns

Called when the uninstall URL is set. If the given URL is invalid, $(ref:runtime.lastError) will be set.

Inherited from

Runtime.Static.setUninstallURL

Source

node_modules/.pnpm/@types+webextension-polyfill@0.10.7/node_modules/@types/webextension-polyfill/namespaces/runtime.d.ts:289


Generated using typedoc-plugin-markdown and TypeDoc