Hacking Gmail

(Grace) #1

Chapter 6 — Gmail and Greasemonkey 113


if (nameValue && nameValue.length == 3) {
// depending on name, store value in a
pre-defined location
switch(nameValue[1]) {
case “to”:
emailTo = emailTo + “%2C%20” +
nameValue[2];
break;
case “cc”:
emailCC = nameValue[2];
//alert(“Found CC=” +
emailCC);
break;
case “subject”:
emailSubject = nameValue[2];
//alert(“Found subject=” +
emailSubject);
break;
case “body”:
emailBody = nameValue[2];
//alert(“Found body=” +
emailBody);
break;
}
}
}
}


mailtoLink.href =
https://mail.google.com/mail?view=cm&tf=0” +
(emailTo? (“&to=” + emailTo) : “”) +
(emailCC? (“&cc=” + emailCC) : “”) +
(emailSubject? (“&su=” + emailSubject) : “”)



  • (emailBody? (“&body=” + emailBody) : “”);
    // mailtoLink.onclick = function() { location.href
    = newUrl; return false; };
    }
    }


window.addEventListener(“load”, processMailtoLinks,
false);


})();


Instead of rewriting the mailto:links directly, as Mark Pilgrim’s script does to
make HTTP links into HTTPS, this script adds a JavaScript onclickfunction

Free download pdf