scripting.compose API

Permissions

The following permissions influence the behavior of the API. Depending on which permissions are requested, additional methods might be available, or certain data may be included in responses.

Hint

Request permissions only when needed. Unnecessary requests may result in rejection during ATN review.

compose

compose

Read and modify your email messages as you compose and send them.

Note

The permission compose is required to use messenger.scripting.compose.*.

Functions

getRegisteredScripts([filter])

– [Added in TB 128]

Returns all registered compose scripts for this extension that match the given filter.

Parameters

filter

[filter]

(ComposeScriptFilter, optional)

An object to filter the extension’s registered compose scripts.

Return type (Promise)

_returns

Required permissions

  • compose

registerScripts(scripts)

– [Added in TB 128]

Registers one or more compose scripts for this extension, which should be injected into the message compose editor.

Note

Registered scripts will only be applied to newly opened message compose tabs. To apply the script to already open message compose tabs, manually inject your script by calling executeScript(injection) for each of the open messageCompose tabs.

Parameters

scripts

scripts

Contains a list of compose scripts to be registered. If there are errors during script parsing/file validation, or if the IDs specified already exist, then no scripts are registered.

Required permissions

  • compose

unregisterScripts([filter])

– [Added in TB 128]

Unregisters one or more compose scripts for this extension.

Parameters

filter

[filter]

(ComposeScriptFilter, optional)

If specified, only unregisters compose scripts which match the filter. Otherwise, all of the extension’s compose scripts are unregistered.

Required permissions

  • compose

Types

ComposeScriptDetails

– [Added in TB 128]

object

id

id

(string)

The id of the compose script, specified in the API call.

css

[css]

(array of ExtensionURL, optional)

The list of CSS files to be injected. These are injected in the order they appear in this array.

js

[js]

(array of ExtensionURL, optional)

The list of JavaScript files to be injected. These are injected in the order they appear in this array.

runAt

[runAt]

(RunAt, optional)

Specifies when JavaScript files are injected. The preferred and default value is document_idle.

ComposeScriptFilter

– [Added in TB 128]

object

ids

[ids]

(array of string, optional)

The IDs of specific compose scripts to retrieve with getRegisteredScripts() or to unregister with unregisterScripts().

ExtensionURL

A path relative to the root of the extension.

string

RunAt

– [Added in TB 45]

The soonest that the JavaScript or CSS will be injected into the tab.

string

Supported values:

document_end

document_end

document_idle

document_idle

document_start

document_start