Comments by Mike Cunneen on scripts

1 comment

Comment on:
GMailTo by N-Dream

Mar 27, 2007

Here is a hacked source to open a gmail compose window, as requested. YMMV.

// ==UserScript==
// @name GMailTo
// @namespace andrinvr@gmail.com
// @description Forces all mailto links to open in GMail
// @include *
// ==/UserScript==

//Super fast recursive lookup if it is a mailto: link
function goUp(target,howmany) {
if(howmany>0) {
if(target.nodeName=="A") {
if(target.href.indexOf("mailto:")==0) {
mail=target.href.substring(7);
if((strip=mail.indexOf("?"))!=-1) {
mail=mail.substring(0,strip);
}
if((strip=mail.indexOf("&"))!=-1) {
mail=mail.substring(0,strip);
}
//target.href="http://mail.google.com/mail/?view=cm&fs=1&tf=1&to="+mail;
var mailwin = window.open("https://mail.google.com/mail/?view=cm&tf=0&to="+mail+"&cc=&su=&body=&fs=1","mailwin","menubar=no,toolbar=no,location=no,directories=no,personalbar=no,status=no,dependent=yes,width=640,height=480");
//target.target="_blank";
target.href = null;
target.target = null;
mailwin.focus();
return false;
} else {
return;
}
} else {
if(target.parentNode!=null) {
goUp(target.parentNode,--howmany);
} else {
return;
}
}
} else {
return;
}
}

window.addEventListener("click",function(e) {
if(e.which==1) {
mail=goUp(e.target,5)
}
}, false);