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?
If what you want is something similar to a Greasemonkey script that would run on every message, you should:
loadevent of thewindow.document.getElementById("messagepane").DOMContentLoadedevent, or similar events likeloaddepending on when exactly you want your handler to be called.DOMContentLoadedwill give you a Greasemonkey-style behavior.event.originalTargetis 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.