<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Discussion on Gmail from address selector | Userscripts.org</title>
    <link>http://userscripts.org/scripts/show/10071</link>
    <description>Recent comments on userscript: Gmail from address selector</description>
    <language>en-us</language>
    <ttl>60</ttl>
    <item>
      <title>Archived Comments, replied by Du Song @ Mon, 17 Dec 2007 03:35:25 -0600</title>
      <description>&lt;p&gt;sorry for misformatted
&lt;br /&gt;&lt;pre&gt;
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 = &quot;youku\.com&quot;;

document.addEventListener('click',function(event) {
 	if (event.target.tagName == 'BUTTON' &amp;amp;&amp;amp; event.target.innerHTML == '&amp;lt;b&amp;gt;Send&amp;lt;/b&amp;gt;') {
		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);
&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 17 Dec 2007 03:35:25 -0600</pubDate>
      <guid isPermaLink="false">userscripts.org:17619:77366</guid>
      <author>Du Song</author>
      <link>http://userscripts.org/topics/17619</link>
    </item>
    <item>
      <title>Archived Comments, replied by Du Song @ Mon, 17 Dec 2007 03:32:48 -0600</title>
      <description>&lt;p&gt;a *working* version for GMail 2.0
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;//-----------------------------------------------------------
&lt;br /&gt;// set this to index of email address you want to use
&lt;br /&gt;// index of 1 would select the second email in the drop down list
&lt;br /&gt;// index of 2 would select the third email in the drop down list and so on,
&lt;br /&gt;//-----------------------------------------------------------
&lt;br /&gt;var emailIndex = 1;
&lt;br /&gt;//-----------------------------------------------------------
&lt;br /&gt;// Check for certain email addresses
&lt;br /&gt;// this can be changed
&lt;br /&gt;// currently changes from address if emails are sent to a .edu email address
&lt;br /&gt;//-----------------------------------------------------------
&lt;br /&gt;var email_regex = &quot;company\.com&quot;;&lt;/p&gt;

&lt;p&gt;document.addEventListener('click',function(event) {
&lt;br /&gt; 	if (event.target.tagName == 'BUTTON' &amp;amp;&amp;amp; event.target.innerHTML == '&lt;b&gt;Send&lt;/b&gt;') {
&lt;br /&gt;		var to = document.getElementsByName('to')[0].value;
&lt;br /&gt;		var cc = document.getElementsByName('cc')[0].value;
&lt;br /&gt;		var bcc = document.getElementsByName('bcc')[0].value;
&lt;br /&gt;		var from = document.getElementsByName('from')[0].value;
&lt;br /&gt;    //console.log('GMail from'+from+' to'+to);
&lt;br /&gt;		var myTest=new RegExp(email_regex);
&lt;br /&gt;		if(to.match(myTest) || cc.match(myTest) || bcc.match(myTest)){
&lt;br /&gt;			var frombox = document.getElementsByName('from')[0]
&lt;br /&gt;			/*for (var i=0;i&amp;lt;frombox&gt;&lt;br /&gt;				alert(frombox.options[i].value + ' ' + i);	 				
&lt;br /&gt;			}*/
&lt;br /&gt;			frombox.selectedIndex = emailIndex;
&lt;br /&gt;			//following line used for debugging the regular expression
&lt;br /&gt;			//alert(frombox.length + ' ' + frombox.multiple + ' ' + frombox.options[2].value);
&lt;br /&gt; 		}		
&lt;br /&gt;	}
&lt;br /&gt;}, true);&lt;/p&gt;

&lt;p&gt;&lt;/code&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 17 Dec 2007 03:32:48 -0600</pubDate>
      <guid isPermaLink="false">userscripts.org:17619:77367</guid>
      <author>Du Song</author>
      <link>http://userscripts.org/topics/17619</link>
    </item>
    <item>
      <title>Archived Comments, replied by jsheena @ Sun, 19 Aug 2007 11:55:03 -0500</title>
      <description>&lt;p&gt;This is very useful!  I've made two modifications which I hope you'll find useful:&lt;/p&gt;

&lt;p&gt;1. Now there's an array of address patterns&lt;/p&gt;

&lt;p&gt;2. There's an optional user confirmation before changing the address.  &lt;/p&gt;

&lt;p&gt;Here's the code:&lt;/p&gt;

&lt;p&gt;&lt;pre&gt;
// ==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 &quot;copy this&quot;
// 
// The first argument of the array is the regular expression matching email
// addresses you're sending to (or cc, or bcc).
// For example, &quot;.*(mycompany.com).*&quot; 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(&quot;.*(.edu).*&quot;, 1),   /* &amp;lt;--&gt;&amp;lt;emailmatchers&gt;&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 19 Aug 2007 11:55:03 -0500</pubDate>
      <guid isPermaLink="false">userscripts.org:17619:77368</guid>
      <author>jsheena</author>
      <link>http://userscripts.org/topics/17619</link>
    </item>
    <item>
      <title>Archived Comments, replied by Brett Brotherton @ Wed, 20 Jun 2007 21:03:12 -0500</title>
      <description>&lt;p&gt;Oops fixed bug had commented out a line that was needed&lt;/p&gt;</description>
      <pubDate>Wed, 20 Jun 2007 21:03:12 -0500</pubDate>
      <guid isPermaLink="false">userscripts.org:17619:77369</guid>
      <author>Brett Brotherton</author>
      <link>http://userscripts.org/topics/17619</link>
    </item>
    <item>
      <title>Archived Comments, replied by Jesse Andrews @ Tue, 16 Nov 2004 19:05:51 -0600</title>
      <description>&lt;p&gt;The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)&lt;/p&gt;</description>
      <pubDate>Tue, 16 Nov 2004 19:05:51 -0600</pubDate>
      <guid isPermaLink="false">userscripts.org:17619:77365</guid>
      <author>Jesse Andrews</author>
      <link>http://userscripts.org/topics/17619</link>
    </item>
  </channel>
</rss>
