Monthly Archives: May 2013

Alt-J – Greasemonkey script to replace Wingdings

Here’s a Greasemonkey script to get rid of those horrible “J” characters we see when an Outlook user tries to send you a smiley.

(Thanks to Abhinay Omkar’s “J for Smile” script which was the inspiration here.)

I don’t really use Greasemonkey but it seems that most people put their scripts on userscripts.org – however this seems to be a repository for Chinese spam and other garbage. So here it is:

// ==UserScript==
// @name        Alt J
// @namespace   http://blench.org
// @description Replace J with smiley etc
// @include     https://outlook.hslive.net/*
// @grant       none
// @version     1
// ==/UserScript==

function makeSmiley(sm)
{
    switch(sm)
    {
        case "J":
        return "☺";
        case "K":
        return "😐";
        case "L":
        return "☹";
        default:
        return sm;
    }
}

function makeSmileys(){

    var fonts = document.getElementsByTagName('font');
    for (var key in fonts)
    {
        var font = fonts[key];
        if (font != null) 
        {
            var face = font.face;
            if (face != null && face.indexOf('Wingdings') != -1)
            {
                font.innerHTML = makeSmiley(font.innerHTML);
            }
        }
    }

    var spans = document.getElementsByTagName('span');
    for (var key in spans)
    {
        var span = spans[key];
        if (span != null) 
        {
            var style = span.style.cssText;
            if (style != null && style.indexOf('Wingdings') != -1)
            {
                span.innerHTML = makeSmiley(span.innerHTML);
            }
        }
    }
}
		

makeSmileys();
Posted in Uncategorized | Leave a comment