messageDisplayScripts API

The messageDisplayScripts API allows to register and unregister scripts for the message display window.

Manifest file properties

compose_scripts

[compose_scripts]

(array of ComposeScript, optional)

– [Added in TB 151]

Scripts and CSS to inject into compose windows.

message_display_scripts

[message_display_scripts]

(array of MessageDisplayScript, optional)

– [Added in TB 151]

Scripts and CSS to inject into message display pages.

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.

messagesModify

messagesModify

Read and modify your email messages as they are displayed to you.

Note

The permission messagesModify is required to use messenger.messageDisplayScripts.*.

Functions

register(messageDisplayScriptOptions)

– [Added in TB 82]

Register a message display script programmatically.

Note

Registered scripts will only be applied to newly opened messages. To apply the script to already open messages, manually inject your script by calling executeScript([tabId], details) for each of the open messageDisplay tabs.

Parameters

messageDisplayScriptOptions

messageDisplayScriptOptions

Required permissions

  • messagesModify

Types

ComposeScript

– [Added in TB 151]

A script and/or CSS to inject into compose windows via the manifest.

Note

The run_at option is not supported for compose scripts, because the compose editor does not load content in the same way as a regular web page.

object

css

[css]

(array of ExtensionURL, optional)

The list of CSS files to inject.

js

[js]

(array of ExtensionURL, optional)

The list of JavaScript files to inject.

ExtensionFileOrCode

Specify code, either by pointing to a file or by providing the code directly. Only one of the two is allowed.

object

file

file

A URL relative to the extension’s manifest.json file, and pointing to a JavaScript file to register.

or

object

code

code

(string)

A string of JavaScript code to register.

ExtensionURL

A path relative to the root of the extension.

string

MessageDisplayScript

– [Added in TB 151]

A script and/or CSS to inject into message display pages via the manifest.

object

css

[css]

(array of ExtensionURL, optional)

The list of CSS files to inject.

js

[js]

(array of ExtensionURL, optional)

The list of JavaScript files to inject.

run_at

[run_at]

(string, optional)

Determines when the files specified in css and js are injected. The states directly correspond to Document.readyState: loading, interactive and complete.

Supported values:

document_end

document_end

document_idle

document_idle

document_start

document_start

RegisteredMessageDisplayScript

– [Added in TB 82]

An object that represents a message display script registered programmatically

object

RegisteredMessageDisplayScriptOptions

– [Added in TB 82]

Details of a message display script registered programmatically

object

css

[css]

(array of ExtensionFileOrCode, optional)

The list of CSS files to inject

js

[js]

(array of ExtensionFileOrCode, optional)

The list of JavaScript files to inject

runAt

[runAt]

(string, optional)

– [Added in TB 126]

Determines when the files specified in css and js are injected. The states directly correspond to Document.readyState: loading, interactive and complete

Supported values:

document_end

document_end

Inject the script after the DOM is complete, but before subresources like images and frames have loaded.

document_idle

document_idle

Inject the script after the page is fully loaded. This is the default.

document_start

document_start

Inject the script after the document is created, but before any other content is loaded.