Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ThunderBird Event for Viewing a Message

I'm trying to modify a message before it is displayed in the main window in Thunderbird. I can't seem to find 1) An event that will be triggered when a new message is opened/viewed 2) A way to modify the displayed contents of a message.

I believe I need the chrome://messenger/content/messenger.xul overlay, and can use a listener such as:

window.addEventListener( "SOME MAGIC HERE", modify_message_handler, true );

But what that event is, I am unsure, along with what object I will get (a message header?) and how easily I can modify what is displayed.

So the questions are:

  • Do I have the correct overlay?
  • Can this be done with events? If not, how?
  • If so, what event is needed and what object does it pass?
like image 344
Thomas M. DuBuisson Avatar asked Jul 06 '12 23:07

Thomas M. DuBuisson


1 Answers

If what you want is something similar to a Greasemonkey script that would run on every message, you should:

  1. Wait for the load event of the window.
  2. Retrieve the message pane object with document.getElementById("messagepane").
  3. Bind your handler to the message pane's DOMContentLoaded event, or similar events like load depending on when exactly you want your handler to be called. DOMContentLoaded will give you a Greasemonkey-style behavior.
  4. In the event handler, event.originalTarget is the document corresponding to the displayed message. You can apply all the usual DOM modification techniques here.

For more details, see this example from the documentation.

like image 179
Generic Human Avatar answered Sep 27 '22 19:09

Generic Human