diff options
Diffstat (limited to 'recipes/office365-owa')
-rw-r--r-- | recipes/office365-owa/package.json | 2 | ||||
-rw-r--r-- | recipes/office365-owa/webview.js | 34 |
2 files changed, 22 insertions, 14 deletions
diff --git a/recipes/office365-owa/package.json b/recipes/office365-owa/package.json index 1192347..e4dce4c 100644 --- a/recipes/office365-owa/package.json +++ b/recipes/office365-owa/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "office365-owa", | 2 | "id": "office365-owa", |
3 | "name": "Office 365 Outlook", | 3 | "name": "Office 365 Outlook", |
4 | "version": "1.4.0", | 4 | "version": "1.4.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "aliases": [ | 6 | "aliases": [ |
7 | "live.com" | 7 | "live.com" |
diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js index 123158e..0309488 100644 --- a/recipes/office365-owa/webview.js +++ b/recipes/office365-owa/webview.js | |||
@@ -1,10 +1,11 @@ | |||
1 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
2 | function getMessages() { | 2 | function getMessages() { |
3 | let unreadMail = 0; | 3 | let directUnreadCount = 0; |
4 | let indirectUnreadCount = 0; | ||
4 | 5 | ||
5 | if (location.pathname.match(/\/owa/)) { | 6 | if (location.pathname.match(/\/owa/)) { |
6 | // classic app | 7 | // classic app |
7 | unreadMail = parseInt( | 8 | directUnreadCount = parseInt( |
8 | jQuery("span[title*='Inbox'] + div > span") | 9 | jQuery("span[title*='Inbox'] + div > span") |
9 | .first() | 10 | .first() |
10 | .text(), | 11 | .text(), |
@@ -12,21 +13,28 @@ module.exports = Ferdi => { | |||
12 | ); | 13 | ); |
13 | } else { | 14 | } else { |
14 | // new app | 15 | // new app |
15 | const favorites = document.querySelector('div[title="Favorites"]'); | 16 | const foldersElement = document.querySelector('div[role=tree]:nth-child(3)'); |
16 | if (!favorites) { | 17 | if (foldersElement) { |
17 | return; | 18 | const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); |
19 | for (const child of allScreenReaders) { | ||
20 | if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { | ||
21 | directUnreadCount += parseInt(child.previousSibling.innerText, 10); | ||
22 | } | ||
23 | } | ||
18 | } | 24 | } |
19 | const folders = Array.from(favorites.nextSibling.childNodes); | ||
20 | 25 | ||
21 | unreadMail = folders.reduce((count, child) => { | 26 | const groupsElement = document.querySelector('div[role=tree]:nth-child(4)'); |
22 | const unread = child.querySelector('.screenReaderOnly'); | 27 | if (groupsElement) { |
23 | return unread && unread.textContent === 'unread' | 28 | const allScreenReaders = groupsElement.querySelectorAll('span.screenReaderOnly'); |
24 | ? count + parseInt(unread.previousSibling.textContent, 10) | 29 | for (const child of allScreenReaders) { |
25 | : count; | 30 | if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { |
26 | }, 0); | 31 | indirectUnreadCount += parseInt(child.previousSibling.innerText, 10); |
32 | } | ||
33 | } | ||
34 | } | ||
27 | } | 35 | } |
28 | 36 | ||
29 | Ferdi.setBadge(unreadMail); | 37 | Ferdi.setBadge(directUnreadCount, indirectUnreadCount); |
30 | } | 38 | } |
31 | 39 | ||
32 | Ferdi.loop(getMessages); | 40 | Ferdi.loop(getMessages); |