Script: RemoveRecipients - jobisoft/quicktext GitHub Wiki

Remove recipients of the mail. A type could be specified to remove recipients from to, cc, bcc, reply-to or all areas.

Script (Thunderbird 102 or newer)

let type = this.mVariables[0];

var win = this.mWindow;

if(type == "to" || type == "all") {
  let toRow = win.document.getElementById("addressRowTo");
  win.addressRowClearPills(toRow);

  // another way to remove the recipients
  //for (let pill of win.document.getElementById("toAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
  //  pill.remove();
  //}
}

if(type == "cc" || type == "all") {
  let ccRow = win.document.getElementById("addressRowCc");
  win.addressRowClearPills(ccRow);

  // another way to remove the recipients
  //for (let pill of win.document.getElementById("ccAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
  //  pill.remove();
  //}
}

if(type == "bcc" || type == "all") {
  let bccRow = win.document.getElementById("addressRowBcc");
  win.addressRowClearPills(bccRow);

  // another way to remove the recipients
  //for (let pill of win.document.getElementById("bccAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
  //  pill.remove();
  //}
}

if(type == "reply-to" || type == "all") {
  let replyRow = win.document.getElementById("addressRowReply");
  win.addressRowClearPills(replyRow);

  // another way to remove the recipients
  //for (let pill of win.document.getElementById("replyAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
  //  pill.remove();
  //}
}

Script (Thunderbird 91 or older)

let type = this.mVariables[0];

var win = this.mWindow;

if(type == "to" || type == "all") {
  for (let pill of win.document.getElementById("toAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
    pill.remove();
  }
}

if(type == "cc" || type == "all") {
  for (let pill of win.document.getElementById("ccAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
    pill.remove();
  }
}

if(type == "bcc" || type == "all") {
  for (let pill of win.document.getElementById("bccAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
    pill.remove();
  }
}

if(type == "reply-to" || type == "all") {
  for (let pill of win.document.getElementById("replyAddrInput").closest(".address-container").querySelectorAll("mail-address-pill")) {
    pill.remove();
  }
}

Usage

Remove recipients in to:

[SCRIPT=RemoveRecipients](/jobisoft/quicktext/wiki/to)

Remove recipients in cc, bcc and reply-to:

[SCRIPT=RemoveRecipients](/jobisoft/quicktext/wiki/cc)
[SCRIPT=RemoveRecipients](/jobisoft/quicktext/wiki/bcc)
[SCRIPT=RemoveRecipients](/jobisoft/quicktext/wiki/reply-to)

Remove all recipients:

[SCRIPT=RemoveRecipients](/jobisoft/quicktext/wiki/all)