Sunday, 5 January 2020

How to modify Thunderbird message display (extension)?

I'd like to write an extension for Thunderbird that modifies the message display (e.g. insert/replace text/markup/image).
Unfortunately, the documentation is lacking (due to recent changes?).

Some examples can be found at

Building on https://github.com/thundernest/sample-extensions/tree/master/messageDisplay

I've modified background.js

browser.messageDisplay.onMessageDisplayed.addListener((tabId, message) => {
  console.log(`Message displayed in tab ${tabId}: ${message.subject}`);
  console.log(message.id);
  browser.messages.getFull(message.id).then((messagepart) => {
      console.log(messagepart);
      body = messagepart['parts'][0]['parts'][0]['body'];
      console.log(body);
      body += "modified!";
      console.log(body);
  });
  browser.windows.getCurrent().then((window)=>{
    console.log(window.type);
  });

  browser.tabs.getCurrent().then((tab)=>{
    console.log("tab",tab);
  });
});

which gives me the message body (using magic indexes) but expectedly, the change is not reflected in the message display.
The window type returned is normal, not messageDisplay.
The tab is undefined despite adding permissions

  "permissions": [
    "messagesRead",
    "activeTab",
    "tabs",
    "tabHide"
  ],

but I assume that's because the script is running as background.

So I'd need a script running on the content / access to the tab and then some hints on how to modify the displayed message content (I do not want to modify the message).

Where would I find the equivalent documentation to

specific to Thunderbird?


Specifying content_scripts in manifest.json causes "Error: Error reloading addon messageDisplay@sample.extensions.thunderbird.net: undefined".

executeScript() from background does not seem to work either, even with tabId specified.



from How to modify Thunderbird message display (extension)?

No comments:

Post a Comment