Can I hook the Reply event in a Thunderbird extension
Is there a way add an event handle开发者_开发问答r in a Thunderbird extension that fires when the user clicks "Reply"?
In compose_overlay.js:
window.addEventListener("compose-send-message", mySendHandler, true);
window.addEventListener("compose-window-init", myReplyHandler, true);
function mySendHandler(evt){
var msgcomposeWindow = document.getElementById( "msgcomposeWindow" );
var msg_type = msgcomposeWindow.getAttribute( "msgtype" );
// do not continue unless this is an actual send event
if(!(msg_type == nsIMsgCompDeliverMode.Now || msg_type == nsIMsgCompDeliverMode.Later) )
return;
//do not continue unless it is a reply action (not a forward)
var msgType = gMsgCompose.type;
if(!(msgType == Components.interfaces.nsIMsgCompType.ReplyToSender || msgType == Components.interfaces.nsIMsgCompType.Reply))
return;
var origURI = gMsgCompose.originalMsgURI;
if(origURI == ""){
return;
}
var TBmain = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService().QueryInterface(Components.interfaces.nsIWindowMediator).getMostRecentWindow("mail:3pane");
var msgHdr = TBmain.messenger.messageServiceFromURI(origURI).messageURIToMsgHdr(origURI);
//TODO
//Do something with the msgHdr
}
function myReplyHandler(evt){
var origURI = gMsgCompose.originalMsgURI;
var TBmain = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService().QueryInterface(Components.interfaces.nsIWindowMediator).getMostRecentWindow("mail:3pane");
var msgHdr = TBmain.messenger.messageServiceFromURI(origURI).messageURIToMsgHdr(origURI);
//TODO
//Do something with the msgHdr
}
Courtesy: gaurang1988
http://forums.mozillazine.org/viewtopic.php?p=9182225&sid=c81555cc47c06bafde88cadbbd7f7808#p9182225
Depending on your goals you could overlay the reply button and get a click event when the user clicked the reply button(s).
精彩评论