diff options
author | 2021-09-23 15:06:12 +0530 | |
---|---|---|
committer | 2021-09-23 15:08:32 +0530 | |
commit | c0406dda600387f4e9ace941e02a8783bc97d90c (patch) | |
tree | d19dba10c8c35d33992c8e66a3d409fa23beac4a /recipes | |
parent | fix: updated 'skype' and 'discord' to properly relinquish 'win' object for im... (diff) | |
download | ferdium-recipes-c0406dda600387f4e9ace941e02a8783bc97d90c.tar.gz ferdium-recipes-c0406dda600387f4e9ace941e02a8783bc97d90c.tar.zst ferdium-recipes-c0406dda600387f4e9ace941e02a8783bc97d90c.zip |
feature: allow services to delineate favorites vs non-favorites in unread counts
implements getferdi/recipes#721
Diffstat (limited to 'recipes')
-rw-r--r-- | recipes/office365-owa/package.json | 5 | ||||
-rw-r--r-- | recipes/office365-owa/webview.js | 38 |
2 files changed, 23 insertions, 20 deletions
diff --git a/recipes/office365-owa/package.json b/recipes/office365-owa/package.json index 354578d..56690e2 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.6", | 4 | "version": "1.5.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "aliases": [ | 6 | "aliases": [ |
7 | "live.com" | 7 | "live.com" |
@@ -10,6 +10,7 @@ | |||
10 | "serviceURL": "https://outlook.office365.com/mail/", | 10 | "serviceURL": "https://outlook.office365.com/mail/", |
11 | "hasNotificationSound": true, | 11 | "hasNotificationSound": true, |
12 | "hasHostedOption": true, | 12 | "hasHostedOption": true, |
13 | "hasCustomUrl": true | 13 | "hasCustomUrl": true, |
14 | "allowFavoritesDelineationInUnreadCount": true | ||
14 | } | 15 | } |
15 | } | 16 | } |
diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js index 0ac258c..b897c8d 100644 --- a/recipes/office365-owa/webview.js +++ b/recipes/office365-owa/webview.js | |||
@@ -1,4 +1,18 @@ | |||
1 | module.exports = Ferdi => { | 1 | module.exports = (Ferdi, settings) => { |
2 | const collectCounts = (selector) => { | ||
3 | let unreadCount = 0; | ||
4 | const foldersElement = document.querySelector(selector); | ||
5 | if (foldersElement) { | ||
6 | const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); | ||
7 | for (const child of allScreenReaders) { | ||
8 | if (child.previousSibling) { | ||
9 | unreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); | ||
10 | } | ||
11 | } | ||
12 | } | ||
13 | return unreadCount; | ||
14 | }; | ||
15 | |||
2 | const getMessages = () => { | 16 | const getMessages = () => { |
3 | let directUnreadCount = 0; | 17 | let directUnreadCount = 0; |
4 | let indirectUnreadCount = 0; | 18 | let indirectUnreadCount = 0; |
@@ -8,25 +22,13 @@ module.exports = Ferdi => { | |||
8 | directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); | 22 | directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); |
9 | } else { | 23 | } else { |
10 | // new app | 24 | // new app |
11 | const foldersElement = document.querySelector('div[role=tree]:nth-child(3)'); | 25 | if (settings.onlyShowFavoritesInUnreadCount === true) { |
12 | if (foldersElement) { | 26 | directUnreadCount = collectCounts('div[role=tree]:nth-child(2)'); // favorites |
13 | const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); | 27 | } else { |
14 | for (const child of allScreenReaders) { | 28 | directUnreadCount = collectCounts('div[role=tree]:nth-child(3)'); // folders |
15 | if (child.previousSibling) { | ||
16 | directUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); | ||
17 | } | ||
18 | } | ||
19 | } | 29 | } |
20 | 30 | ||
21 | const groupsElement = document.querySelector('div[role=tree]:nth-child(4)'); | 31 | indirectUnreadCount = collectCounts('div[role=tree]:nth-child(4)'); // groups |
22 | if (groupsElement) { | ||
23 | const allScreenReaders = groupsElement.querySelectorAll('span.screenReaderOnly'); | ||
24 | for (const child of allScreenReaders) { | ||
25 | if (child.previousSibling) { | ||
26 | indirectUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); | ||
27 | } | ||
28 | } | ||
29 | } | ||
30 | } | 32 | } |
31 | 33 | ||
32 | Ferdi.setBadge(directUnreadCount, indirectUnreadCount); | 34 | Ferdi.setBadge(directUnreadCount, indirectUnreadCount); |