Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Thunderbird] Disable CC field, keep BCC field

137 views
Skip to first unread message

pisigou

unread,
May 9, 2013, 8:51:00 PM5/9/13
to dev-ext...@lists.mozilla.org
Hello,
I need to disable the CC option when composing a new message in
Thunderbird, but keep the BCC one.

It is a very urgent task to get accomplished for me because some of my
collaborators have mistaken the CC option for the BCC one disclosing our
lists more than once, and it's about time to solve this.

I've searched through the web in general and though the documentation about
creating Mozilla Addons in particular, looking for an extension or for some
instructions about how to modify the "compose message" page - I wasn't able
to find what I'm looking for.

Could anybody please share any pointer about how to proceed with this task?

I already have a working skeleton for the extension built with the Add-on
Builder but right now I'm pretty much lost in dead ends, for instance:

https://addons.mozilla.org/en-us/developers/docs/reference

contains this link:

https://developer.mozilla.org/en-US/docs/Thunderbird/STEEL

which looks like an empty placeholder, and this page:

https://developer.mozilla.org/en-US/docs/Extensions/Thunderbird/HowTos

has a lot of red links and TODOs which are exactly the ones I'd need.

Thanks a lot for your attention, any pointer or hint will be really welcome.

Cheers,
Simone

David Lechner

unread,
May 10, 2013, 1:06:10 PM5/10/13
to
On 5/9/2013 7:51 PM, pisigou wrote:
> Could anybody please share any pointer about how to proceed with this task?

This page has some better links (and some out of date ones too)
https://developer.mozilla.org/en-US/docs/Extensions/Thunderbird

I've never used addon builder, but rather just start from scratch, so if
something I'm saying doesn't sound right, it is probably because I am
guessing a bit. Also, substitute "myaddon" with whatever you call your
addon.

Addon builder should have created some files that look something like
this:
https://developer.mozilla.org/en-US/docs/Extensions/Thunderbird/Building_a_Thunderbird_extension_2:_extension_filesystem

I think install.rdf is pretty easy, and addon builder should have filled
it out properly for you, so I'll skip that part.

In chrome.manifest, you will want a couple lines like:

content myaddon chrome/content/
overlay chrome://messenger/content/messengercompose/messengercompose.xul
chrome://myaddon/content/compose-overlay.xul

This will tell Thunderbird to overlay chrome/content/compose-overlay.xul
over the top of the built-in compose window.

Now, you need to create the overlay file. Create a new text file called
chrome/content/compose-overlay.xul with the following contents:

<?xml version="1.0"?>
<overlay id="myaddon-compose-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://myaddon/content/compose-overlay.js"/>
</overlay>

This will call chrome/content/compose-overlay.js each time a new compose
window is opened.

After this, things get a little tricky since the To/Cc/Bcc is
dynamically selected and generated there probably isn't a trivial way to
disable it. You will have to use the DOM Inspector addon and look at the
source code to figure out how the message compose window works.
(Search addons for "DOM" to find the DOM Inspector. For source code, you
can start here:
https://mxr.mozilla.org/comm-central/source/mail/components/compose/content/)


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

pisigou

unread,
May 10, 2013, 10:39:23 PM5/10/13
to dev-ext...@lists.mozilla.org
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
0 new messages