### runtime.onStartup Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/runtime.md Fired when a profile that has this extension installed first starts up. This event is not fired for incognito profiles. ```APIDOC ## runtime.onStartup ### Description Fired when a profile that has this extension installed first starts up. This event is not fired for incognito profiles. ### Parameters #### addListener - `listener` (function) - A function that will be called when this event occurs. ``` -------------------------------- ### runtime.onInstalled.addListener Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/runtime.md Fired when the extension is first installed, updated, or when a shared module is updated. The listener receives a details object containing information about the installation event. ```APIDOC ## runtime.onInstalled.addListener(listener) ### Description A function that will be called when the onInstalled event occurs. ### Parameters #### listener(details) - **details** (object) - An object containing details about the installation event. - **reason** ([OnInstalledReason](#runtime-on-installed-reason)) - The reason that this event is being dispatched. - **temporary** (boolean) - Indicates whether the addon is installed as a temporary extension. [Added in TB 55] - **id** (string, optional) - Indicates the ID of the imported shared module extension which updated. This is present only if ‘reason’ is ‘shared_module_update’. **Unsupported.** - **previousVersion** (string, optional) - Indicates the previous version of the extension, which has just been updated. This is present only if ‘reason’ is ‘update’. [Added in TB 55] ``` -------------------------------- ### management.getAll() Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/management.md Retrieves a list of information about all installed extensions. ```APIDOC ## GET management.getAll() ### Description Returns a list of information about installed extensions. ### Method GET ### Endpoint management.getAll() ### Response #### Success Response (200) - **array of ExtensionInfo** - A list containing information about each installed extension. ### Required Permissions - management ``` -------------------------------- ### management.install(options) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/management.md Installs and enables a theme extension from a given URL. ```APIDOC ## POST management.install(options) ### Description Installs and enables a theme extension from the given URL. The installable file must be a theme. ### Method POST ### Endpoint management.install(options) ### Parameters #### Request Body - **options** (object) - Required - An object containing installation options. - **url** (HttpURL) - Required - URL pointing to the theme XPI file. - **hash** (string, optional) - A hash of the XPI file (sha256 or stronger). ### Response #### Success Response (200) - **id** (ExtensionID) - The ID of the installed theme. ### Required Permissions - management ``` -------------------------------- ### runtime.onUpdateAvailable Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/runtime.md 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 [reload()](#runtime-reload). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call [reload()](#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 [reload()](#runtime-reload) is called in response to this event. ```APIDOC ## runtime.onUpdateAvailable ### Description 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 [reload()](#runtime-reload). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call [reload()](#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 [reload()](#runtime-reload) is called in response to this event. ### Parameters #### addListener - `listener` (function) - A function that will be called when this event occurs. ### listener(details) #### Parameters - `details` (object) - The manifest details of the available update. - `version` (string) - The version of the update. ``` -------------------------------- ### ExtensionInstallType Enum Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/management.md Defines the possible ways an extension can be installed. ```APIDOC ## ExtensionInstallType Enum How the extension was installed. ### Values - **admin**: The extension was installed by policy. - **development**: The extension was loaded unpacked in developer mode. - **normal**: The extension was installed normally via an .xpi file. - **other**: The extension was installed by other means. - **sideload**: The extension was installed by other software on the machine. ``` -------------------------------- ### getAll Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/windows.md Gets all windows. Optionally accepts a getInfo parameter to specify details to retrieve. ```APIDOC ## getAll([getInfo]) Gets all windows. ### Parameters * **getInfo** (`GetInfo`, optional) - Specifies details to retrieve for each window. ### Returns * `Promise>` - A promise that resolves to an array of Window objects. ``` -------------------------------- ### list(folder, [options]) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/messages.md Gets all messages in a folder. ```APIDOC ## list(folder, [options]) ### Description Gets all messages in a folder. ### Parameters #### folder - **folder** (MailFolder or MailFolderId) - Required - The folder to retrieve messages from. #### options - **options** (object, optional) - Optional parameters for listing messages. ``` -------------------------------- ### Reading the resistFingerprinting setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/privacy.websites.resistFingerprinting.md This example demonstrates how to retrieve the current value of the resistFingerprinting setting. ```APIDOC ## Reading the resistFingerprinting setting ### Description Retrieves the current value of the resistFingerprinting setting. ### Method `messenger.privacy.websites.resistFingerprinting.get(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Specifies which setting to consider. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default false). ### Request Example ```javascript let { value } = await messenger.privacy.websites.resistFingerprinting.get({}); ``` ### Response #### Success Response (200) - **value** (any) - The value of the setting. - **levelOfControl** (LevelOfControl) - The level of control of the setting. #### Response Example ```json { "value": true, "levelOfControl": "controlled_by_this_extension" } ``` ``` -------------------------------- ### launchWebAuthFlow Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/identity.md Starts an authentication flow at the specified URL. This method requires the 'identity' permission. ```APIDOC ## launchWebAuthFlow(details) ### Description Starts an auth flow at the specified URL. ### Parameters #### details (object) - **url** (HttpURL) - Required - The URL to start the authentication flow. - **interactive** (boolean, optional) - Whether the flow should be interactive. ### Return type Promise ### Required permissions - identity ``` -------------------------------- ### Updating the useWebRenderCompositor setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.colorManagement.useWebRenderCompositor.md This example shows how to change the value of the useWebRenderCompositor setting. ```APIDOC ## Updating the useWebRenderCompositor setting ### Description Updates the `useWebRenderCompositor` setting to a new value. ### Method `messenger.browserSettings.colorManagement.useWebRenderCompositor.set(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Specifies the new value for the setting. - **value** (boolean) - Required - The new value to set for the `useWebRenderCompositor` setting. ### Request Example ```javascript await messenger.browserSettings.colorManagement.useWebRenderCompositor.set({ value: }); ``` ### Response #### Success Response (200) No specific response body is detailed, indicating a successful operation. #### Response Example None provided. ``` -------------------------------- ### Reading the useDocumentFonts setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.useDocumentFonts.md This example demonstrates how to retrieve the current value of the useDocumentFonts setting. ```APIDOC ## get(details) ### Description Gets the value of a setting. ### Method `messenger.browserSettings.useDocumentFonts.get` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Which setting to consider. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default false). ### Response #### Success Response (200) - **levelOfControl** ([LevelOfControl]) - The level of control of the setting. - **value** (any) - The value of the setting. ### Request Example ```javascript let { value } = await messenger.browserSettings.useDocumentFonts.get({}); ``` ### Response Example ```json { "levelOfControl": "user", "value": true } ``` ``` -------------------------------- ### Updating the resistFingerprinting setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/privacy.websites.resistFingerprinting.md This example shows how to update the resistFingerprinting setting to a new value. ```APIDOC ## Updating the resistFingerprinting setting ### Description Updates the resistFingerprinting setting to a new value. ### Method `messenger.privacy.websites.resistFingerprinting.set(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Specifies the new value for the setting. - **value** (boolean) - Required - The new value for the resistFingerprinting setting. - **incognito** (boolean, optional) - Whether to set the value for the incognito session (default false). ### Request Example ```javascript await messenger.privacy.websites.resistFingerprinting.set({ value: }); ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### urlPrefix Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/webNavigation.md Matches if the URL (without fragment identifier) starts with a specified string. ```APIDOC ## urlPrefix ### Description Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. ### Parameters #### Query Parameters - **urlPrefix** (string) - Optional - The string the URL must start with. ``` -------------------------------- ### query([queryInfo]) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/folders.md Gets folders that match the specified properties, or all folders if no properties are specified. ```APIDOC ## query([queryInfo]) ### Description Gets folders that match the specified properties, or all folders if no properties are specified. ### Parameters #### Query Parameters - **queryInfo** (object, optional) - An object containing properties to filter folders by. - **accountId** ([MailAccountId](accounts.md#id4), optional) - Limits the search to folders of the account with the specified id. - **canAddMessages** (boolean, optional) - Whether the folder supports adding new messages, or not. - **canAddSubfolders** (boolean, optional) - Whether the folder supports adding new subfolders, or not. - **canBeDeleted** (boolean, optional) - Whether the folder can be deleted, or not. - **canBeRenamed** (boolean, optional) - Whether the folder can be renamed, or not. - **canDeleteMessages** (boolean, optional) - Whether the folder supports deleting messages, or not. - **folderId** ([MailFolderId](#id12), optional) - Limits the search to the folder with the specified id. - **hasMessages** (boolean or [QueryRange](#folders-query-range), optional) - Whether the folder (excluding subfolders) contains messages, or not. Supports to specify a [QueryRange](#folders-query-range) (min/max) instead of a simple boolean value (none/some). - **hasNewMessages** (boolean or [QueryRange](#folders-query-range), optional) - Whether the folder (excluding subfolders) contains new messages, or not. Supports to specify a [QueryRange](#folders-query-range) (min/max) instead of a simple boolean value (none/some). - **hasSubFolders** (boolean, optional) - Whether the folder has subfolders, or not. ``` -------------------------------- ### Updating the useDocumentFonts setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.useDocumentFonts.md This example shows how to change the useDocumentFonts setting to a new value. ```APIDOC ## set(details) ### Description Sets the value of a setting. ### Method `messenger.browserSettings.useDocumentFonts.set` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Which setting to consider. - **value** (any) - Required - The new value for the setting. - **incognito** (boolean, optional) - Whether to set the value for the incognito session (default false). ### Request Example ```javascript await messenger.browserSettings.useDocumentFonts.set({ value: }); ``` ``` -------------------------------- ### Updating the zoomSiteSpecific setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.zoomSiteSpecific.md This example shows how to update the zoomSiteSpecific setting to a new value. ```APIDOC ## Updating the zoomSiteSpecific setting ### Description Sets the `zoomSiteSpecific` setting to a new value. ### Method `messenger.browserSettings.zoomSiteSpecific.set(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required. Contains the new value for the setting. - **value** (any) - Required. The new value to set for the `zoomSiteSpecific` setting. ### Request Example ```javascript await messenger.browserSettings.zoomSiteSpecific.set({ value: }); ``` ### Response #### Success Response (200) No specific response body is detailed, typically indicates success. #### Response Example (No example provided in source) ``` -------------------------------- ### Reading the overrideContentColorScheme setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.overrideContentColorScheme.md This example demonstrates how to retrieve the current value of the overrideContentColorScheme setting. ```APIDOC ## get(details) ### Description Gets the value of a setting. ### Method `messenger.browserSettings.overrideContentColorScheme.get(details)` ### Parameters #### Request Body - **details** (object) - Required - Which setting to consider. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default false). ### Response #### Success Response (200) - **levelOfControl** (LevelOfControl) - The level of control of the setting. - **value** (any) - The value of the setting. ### Request Example ```javascript let { value } = await messenger.browserSettings.overrideContentColorScheme.get({}); ``` ``` -------------------------------- ### Reading the networkPredictionEnabled setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/privacy.network.networkPredictionEnabled.md This example demonstrates how to retrieve the current value of the networkPredictionEnabled setting. ```APIDOC ## Reading the networkPredictionEnabled setting ### Description Retrieves the current value of the `networkPredictionEnabled` setting. ### Method `messenger.privacy.network.networkPredictionEnabled.get(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Specifies which setting to consider. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default false). ### Request Example ```javascript let { value } = await messenger.privacy.network.networkPredictionEnabled.get({}); ``` ### Response #### Success Response (200) - **value** (any) - The value of the setting. - **levelOfControl** ([LevelOfControl](#privacy-network-network-prediction-enabled-level-of-control)) - The level of control of the setting. #### Response Example ```json { "value": true, "levelOfControl": "user_provided" } ``` ``` -------------------------------- ### Reading the openSearchResultsInNewTabs setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.openSearchResultsInNewTabs.md This example demonstrates how to retrieve the current value of the openSearchResultsInNewTabs setting. ```APIDOC ## Reading the openSearchResultsInNewTabs setting ### Description Retrieves the current value of the `openSearchResultsInNewTabs` setting. ### Method `messenger.browserSettings.openSearchResultsInNewTabs.get(details)` ### Parameters #### Details Object - `details` (object) - Specifies which setting to consider. This object can contain: - `incognito` (boolean, optional): If true, returns the value for the incognito session. Defaults to false. ### Return Type Promise ### Response An object containing: - `value` (boolean): The current value of the setting. - `levelOfControl` (SettingLevelOfControl): The level of control for the setting. ``` -------------------------------- ### windows.create Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/windows.md Creates a new window with specified properties. Supports setting dimensions, position, state, and content URL. ```APIDOC ## windows.create ### Description Creates a new window with specified properties. ### Parameters #### Path Parameters - **height** (integer, optional) - The height in pixels of the new window, including the frame. Defaults to a natural height. - **incognito** (boolean, optional) - Unsupported. - **left** (integer, optional) - The number of pixels to position the new window from the left edge of the screen. Defaults to an offset from the last focused window. - **linkHandler** (string, optional) - Specifies how to handle hyperlinks. Supported values: balanced, relaxed, strict. - **state** (WindowState, optional) - The initial state of the window (e.g., minimized, maximized). - **tabId** (integer, optional) - The id of the tab to adopt into the new window. - **titlePreface** (string, optional) - A string to add to the beginning of the window title. - **top** (integer, optional) - The number of pixels to position the new window from the top edge of the screen. Defaults to an offset from the last focused window. - **type** (CreateType, optional) - Specifies the type of window to create (e.g., popup). Thunderbird interprets panel and detached_panel as popup. - **url** (string or array of string, optional) - A URL to be opened in a popup window. Defaults to the New Tab Page. ### Returns - **Promise** - Resolves with the created [Window](#windows-window) object. ``` -------------------------------- ### Interacting with Folder and Message Managers Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/guides/experiments.md Use folderManager and messageManager from context.extension to interact with MailFolder, MessageHeader, and MessageList objects. These managers provide methods to get, convert, and start lists of these objects. ```javascript // Get an nsIMsgFolder from a MailFolder: let realFolder = context.extension.folderManager.get(accountId, path); // Get a MailFolder from an nsIMsgFolder: context.extension.folderManager.convert(realFolder); // Get an nsIMsgDBHdr from a MessageHeader: let realMessage = context.extension.messageManager.get(messageId); // Get a MessageHeader from an nsIMsgDBHdr: context.extension.messageManager.convert(realMessage); // Start a MessageList from an array or enumerator of nsIMsgDBHdr: context.extension.messageManager.startMessageList(realFolder.messages); ``` -------------------------------- ### Working with WebExtension Events (Event Listener Guide) Source: https://context7.com/thunderbird/webext-docs/llms.txt Explains how to use `addListener`, `removeListener`, and `hasListener` for WebExtension events. Covers events with extra parameters and blocking events that can modify or cancel actions. ```APIDOC ## Working with WebExtension Events (Event Listener Guide) All WebExtension event objects expose `addListener`, `removeListener`, and `hasListener`. Some events accept extra parameters for fine-grained control (e.g., `onNewMailReceived` accepts `monitorAllFolders`). Blocking events like `onBeforeSend` can return values to cancel or modify the action. ### Named listener ```javascript // Named listener (can be removed later) async function onMenuClick(info, tab) { console.log(`Menu item ${info.menuItemId} clicked in tab ${tab.id}`); } messenger.menus.onClicked.addListener(onMenuClick); // Remove later: messenger.menus.onClicked.removeListener(onMenuClick); ``` ### Arrow function listener ```javascript // Arrow function listener (cannot be removed without a reference) messenger.messages.onUpdated.addListener((msg, changed) => { if (changed.flagged) console.log(`Message flagged: ${msg.subject}`); }); ``` ### Event with extra listener parameter ```javascript messenger.messages.onNewMailReceived.addListener( (folder, messages) => { console.log(`New mail: ${messages.messages.length} in ${folder.path}`); }, /* monitorAllFolders = */ true ); ``` ### Blocking event — intercept and modify/cancel ```javascript messenger.compose.onBeforeSend.addListener((tab, details) => { if (!details.subject) { // Cancel the send if subject is empty return { cancel: true }; } // Add a BCC silently return { details: { bcc: [...(details.bcc ?? []), "bcc@example.com"] } }; }); ``` ``` -------------------------------- ### runtime.onSuspend Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/runtime.md 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. ```APIDOC ## runtime.onSuspend ### Description 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. #### NOTE This event does not fire until Thunderbird 106, when event pages are available. ### Parameters #### addListener - `listener` (function) - A function that will be called when this event occurs. ``` -------------------------------- ### onInstalled Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/management.md Fired when an addon has been installed. Before version 56, only extensions whose type is ‘theme’ are supported. ```APIDOC ## onInstalled ### Description Fired when an addon has been installed. #### NOTE Before version 56, only extensions whose type is ‘theme’ are supported. ### Parameters for onInstalled.addListener(listener) - **listener(info)** ([ExtensionInfo](#management-extension-info)) - A function that will be called when this event occurs. Parameters passed to the listener function - **info** ([ExtensionInfo](#management-extension-info)) - Information about the installed add-on. ``` -------------------------------- ### get Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/addressBooks.md Gets a single address book, optionally including all contacts and mailing lists. ```APIDOC ## get(id, [complete]) ### Description Gets a single address book, optionally including all contacts and mailing lists. ### Parameters #### Path Parameters - **id** (string) - Required - The id of the address book to retrieve. #### Query Parameters - **complete** (boolean, optional) - If set to true, results will include contacts and mailing lists for this address book. ### Permissions - addressBooks ### Returns - **AddressBookNode** - [Added in TB 89] ### Method `messenger.addressBooks.get(id, complete)` ``` -------------------------------- ### Get Third Party Cookies Allowed Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/privacy.websites.thirdPartyCookiesAllowed.md Retrieves the current value of the third-party cookies allowed setting. The `incognitoSpecific` property is only present if the incognito property was true in the get() details. ```APIDOC ## get() ### Description Retrieves the current value of the third-party cookies allowed setting. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **value** (any) - The current value of the setting. - **incognitoSpecific** (boolean, optional) - Whether the value is specific to the incognito session. Only present if incognito was true in the get() details. #### Response Example ```json { "value": true, "incognitoSpecific": false } ``` ``` -------------------------------- ### windows.create Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/windows.md Creates a new window with optional sizing, position, or default URL. Handles same-site and other link behaviors differently for popup windows. ```APIDOC ## windows.create([createData]) ### Description Creates (opens) a new window with any optional sizing, position or default URL provided. When loading a page into a popup window, same-site links are opened within the same window, all other links are opened in the user’s default browser. To override this behavior, add-ons have to register a [content script](https://bugzilla.mozilla.org/show_bug.cgi?id=1618828#c3), capture click events and handle them manually. Same-site links with targets other than \_self are opened in a new tab in the most recent normal Thunderbird window. ### Parameters #### createData [`createData`] (object, optional) - **allowScriptsToClose** (`boolean`, optional) - Allow scripts running inside the window to close the window by calling window.close(). Defaults to true when the given URL points to an extension page (a page included with this extension and loaded with the moz-extension: protocol), defaults to false otherwise. - **cookieStoreId** (`string`, optional) - The [CookieStore](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contextualIdentities/ContextualIdentity#cookiestoreid) id which all initially opened tabs should use. Either a custom id created using the [contextualIdentities API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contextualIdentities), or a built-in one: firefox-default, firefox-container-1, firefox-container-2, firefox-container-3, firefox-container-4, firefox-container-5. NOTE: The naming pattern of the built-in cookie stores was deliberately not changed for Thunderbird, but kept for compatibility reasons. NOTE: The cookies permission is required to be able to specify this property. Furthermore, the contextualIdentities permission should be requested, to enable the contextual identities feature (enabled by default only on Thunderbird Daily). - **focused** (`boolean`, optional) - **Unsupported.** If true, opens an active window. If false, opens an inactive window. - **height** (`integer`, optional) - The height of the window, in pixels. - **incognito** (`boolean`, optional) - If true, creates the window in incognito mode. Defaults to false. - **left** (`integer`, optional) - The distance from the left edge of the screen to the left edge of the window, in pixels. - ** பின்னணி** (`boolean`, optional) - If true, the window is created in the background, so the user is not immediately focused on it. Defaults to false. - **top** (`integer`, optional) - The distance from the top edge of the screen to the top edge of the window, in pixels. - **url** (`string` or `array` of `string`, optional) - A URL or array of URLs to load into the window. If empty, an empty window is created. - **width** (`integer`, optional) - The width of the window, in pixels. ``` -------------------------------- ### Interacting with Tab and Window Managers Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/guides/experiments.md Access tabs and windows using tabManager and windowManager from context.extension. These managers allow getting native tab/window objects from IDs, getting IDs from native objects, and querying or listing them. ```javascript // Get a real tab from a tab ID: let tabObject = context.extension.tabManager.get(tabId); let realTab = tabObject.nativeTab; let realTabWindow = tabObject.window; // Get a tab ID from a real tab: context.extension.tabManager.getWrapper(realTab).id; // Query tabs: (note this returns a Generator, not an array like the API) context.extension.tabManager.query(queryInfo); ``` ```javascript // Get a real window from a window ID: let windowObject = context.extension.windowManager.get(windowId); let realWindow = windowObject.window; // Get a window ID from a real window: context.extension.windowManager.getWrapper(realWindow).id; // Get all windows: (note this returns a Generator, not an array like the API) context.extension.windowManager.getAll(); ``` -------------------------------- ### Working with Message Lists (Pagination Guide) Source: https://context7.com/thunderbird/webext-docs/llms.txt Demonstrates how to paginate through message lists using `messages.list()` and `messages.continueList()`, including patterns for simple while-loops, async generators, and aborting ongoing queries. ```APIDOC ## Working with Message Lists (Pagination Guide) Message list responses from `messages.list()` and `messages.query()` are paginated into `MessageList` objects with an `id` and `messages` array. Always iterate pages using `continueList`; never assume a fixed page size. ### Pattern 1: Simple while-loop pagination ```javascript // manifest.json permissions: ["accountsRead", "messagesRead"] const folder = (await messenger.folders.query({ specialUse: ["inbox"] }))[0]; let page = await messenger.messages.list(folder); const allMessages = []; allMessages.push(...page.messages); while (page.id) { page = await messenger.messages.continueList(page.id); allMessages.push(...page.messages); } console.log(`Total messages: ${allMessages.length}`); ``` ### Pattern 2: Async generator ```javascript async function* iterateMessages(folder) { let page = await messenger.messages.list(folder); for (const msg of page.messages) yield msg; while (page.id) { page = await messenger.messages.continueList(page.id); for (const msg of page.messages) yield msg; } } for await (const msg of iterateMessages(folder)) { if (msg.subject?.includes("STOP")) break; // early exit is safe } ``` ### Pattern 3: Early-abort an ongoing query ```javascript const listId = await messenger.messages.query({ fullText: "invoice", returnMessageListId: true, autoPaginationTimeout: 500 // return partial pages after 500 ms }); // Abort before full completion if user cancels await messenger.messages.abortList(listId); ``` ``` -------------------------------- ### get(messageId) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/messages.md Returns the specified message. ```APIDOC ## get(messageId) ### Description Returns the specified message. ### Parameters #### Path Parameters - **messageId** ([MessageId](#messages-message-id)) - Required ### Return Type [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) ``` -------------------------------- ### Reading the useWebRenderCompositor setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.colorManagement.useWebRenderCompositor.md This example demonstrates how to retrieve the current value of the useWebRenderCompositor setting. ```APIDOC ## Reading the useWebRenderCompositor setting ### Description Retrieves the current value of the `useWebRenderCompositor` setting. ### Method `messenger.browserSettings.colorManagement.useWebRenderCompositor.get(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Specifies which setting to consider. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default: false). ### Request Example ```javascript let { value } = await messenger.browserSettings.colorManagement.useWebRenderCompositor.get({}); ``` ### Response #### Success Response (200) - **value** (boolean) - The current value of the setting. - **levelOfControl** ([LevelOfControl](#browser-settings-color-management-use-web-render-compositor-level-of-control)) - The level of control of the setting. #### Response Example ```json { "value": true, "levelOfControl": "user" } ``` ``` -------------------------------- ### getTitle(details) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/messageDisplayAction.md Gets the title of the messageDisplayAction button. ```APIDOC ## getTitle(details) ### Description Gets the title of the messageDisplayAction button. ### Parameters #### details (object) - **tabId** (integer, optional) - Specifies for which tab the title should be retrieved. If no tab is specified, the global value is retrieved. - **windowId** (integer, optional) **Unsupported.** - Will throw an error if used. ### Return type Promise ``` -------------------------------- ### IconPath Dictionary Example Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserAction.md Specify paths for multiple icons in different sizes to avoid scaling. Each entry maps a size to its icon file path. ```JSON { "16": "icon16.png", "32": "icon32.png" } ``` -------------------------------- ### getFolderCapabilities(folder) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/folders.md Get capability information about a folder. ```APIDOC ## getFolderCapabilities(folder) ### Description Get capability information about a folder. ### Parameters #### Path Parameters - **folder** (MailFolder or MailFolderId) - Required - The folder to get capabilities for. ``` -------------------------------- ### installModule(name, [flags]) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/pkcs11.md Installs a PKCS#11 module identified by its name. An optional flags parameter can be provided. ```APIDOC ## Function: installModule(name, [flags]) ### Description Install a PKCS#11 module with a given name. ### Parameters #### Path Parameters - **name** (string) - Required - The name of the module to install. - **flags** (integer) - Optional - Flags to control the installation behavior. ### Required Permissions - pkcs11 ``` -------------------------------- ### get Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/mailingLists.md Retrieves a single mailing list by its ID. ```APIDOC ## get(id) ### Description Gets a single mailing list. ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the mailing list to retrieve. ### Return Type Promise - An object representing the mailing list. [Added in TB 96] ### Required Permissions - addressBooks ``` -------------------------------- ### beginNew Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/compose.md Opens a new message compose window. ```APIDOC ## beginNew([messageId], [details]) ### Description Open a new message compose window. ### Parameters #### Path Parameters - **messageId** ([MessageId](messages.md#messages-message-id)) - Optional - The ID of a message to pre-fill the compose window with. - **details** ([ComposeDetails](#compose-compose-details), optional) - Additional details for composing the message. ### Return type [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to [Tab](tabs.md#tabs-tab). ### Permissions - compose ``` -------------------------------- ### getTitle(details) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/composeAction.md Gets the title of the composeAction button. ```APIDOC ## getTitle(details) ### Description Gets the title of the composeAction button. ### Parameters #### details (object) - **tabId** (integer, optional) - Specifies for which tab the title should be retrieved. If no tab is specified, the global value is retrieved. - **windowId** (integer, optional) - **Unsupported.** Will throw an error if used. ### Returns - **Promise** which resolves to a string representing the title. ``` -------------------------------- ### commands.openShortcutSettings() Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/commands.md Opens the dedicated page in Thunderbird's settings for configuring extension shortcuts. ```APIDOC ## commands.openShortcutSettings() ### Description Opens the extension shortcuts configuration page. ### Endpoint `messenger.commands.openShortcutSettings()` ``` -------------------------------- ### getAll() Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/alarms.md Gets an array of all the alarms that are currently set. ```APIDOC ## getAll() ### Description Gets an array of all the alarms. ### Method ```javascript Promise ``` ### Returns An array of Alarm objects. ``` -------------------------------- ### Reading the closeTabsByDoubleClick setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.closeTabsByDoubleClick.md This example demonstrates how to retrieve the current value of the closeTabsByDoubleClick setting. ```APIDOC ## Reading the closeTabsByDoubleClick setting ### Description Retrieves the current value of the `closeTabsByDoubleClick` setting. ### Method `messenger.browserSettings.closeTabsByDoubleClick.get(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Specifies which setting to retrieve. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default false). ### Request Example ```javascript let { value } = await messenger.browserSettings.closeTabsByDoubleClick.get({}); ``` ### Response #### Success Response (200) - **value** (boolean) - The current value of the setting. - **levelOfControl** (SettingLevelOfControl) - The level of control of the setting. #### Response Example ```json { "value": true, "levelOfControl": "not_controllable" } ``` ``` -------------------------------- ### Get Full MIME Message with messenger.messages.getFull Source: https://context7.com/thunderbird/webext-docs/llms.txt Retrieves the complete MIME structure of a message, including headers, body parts, and attachments. Supports decryption and decoding options. Requires `messagesRead` permission. Also shows how to get only headers using `getHeaders`. ```javascript // manifest.json permissions: ["messagesRead"] const full = await messenger.messages.getFull(messageId, { decrypt: true, decodeHeaders: true, decodeContent: true }); // Walk the MIME tree function walkParts(part, depth = 0) { const indent = " ".repeat(depth); console.log(`${indent}[${part.contentType}] partName=${part.partName}`); if (part.body) console.log(`${indent} body length: ${part.body.length}`); for (const child of part.parts ?? []) walkParts(child, depth + 1); } walkParts(full); // Check decryption status console.log("Decryption status:", full.decryptionStatus); // "none" | "success" | "fail" | "skipped" // Get raw message headers quickly (faster than getFull when only headers needed) const headers = await messenger.messages.getHeaders(messageId); console.log("X-Mailer:", headers["x-mailer"]?.[0]); ``` -------------------------------- ### Reading the zoomSiteSpecific setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.zoomSiteSpecific.md This example demonstrates how to retrieve the current value of the zoomSiteSpecific setting. ```APIDOC ## Reading the zoomSiteSpecific setting ### Description Retrieves the current value of the `zoomSiteSpecific` setting. ### Method `messenger.browserSettings.zoomSiteSpecific.get(details)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Optional. Specifies which setting to consider. - **incognito** (boolean, optional) - Whether to return the value that applies to the incognito session (default: false). ### Request Example ```javascript let { value } = await messenger.browserSettings.zoomSiteSpecific.get({}); ``` ### Response #### Success Response (200) - **value** (any) - The value of the setting. - **levelOfControl** ([LevelOfControl](#browser-settings-zoom-site-specific-level-of-control)) - The level of control of the setting. #### Response Example ```json { "value": true, "levelOfControl": "user_provided" } ``` ``` -------------------------------- ### get Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/tabs.md Retrieves details about a specified tab using its ID. ```APIDOC ## get(tabId) ### Description Retrieves details about the specified tab. ### Parameters #### Path Parameters - **tabId** (integer) - The ID of the tab to retrieve. ### Return type [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) ### Returns [Tab](#tabs-tab) - Details of the specified tab. ``` -------------------------------- ### Reading the useNativeSRGB setting Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/browserSettings.colorManagement.useNativeSRGB.md This example demonstrates how to retrieve the current value of the useNativeSRGB setting. ```APIDOC ## Reading the useNativeSRGB setting ### Description Retrieves the current value of the `useNativeSRGB` setting. ### Method `messenger.browserSettings.colorManagement.useNativeSRGB.get(details)` ### Parameters #### Details - `details` (object) - Required - Specifies which setting to consider. - `incognito` (boolean, optional) - Whether to return the value that applies to the incognito session (default: false). ### Returns - `Promise` - A promise that resolves to an object containing the setting's details. - `levelOfControl` (LevelOfControl) - The level of control of the setting. - `value` (any) - The value of the setting. ### Request Example ```javascript let { value } = await messenger.browserSettings.colorManagement.useNativeSRGB.get({}); ``` ``` -------------------------------- ### Get webRTCIPHandlingPolicy Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/privacy.network.webRTCIPHandlingPolicy.md Retrieves the current value of the webRTCIPHandlingPolicy setting. ```APIDOC ## get(details) ### Description Gets the value of a setting. ### Method `messenger.privacy.network.webRTCIPHandlingPolicy.get` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **details** (object) - Required - Which setting to consider. - **incognito** (boolean) - Optional - Whether to return the value that applies to the incognito session (default false). ### Response #### Success Response (200) - **levelOfControl** (LevelOfControl) - The level of control of the setting. - **value** (IPHandlingPolicy) - The current value of the setting. ### Request Example ```javascript let { value } = await messenger.privacy.network.webRTCIPHandlingPolicy.get({}); ``` ### Response Example ```json { "levelOfControl": "user_level", "value": "default" } ``` ``` -------------------------------- ### getAttachmentFile(id) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/compose.md Gets the content of a ComposeAttachment as a File object. ```APIDOC ## getAttachmentFile(id) ### Description Gets the content of a [ComposeAttachment](#compose-compose-attachment) as a [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object. ### Parameters #### Parameters - **id** (integer) - Required - The unique identifier for the attachment. ### Returns [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) returning [File](https://developer.mozilla.org/en-US/docs/Web/API/File) ``` -------------------------------- ### OnInstalledReason Enum Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/runtime.md Defines the possible reasons for the 'onInstalled' event to be dispatched. ```APIDOC ## OnInstalledReason Enum ### Description The reason that this event is being dispatched. ### Values - **browser_update**: The event is dispatched because the browser was updated. - **install**: The event is dispatched because the extension was installed. - **update**: The event is dispatched because the extension was updated. ``` -------------------------------- ### query Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/tabs.md Gets all tabs that have the specified properties, or all tabs if no properties are specified. ```APIDOC ## query([queryInfo]) ### Description Gets all tabs that have the specified properties, or all tabs if no properties are specified. ### Parameters #### Path Parameters - **queryInfo** (object, optional) - An object containing properties to filter tabs. - **active** (boolean, optional) - Whether the tabs are active in their windows. - **cookieStoreId** (array of string or string, optional) - The [CookieStore](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contextualIdentities/ContextualIdentity#cookiestoreid) id(s) used by the tabs. Either custom ids created using the [contextualIdentities API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contextualIdentities), or built-in ones: firefox-default, firefox-container-1, firefox-container-2, firefox-container-3, firefox-container-4, firefox-container-5. ### Return type [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) ``` -------------------------------- ### getFrameId(target) Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/runtime.md Get the frameId of any window global or frame element. ```APIDOC ## getFrameId(target) ### Description Get the frameId of any window global or frame element. ### Parameters #### Path Parameters - **target** (any) - Required - A WindowProxy or a Browsing Context container element (IFrame, Frame, Embed, Object) for the target frame. ### Return type [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) resolving to a number (the frameId, or -1 if it doesn’t exist). ``` -------------------------------- ### beginForward Source: https://github.com/thunderbird/webext-docs/blob/beta-mv2/compose.md Opens a new message compose window forwarding a given message. Requires the 'compose' permission. ```APIDOC ## beginForward(messageId, [forwardType], [details]) ### Description Open a new message compose window forwarding a given message. #### NOTE The compose format can be set by details.isPlainText or by specifying only one of details.body or details.plainTextBody. Otherwise the default compose format of the selected identity is used. If no identity is specified, this function is using the default identity and not the identity of the referenced message. ### Parameters #### Path Parameters - **messageId** ([MessageId](messages.md#messages-message-id)) - Required - The message to forward, as retrieved using other APIs. - **forwardType** (string, optional) - Supported values: `forwardAsAttachment`, `forwardInline`. - **details** ([ComposeDetails](#compose-compose-details), optional) - Additional details for composing the message. ### Return type [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to [Tab](tabs.md#tabs-tab). ### Permissions - compose ```