diff options
-rw-r--r-- | all.json | 2 | ||||
-rw-r--r-- | docs/configuration.md | 2 | ||||
-rw-r--r-- | recipes/office365-owa/package.json | 5 | ||||
-rw-r--r-- | recipes/office365-owa/webview.js | 38 | ||||
-rw-r--r-- | scripts/package.js | 2 |
5 files changed, 27 insertions, 22 deletions
@@ -1122,7 +1122,7 @@ | |||
1122 | "featured": false, | 1122 | "featured": false, |
1123 | "id": "office365-owa", | 1123 | "id": "office365-owa", |
1124 | "name": "Office 365 Outlook", | 1124 | "name": "Office 365 Outlook", |
1125 | "version": "1.4.6", | 1125 | "version": "1.5.0", |
1126 | "aliases": [ | 1126 | "aliases": [ |
1127 | "live.com" | 1127 | "live.com" |
1128 | ], | 1128 | ], |
diff --git a/docs/configuration.md b/docs/configuration.md index ee44081..ab496c6 100644 --- a/docs/configuration.md +++ b/docs/configuration.md | |||
@@ -78,6 +78,8 @@ Services like Slack or HipChat have direct messages e.g. a mention or message to | |||
78 | Info message that will be displayed in the add/edit service preferences screen. | 78 | Info message that will be displayed in the add/edit service preferences screen. |
79 | * `boolean` **disablewebsecurity** _default: false_<br /> | 79 | * `boolean` **disablewebsecurity** _default: false_<br /> |
80 | Some services like hangoutschat need the web security disabled. | 80 | Some services like hangoutschat need the web security disabled. |
81 | * `boolean` **allowFavoritesDelineationInUnreadCount** _default: false_<br /> | ||
82 | Services like Outlook differentiate between favorites vs other folders. Setting this to `true` will allow the exclusion of the message counts from those non-favorite folders. | ||
81 | 83 | ||
82 | ## Example | 84 | ## Example |
83 | 85 | ||
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); |
diff --git a/scripts/package.js b/scripts/package.js index 2675ffb..79db480 100644 --- a/scripts/package.js +++ b/scripts/package.js | |||
@@ -133,7 +133,7 @@ const compress = (src, dest) => new Promise((resolve, reject) => { | |||
133 | } | 133 | } |
134 | if (config.config && typeof config.config === "object") { | 134 | if (config.config && typeof config.config === "object") { |
135 | const configKeys = Object.keys(config.config); | 135 | const configKeys = Object.keys(config.config); |
136 | const knownConfigKeys = ['serviceURL', 'hasTeamId', 'urlInputPrefix', 'urlInputSuffix', 'hasHostedOption', 'hasCustomUrl', 'hasNotificationSound', 'hasDirectMessages', 'hasIndirectMessages', 'message', 'disablewebsecurity']; | 136 | const knownConfigKeys = ['serviceURL', 'hasTeamId', 'urlInputPrefix', 'urlInputSuffix', 'hasHostedOption', 'hasCustomUrl', 'hasNotificationSound', 'hasDirectMessages', 'hasIndirectMessages', 'allowFavoritesDelineationInUnreadCount', 'message', 'disablewebsecurity']; |
137 | const unrecognizedConfigKeys = configKeys.filter(x => !knownConfigKeys.includes(x)); | 137 | const unrecognizedConfigKeys = configKeys.filter(x => !knownConfigKeys.includes(x)); |
138 | if (unrecognizedConfigKeys.length > 0) { | 138 | if (unrecognizedConfigKeys.length > 0) { |
139 | configErrors.push(`The recipe's package.json contains the following keys that are not recognized: ${unrecognizedConfigKeys}`); | 139 | configErrors.push(`The recipe's package.json contains the following keys that are not recognized: ${unrecognizedConfigKeys}`); |