UserScript: Set the Outlook Web Access (OWA) title to the unread email count

Below is a simple UserScript (install with TamperMonkey or GreaseMonkey) to refresh the light OWA page and set the title of the page (tab) to the number of unread emails. I’ve only tried this in the light OWA mode 2010, but it seems to do the job, and refreshes the page once a minute.

I wrote this as I spend 95% of my day at work on my Linux box, and didn’t feel like having to run a full Exchange-to-imap gateway (like DavMail) so I just use the lightweight Outlook mail in a tab. Just be careful when composing an email using the light mode as it’ll just refresh the page regardless…!

// ==UserScript==
// @name           Outlook Web Access Light Title Inbox Count
// @namespace      seb.so
// @author         Seb Maynard
// @version        0.1
// @include        https://*/owa/*
// @include        http://*/owa/*
// ==/UserScript==
(function() {
    var originalTitle = unsafeWindow.document.title;
    var setTitleFunc = function(title) {
        title = title.replace(/\(/g, "").replace(/\)/g, "");
        window.document.title = title;
    };
    var f = function() {
        var setTitle = false;
        var as = unsafeWindow.document.getElementsByTagName('a');
        for (var i = 0, l = as.length; i < l; i++) {
            if (as[i].getAttribute('title') == 'Inbox') {
                var unrd = as[i].nextSibling;
                if (unrd && unrd.className == "unrd") {
                    setTitleFunc(unrd.innerHTML + " new");
                    setTitle = true;
                }
            }
        }
        if (!setTitle) setTitleFunc("- ");
    };
    setInterval("window.location=window.location", 60 * 1000);
    f();
})();

Posted

in

by

Tags:

Comments

One response to “UserScript: Set the Outlook Web Access (OWA) title to the unread email count”

  1. userscripts Avatar

    Great goods from you, I have understand your stuff previous to and you are just extremely wonderful web site.
    here is alternate of userscripts.org
    http://scriptsuser.org

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.