my first greasemonkey script - change_stupid_mailto_to_webmail !
my first greasemonkey script - change_stupid_mailto_to_webmail !
change_stupid_mailto_to_webmail, codename “sexual healing”, parses all mailto links on a page and changes them over to gmail links. So if you click on a mailto link it’ll take you to the gmail compose page with all the fields filled out properly.
To use change_stupid_mailto_to_webmail, you need to
-
Firefox
-
Greasemonkey extension for Firefox
-
Go to the
script page
here and click “install this script” in the top right
If you try it out, let me know what you think either here or on the script page. I tested it a bit, but not for every possible mailto link so there could be bugs. Also, I’m not quite sure what the best way for people to enter their own webmail links is, so suggestions are welcome. The code is below. If you see any bugs, or places I could improve it let me know.
************************ EDIT *********************
I gotta fix one line of code that’s really really slow (see first comment), and so I’d suggest not installing this until then.
**************************************************
// ==UserScript==
// @name change_stupid_mailto_to_webmail, codename “sexual healing”
// @namespace vikas_reddy
// @description changes mailto links to point to a webmail of your choice (I’ll generalize this eventually)
// ==/UserScript==
function getmailtoproperty(source, startIndicator, endIndicator)
{
var startPosition = source.indexOf(startIndicator);
if(startPosition == -1) return “”;
startPosition += 1;
var property = source.substring(startPosition + startIndicator.length,source.length);
var terminationPosition = property.indexOf(endIndicator);
if(terminationPosition == -1) terminationPosition = property.length;
property = property.substring(0,terminationPosition);
return property;
}
var links = document.getElementsByTagName(’a');
var x;
for(x in links)
{
var href = links[x].href;
if(href != null && href.substring(0,7) == “mailto:”)
{
var address = getmailtoproperty(href,”mailto”,”?”);
var subject = getmailtoproperty(href,”subject”,”&”);
var cc = getmailtoproperty(href,”cc”,”&”);
var bcc = getmailtoproperty(href,”bcc”,”&”);
var body = getmailtoproperty(href,”body”,”&”);
links[x].href = “https://mail.google.com/mail/?fs=1&view=cm&shva=1&to=” + address + “&su=” + subject + “&cc=” + cc + “&bcc=” + bcc + “&body=” + body;
}
}
![]() |
Currently Listening Finding Forever By Common see related |
post and comments imported from Xanga - vikas
-

hmm i need a better way to find all “mailto” links than looping through them all, is there something better than document.getElementByTagName(’a')?
until i fix this, i’d suggest not trying this out .
-

Weird…
Where are you looking for an apartment?
Please take the hat off, the aliens have left…
-

that’s pretty awesome dude
-

shweet
-

nice
-

Shit dude, I was JUST thinking about this yesterday when I was surfin Craiglist……. that’s pretty creepy. Thanks!





