Skip to content

Instantly share code, notes, and snippets.

@asimihsan
Created May 14, 2013 09:59
Show Gist options
  • Save asimihsan/5574914 to your computer and use it in GitHub Desktop.
Save asimihsan/5574914 to your computer and use it in GitHub Desktop.
A Greasemonkey script to show notifications when there is any new mail in an Office 365 Outlook Web App tab.
// ==UserScript==
// @name Office 365 notifications
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description Show a Google Chrome notification when there is any unread mail.
// @match https://*/owa/*
// @copyright 2012+, You
// ==/UserScript==
var current_unread_count = 0;
function checkForUpdate() {
var clsElements = document.querySelectorAll("._n_D6");
var max = clsElements.length;
var unread_count = 0;
for (var i=0; i<max; i++) {
var element = clsElements[i];
var unread_count_id = element.id.split(".")[0] + ".ucount";
if (document.getElementById(unread_count_id)) {
unread_count += 1;
}
}
if (unread_count != current_unread_count) {
current_unread_count = unread_count;
if (unread_count > 0) {
GM_notification("You've got mail!", "Unread mail", null, 1000);
}
}
}
setInterval(checkForUpdate, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment