diff options
author | Vijay A <avijayr@protonmail.com> | 2021-08-29 16:14:40 +0530 |
---|---|---|
committer | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-08-29 16:18:17 +0530 |
commit | 7a3d8fa7f56986e0394e93ebbcb3d0a47785d737 (patch) | |
tree | 6348dac06399ac67a935d83034e3178a4df018ac | |
parent | cleanup: Remove duplicated recipes for Outlook Web App and Enterprise OWA. Fi... (diff) | |
download | ferdium-recipes-7a3d8fa7f56986e0394e93ebbcb3d0a47785d737.tar.gz ferdium-recipes-7a3d8fa7f56986e0394e93ebbcb3d0a47785d737.tar.zst ferdium-recipes-7a3d8fa7f56986e0394e93ebbcb3d0a47785d737.zip |
fix: Fix unread count in outlook (fixes #1808)
-rw-r--r-- | all.json | 2 | ||||
-rw-r--r-- | recipes/office365-owa/package.json | 2 | ||||
-rw-r--r-- | recipes/office365-owa/webview.js | 34 |
3 files changed, 23 insertions, 15 deletions
@@ -1023,7 +1023,7 @@ | |||
1023 | "featured": false, | 1023 | "featured": false, |
1024 | "id": "office365-owa", | 1024 | "id": "office365-owa", |
1025 | "name": "Office 365 Outlook", | 1025 | "name": "Office 365 Outlook", |
1026 | "version": "1.4.0", | 1026 | "version": "1.4.1", |
1027 | "aliases": [ | 1027 | "aliases": [ |
1028 | "live.com" | 1028 | "live.com" |
1029 | ], | 1029 | ], |
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); |