From a6f2f49165c18ac2321ede096a60e0b9a1bc5ca7 Mon Sep 17 00:00:00 2001 From: Balthasar Schachtner Date: Mon, 25 Mar 2019 12:57:18 +0100 Subject: [PATCH] add improved owa script --- owa.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 owa.js diff --git a/owa.js b/owa.js new file mode 100644 index 0000000..79cb303 --- /dev/null +++ b/owa.js @@ -0,0 +1,37 @@ +// ==UserScript== +// @name OWA +// @namespace Violentmonkey Scripts +// @match https://webmail.med.uni-muenchen.de/owa/* +// @grant none +// ==/UserScript== + +Notification.requestPermission().then(function(result) { + console.log(result); +}); +notified = 0 + +window.setInterval(function(){ + var search = document.querySelectorAll('.ms-font-weight-semibold[title="Posteingang"]') + if (search.length == 0){ + // no search result + nMails = 0 + } + else { + var x = search[0].parentElement.children[2] + nMails = x.innerHTML + } + if (document.title.slice(0,1) === "("){ + document.title = "("+nMails+') ' + document.title.slice(4) + } + else { + document.title = "("+nMails+') ' + document.title + } + if (nMails > 0){ + if (notified !== nMails) { + //console.log("OWA: "+nMails+" new mails") + var img = 'https://webmail.med.uni-muenchen.de/owa/prem/15.0.1365.1/resources/images/0/favicon.ico'; + var n = new Notification("New mails on OWA: "+nMails, {icon:img}); + notified = nMails + } + } +}, 10000);