2013/5/10 David Lechner <
da...@lechnology.com>
> On 5/9/2013 7:51 PM, pisigou wrote:
>
>> Could anybody please share any pointer about how to proceed with this
>> task?
>>
>
>
<snip useful references and examples>
> Maybe someone else has a better way to do this, but this is how I would
> approach it based on what I know.
>
> Good Luck.
>
> -David
>
>
Hello David, thanks a lot for your message and for your example.
I've built the addon from scratch based on your directions and on the
documentation you linked, then I found this addon:
https://addons.mozilla.org/en-US/thunderbird/addon/check-and-send/
and I inspected its code to see how it prompted for confirmation before
sending the message, then I ended up adding the following code into my js
file:
<javascript>
var RCerror = "Lists are not allowed other than in the 'BCC' field";
var RCfail = function() {
var rcpt_type_prefix = "addressCol1#";
var rcpt_value_prefix = "addressCol2#";
var delta = 1;
var rcpt_type = null;
var rcpt_value = null;
while(rcpt_type = document.getElementById(rcpt_type_prefix + delta)) {
rcpt_value = document.getElementById(rcpt_value_prefix + delta);
++delta;
if(rcpt_value.value.search(/<[^@]*>/) != -1 && rcpt_type.value !=
"addr_bcc") {
return true;
}
}
return false;
};
var OriginalSendMessage = SendMessage;
var SendMessage = function()
{
if(RCfail()) {
alert(RCerror);
return;
}
OriginalSendMessage.apply(this, arguments);
};
var OriginalSendMessageWithCheck = SendMessageWithCheck;
var SendMessageWithCheck = function()
{
if(RCfail()) {
alert(RCerror);
return;
}
OriginalSendMessageWithCheck.apply(this, arguments);
};
var OriginalSendMessageLater = SendMessageLater;
var SendMessageLater = function()
{
if(RCfail()) {
alert(RCerror);
return;
}
OriginalSendMessageLater.apply(this, arguments);
};
</javascript>
("RC" up there in the function and in the error variable refers to
"Recipient Control", the name I gave to my addon).
Bottom line: I quickly found a simple alternative to what I was trying to
achieve thanks to your help and thanks to a more educated search on the
existing addons (i.e. block the sending in case anything looks suspicious
instead of trying to disable the CC field)
I think I'll improve it by intercepting also multiple addresses separated
by a comma in the non-BCC fields, just to make it more foolproof.
Wish everybody good work,
cheers,
Simone