Skip to content

Instantly share code, notes, and snippets.

@lisotton
Forked from sdennler/A Sad Web App Notifier
Last active July 12, 2019 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisotton/c214aa280c60a6bd7fa19266d4bdb19a to your computer and use it in GitHub Desktop.
Save lisotton/c214aa280c60a6bd7fa19266d4bdb19a to your computer and use it in GitHub Desktop.
Bring the necessary Desktop Notification to Outlook Web App.

Synopsis

Outlook Web App has no Desktop Notification support. Probably because IE doesn't support it as well...

Motivation

I missed to much mails because this feature is missing...

Installation

  1. Install user script manager in your browser:
  1. Open this links and install the script:
  1. Change @match to your Outlook Web App URL

License

Public Domain

// ==UserScript==
// @name Sad Web App Notifier
// @namespace https://gist.github.com/lisotton/
// @version 1
// @description Bring the necessary Desktop Notification to Outlook Web App.
// @author Leandro Isotton
// @match https://myremote.ec.europa.eu/owa/*
// @exclude */manifests/*
// @grant none
// ==/UserScript==
console.log('Start Sad Web App Notifier');
if (!("Notification" in window)) {
alert("This browser does not support desktop notification. Sad Web App Notifier will not work.");
}
else {
Notification.requestPermission();
var BoxName = getBoxName();
checkForNewMail();
}
function getBoxName(){
var name = document.URL.match(/\/([^@\/]+@[^@\/]+)\//);
return name ? name[1] : false;
}
function checkForNewMail() {
var favoriteFolders = document.getElementById('MailFolderPane.FavoritesFolders');
var numberOfMessages = favoriteFolders.getElementsByClassName('ms-fcl-tp')[0].innerText;
numberOfMessages = numberOfMessages == '' ? 0 : parseInt(numberOfMessages);
if (typeof window.numberOfMessages === 'undefined') {
console.log('Initializing...');
window.numberOfMessages = numberOfMessages;
}
if (numberOfMessages > window.numberOfMessages) {
console.log('New mail!');
var notification = spawnNotification('', 'You have new mail!');
}
else {
console.log('No new mail');
}
window.numberOfMessages = numberOfMessages;
setTimeout(checkForNewMail, 10000);
}
function spawnNotification(body, title) {
if (BoxName) title += ' ('+BoxName+')';
var options = {
body: body,
icon: 'https://openclipart.org/image/128px/svg_to_png/214764/1424701298.png'
}
return new Notification(title, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment