| < Day Day Up > |
Hack 61. Warn Before Replying to Multiple Recipients in Gmail
Don't embarrass yourself by sending private replies to everyone .
Using any email program, it's all too easy to
7.3.1. The Code
This
The script uses the following algorithm to detect a possible reply-all snafu:
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %} Save the following user script as dontreplyall.user.js :
// ==UserScript==
// @name Don't Reply-All
// @namespace http://youngpup.net/
// @description Warn before replying to multiple recipients in Gmail
// @include http*://mail.google.com/mail/?*&view=cv*
// ==/UserScript==
// based on code by Aaron Boodman
// and included here with his gracious permission
var recipient_separator = /\s*\,\s*/g;
document.addEventListener("click", function(e) {
if (e.target.id == "send") {
var form = document.getElementById("compose_form");
var to = removeEmptyItems(
form.elements.namedItem('to').value.split(recipient_separator));
var cc = removeEmptyItems(
form.elements.namedItem('cc').value.split(recipient_separator));
var bcc = removeEmptyItems(
form.elements.namedItem('bcc').value.split(recipient_separator));
if ((to.length + cc.length + bcc.length) > 1) {
if (!confirm("WARNING!\n" +
"Do you really want to reply to all these people?\n\n" +
"To: " + to.join(", ") + "\n" +
"CC: " + cc.join(", ") + "\n" +
"BCC: " + bcc.join(", "))) {
e.stopPropagation();
}
}
}
}, true);
function removeEmptyItems(arr) {
var result = [];
for (var i = 0, item; item = arr[i]; i++) {
if (/\S/.test(item)) {
result.push(item);
}
}
return result;
}
7.3.2. Running the Hack
After installing the user script (Tools
Figure 7-3. Confirmation message before replying to multiple recipients
If you hit OK, Gmail will send the message as usual. If you hit Cancel, you will stay in the message composition window and can edit the To: or Cc: list to trim the number of recipients. — Aaron Boodman |
| < Day Day Up > |