aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/office365-owa/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/office365-owa/webview.js')
-rw-r--r--recipes/office365-owa/webview.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js
index b897c8d..17649fd 100644
--- a/recipes/office365-owa/webview.js
+++ b/recipes/office365-owa/webview.js
@@ -1,12 +1,14 @@
1module.exports = (Ferdi, settings) => { 1module.exports = (Ferdi, settings) => {
2 const collectCounts = (selector) => { 2 const collectCounts = selector => {
3 let unreadCount = 0; 3 let unreadCount = 0;
4 const foldersElement = document.querySelector(selector); 4 const foldersElement = document.querySelector(selector);
5 if (foldersElement) { 5 if (foldersElement) {
6 const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); 6 const allScreenReaders = foldersElement.querySelectorAll(
7 'span.screenReaderOnly',
8 );
7 for (const child of allScreenReaders) { 9 for (const child of allScreenReaders) {
8 if (child.previousSibling) { 10 if (child.previousSibling) {
9 unreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); 11 unreadCount += Ferdi.safeParseInt(child.previousSibling.textContent);
10 } 12 }
11 } 13 }
12 } 14 }
@@ -17,22 +19,24 @@ module.exports = (Ferdi, settings) => {
17 let directUnreadCount = 0; 19 let directUnreadCount = 0;
18 let indirectUnreadCount = 0; 20 let indirectUnreadCount = 0;
19 21
20 if (location.pathname.match(/\/owa/)) { 22 if (/\/owa/.test(location.pathname)) {
21 // classic app 23 // classic app
22 directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); 24 directUnreadCount = Ferdi.safeParseInt(
25 document.querySelectorAll("span[title*='Inbox'] + div > span")[0]
26 .textContent,
27 );
23 } else { 28 } else {
24 // new app 29 // new app
25 if (settings.onlyShowFavoritesInUnreadCount === true) { 30 directUnreadCount =
26 directUnreadCount = collectCounts('div[role=tree]:nth-child(2)'); // favorites 31 settings.onlyShowFavoritesInUnreadCount === true
27 } else { 32 ? collectCounts('div[role=tree]:nth-child(2)')
28 directUnreadCount = collectCounts('div[role=tree]:nth-child(3)'); // folders 33 : collectCounts('div[role=tree]:nth-child(3)');
29 }
30 34
31 indirectUnreadCount = collectCounts('div[role=tree]:nth-child(4)'); // groups 35 indirectUnreadCount = collectCounts('div[role=tree]:nth-child(4)'); // groups
32 } 36 }
33 37
34 Ferdi.setBadge(directUnreadCount, indirectUnreadCount); 38 Ferdi.setBadge(directUnreadCount, indirectUnreadCount);
35 } 39 };
36 40
37 Ferdi.loop(getMessages); 41 Ferdi.loop(getMessages);
38}; 42};