-
Notifications
You must be signed in to change notification settings - Fork 2
/
gmailto.js
45 lines (35 loc) · 928 Bytes
/
gmailto.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++)
{
if (links[i].href.match(/^mailto:/))
{
links[i].originalHref = links[i].href;
var queryStringIndex = -1;
var endIndex = links[i].href.length;
var subject = "";
var body = "";
if ((queryStringIndex = links[i].href.indexOf("?")) != -1)
{
endIndex = queryStringIndex;
var params = links[i].href.substring(queryStringIndex + 1).split("&");
for (var j = 0; j < params.length; j++)
{
var param = params[j].split("=");
switch (param[0])
{
case "subject":
{
subject = param[1];
}
break;
case "body":
{
body = param[1];
}
}
}
}
links[i].target = "_blank";
links[i].href="https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=" + escape(links[i].href.substring(7, endIndex)) + "&su=" + subject + "&body=" + body;
}
}