Changes in Thunderbird 78.4.0

compose

tabs

messageDisplay

See the documentation on those functions and events for more information.

messageDisplayScripts/tabs

  • Content script functions can now operate on a message display “tab” in the same way they do on a content tab in Thunderbird or Firefox. This requires the new “messagesModify” permission.

    Here are some basic examples. See the MDN documentation for a more in-depth explanation.

    // Where tabId is the id of a message display tab:
    
    browser.tabs.executeScript(tabId, {
      code: `document.body.textContent = "Hey look, the script ran!";`,
    });
    
    browser.tabs.executeScript(tabId, {
      file: "display.js",
    });
    
    browser.tabs.insertCSS(tabId, {
      code: "body { background-color: red; }",
    });
    
    browser.tabs.insertCSS(tabId, {
      file: "display.css",
    });
    
    browser.tabs.removeCSS(tabId, {
      code: "body { background-color: red; }",
    });
    
    browser.tabs.removeCSS(tabId, {
      file: "display.css",
    });
    
  • Scripts can also be registered to run automatically on messages being displayed, using the new messageDisplayScripts API.

    Again, this works just like the contentScripts API:

    let registeredScripts = await browser.messageDisplayScripts.register({
      css: [
        // Any number of code or file objects could be listed here.
        { code: "body { background-color: red; }" },
        { file: "display.css" },
      ],
      js: [
        // Any number of code or file objects could be listed here.
        { code: `document.body.textContent = "Hey look, the script ran!";` },
        { file: "display.js" },
      ],
    });
    

    Added code will run immediately and CSS will be immediately applied to already-open message display tabs or windows, and any new message display tabs or windows.

    The returned value, registeredScripts in this example, is an object with which you can unregister the code/CSS:

    await registeredScripts.unregister();
    

Note

This functionality does not permanently alter messages, only what the user sees when they are displayed.