Imanuel
Imanuel

Reputation: 3667

How can I hook into new message windows using a bootstrapped Thunderbird extension?

I am currently trying to create a Thunderbird extension that write the recipients of a draft into the title of the composing window.
The default behaviour of Thunderbird is Compose: [Subject] (translated from German, YMMV), but I'd like to have something like this: Compose to [recipient(s)]: [Subject], so my time tracking software can keep track of the time I spend writing emails to clients.

My general idea for this extension is:

  1. Hook into every composing window that is created / opened (I know they are reused) via event listeners
  2. For every window, listen to the event recipients_changed, if such a thing exists. Otherwise, it's a bit more work (monitor all recipient input fields), but that should not be a problem.
  3. Also listen for subject_changed (easier, because it's only one input) to prevent the default title overwriting our extended title.

I have already created a skeleton extension (bootstrapped), and the startup function in bootstrap.js is actually getting called. Since this is my first extension to Firefox/Thunderbird, this is the first success! :)
However, the only reason I know the function is called because the many exceptions my different trials have thrown are logged in the error console...

I have read many texts, but the learning curve seems to be pretty steep.
I learned that at the time startup is called, pretty much nothing is defined yet (my first attempts were alert and then settimeout).

This answer looked promising, but it throws the exception 'wm' is not defined:
https://stackoverflow.com/a/14291575/1886765
Maybe I used the code wrongly - hard to say for a beginner.

It would probably be easier to make a non-bootstrapped extension (I could overlay the compose window and wouldn't need step #1), but now that I've started this way, I'd like to finish it this way.

Maybe the solution is some XPCOM connector, but this field is still completely dark for me.

Could you kindly point me in the right direction?

Upvotes: 0

Views: 172

Answers (0)

Related Questions