4

I have followed the tutorial for getting a Thunderbird extention going and succeeded in getting extensions that use the "load" event to work (the basic "date" example and random text using alert("hey"); both work).

However, I can't seem to get any message-based events to trigger. I've tried using various types of alerts and it just seems my code is not being ran. For example:

function send_event_handler( evt ) {
  alert("hohoho");
}

window.addEventListener( "compose-send-message", send_event_handler, true );

How do I get events to trigger that allow me to modify message bodies?

My test platform is using Thunderbird 13.

My manifest is:

content     thundersafe    chrome/content/
overlay chrome://messenger/content/messenger.xul chrome://thundersafe/content/thundersafe.xul
Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166

1 Answers1

6

Thanks to WladimirPalant, I looked for other overlays. This didn't occur to me because I thought the overlay would only be useful for adjusting the GUI via XUL join points - clearly I have a lot to learn.

The correct overlay for my use is:

chrome://messenger/content/messengercompose/messengercompose.xul

This overlay was discovered by looking at other extensions. I couldn't find a list of overlays and their intended uses anywhere on MDN.

Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166
  • 1
    Correct - you load a script from an overlay, consequently it runs in the context of the window you are overlaying. And since the `compose-send-message` event is fired in the Compose window you obviously need to overlay the Compose window (you found its address). You can see the address and structure of the chrome windows with the [DOM Inspector extension](https://addons.mozilla.org/addon/dom-inspector-6622/). – Wladimir Palant Jun 22 '12 at 21:33
  • Can you give more details about your files? I try to do exactly the same, but with no success – Cédric Boivin Jan 22 '17 at 13:47