Archived Comments (locked)
|
|
The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008) |
|
|
sorry for misformatted
var emailIndex = 1;
//-----------------------------------------------------------
// Check for certain email addresses
// this can be changed
// currently changes from address if emails are sent to a .edu email address
//-----------------------------------------------------------
var email_regex = "youku\.com";
document.addEventListener('click',function(event) {
if (event.target.tagName == 'BUTTON' && event.target.innerHTML == '<b>Send</b>') {
var to = document.getElementsByName('to')[0].value;
var cc = document.getElementsByName('cc')[0].value;
var bcc = document.getElementsByName('bcc')[0].value;
var from = document.getElementsByName('from')[0].value;
//console.log('GMail from'+from+' to'+to);
var myTest=new RegExp(email_regex);
if(to.match(myTest) || cc.match(myTest) || bcc.match(myTest)){
var frombox = document.getElementsByName('from')[0]
frombox.selectedIndex = emailIndex;
}
}
}, true);
|
|
|
a *working* version for GMail 2.0
document.addEventListener('click',function(event) {
|
|
|
This is very useful! I've made two modifications which I hope you'll find useful: 1. Now there's an array of address patterns 2. There's an optional user confirmation before changing the address. Here's the code:
// ==UserScript==
// @name Gmail from address selector
// @namespace test123
// @description Selects the from address of same domain your sending to
// @include http*://mail.google.tld/mail/*
// ==/UserScript==
//-----------------------------------------------------------
// Check for certain email addresses
// this can be changed
// currently changes from address if emails are sent to a .edu email address
// You can add as many checks as you like by copying the line marked "copy this"
//
// The first argument of the array is the regular expression matching email
// addresses you're sending to (or cc, or bcc).
// For example, ".*(mycompany.com).*" matches any address sent to mycompany.com
//
//
// The second argument of the array is the index of the email you want to use
// as the sender.
//
// set this to index of email address you want to use
// index of 1 would select the second email in the drop down list
// index of 2 would select the third email in the drop down list and so on,
//-----------------------------------------------------------
var emailMatchers = new Array (
new Array(".*(.edu).*", 1), /* <--><emailmatchers>
|
|
|
Oops fixed bug had commented out a line that was needed |