Thursday, May 01, 2008

  • my first greasemonkey script - change_stupid_mailto_to_webmail !

    I've been looking for apartments on Craigslist lately and I got sick of clicking on the mailto links and having stupid outlook express open up. I hate Outlook, and I love gmail. So I decided to do something about it. Thus, my greasemonkey script change_stupid_mailto_to_webmail was born.

    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
    1. Firefox
    2. Greasemonkey extension for Firefox
    3. 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.
    **************************************************

    <code>
    // ==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;
        }
    }
    </code>
    Currently Listening
    Finding Forever
    By Common
    see related

Comments (6)

  • Choose Identity

  • Give eProps (?)

  • New! You can now edit your comments for 15 minutes after submitting.

About this Entry

Who recommended?

Who gave the eProps?

2 eProps from: