aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/office365-owa/webview.js
diff options
context:
space:
mode:
authorLibravatar Bennett <hello@vantezzen.io>2020-09-22 20:56:48 +0200
committerLibravatar GitHub <noreply@github.com>2020-09-22 19:56:48 +0100
commit6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch)
tree9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /recipes/office365-owa/webview.js
parentUpdated logos for Outlook/OWA (diff)
downloadferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.gz
ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.zst
ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.zip
Unpack recipes and update recipes icons (#292)
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'recipes/office365-owa/webview.js')
-rw-r--r--recipes/office365-owa/webview.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js
new file mode 100644
index 0000000..ae21e19
--- /dev/null
+++ b/recipes/office365-owa/webview.js
@@ -0,0 +1,33 @@
1'use strict';
2
3module.exports = Franz => {
4 const getMessages = function getMessages() {
5 let unreadMail = 0;
6
7 if (location.pathname.match(/\/owa/)) {
8 // classic app
9 unreadMail = parseInt(
10 jQuery("span[title*='Inbox'] + div > span")
11 .first()
12 .text(),
13 10
14 );
15 } else {
16 // new app
17 const folders = document.querySelector('div[title="Folders"]');
18 if (!folders) {
19 return;
20 }
21
22 unreadMail = [...folders.parentNode.parentNode.children].reduce((count, child) => {
23 const unread = child.querySelector('.screenReaderOnly');
24 return unread && unread.textContent === 'unread'
25 ? count + parseInt(unread.previousSibling.textContent, 10)
26 : count;
27 }, 0);
28 }
29
30 Franz.setBadge(unreadMail);
31 };
32 Franz.loop(getMessages);
33};