Skip to content

Instantly share code, notes, and snippets.

@nattaylor
Last active January 20, 2017 04:38
Show Gist options
  • Save nattaylor/6ca2e0f91269576157cef780789926eb to your computer and use it in GitHub Desktop.
Save nattaylor/6ca2e0f91269576157cef780789926eb to your computer and use it in GitHub Desktop.
Outlook for Web Desktop Notifications Userscript
// ==UserScript==
// @name Outlook Web App Notifications
// @author nattaylor@gmail.com
// @namespace Notifications
// @include https://*/owa/*
// @exclude https://*/manifests/appCacheManifestHandler.ashx*
// @version 1
// @grant none
// @description Display WebAPI Desktop notifications for new messages
// ==/UserScript==
/**
* TODO: Fix the onload spam; add calendar support; onclick goto message; better check for itemType
*/
(function(open) {
XMLHttpRequest.prototype.open = function() {
this.addEventListener("readystatechange", function() {
if(this.readyState == 4 && this.responseURL.indexOf("GetConversationItem")>0) {
var msg = JSON.parse(this.responseText).Body.ResponseMessages.Items[0].Conversation.ConversationNodes[0].Items[0];
if(msg.Subject !== undefined && msg.ParentFolderId.Id.indexOf("AAAAAAEMAAA")>0 && !msg.IsRead) {
var n = new Notification(msg.From.Mailbox.Name, {
"body":msg.Subject + ": " + msg.Preview,
"icon":"https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Microsoft_Outlook_2013_logo.svg/64px-Microsoft_Outlook_2013_logo.svg.png"
});
}
}
}, false);
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
@mikemartin1090
Copy link

Hey - I found your post on this forum https://office365.uservoice.com/forums/273494-outlook-and-calendar/suggestions/9609474-new-email-browser-notifications-for-office-365-owa. Tried to use it with TamperMonkey chrome plugin, but can't seem to get it to alert me. What type of notification are we supposed to get? I see the outlook icon from wikimedia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment