diff options
Diffstat (limited to 'recipes/proton-mail/webview.js')
-rw-r--r-- | recipes/proton-mail/webview.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/recipes/proton-mail/webview.js b/recipes/proton-mail/webview.js index 395b779..89e5dab 100644 --- a/recipes/proton-mail/webview.js +++ b/recipes/proton-mail/webview.js | |||
@@ -1,15 +1,13 @@ | |||
1 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
2 | const getMessages = () => { | 2 | const getMessages = () => { |
3 | const element = document.querySelector('.navigationItem-counter'); | 3 | let unreadCount = 0; |
4 | if (!element) { | 4 | // Loop over all displayed counters and take the highest one (from the "All Mail" folder) |
5 | return; | 5 | document.querySelectorAll('.navigation-counter-item').forEach(counterElement => { |
6 | } | 6 | const unreadCounter = Ferdi.safeParseInt(counterElement.textContent); |
7 | const text = element.textContent; | 7 | unreadCount = Math.max(unreadCount, unreadCounter); |
8 | if (text) { | 8 | }); |
9 | // eslint-disable-next-line unicorn/prefer-string-slice | 9 | |
10 | const count = Ferdi.safeParseInt(text.substring(1, text.length - 1)); | 10 | Ferdi.setBadge(unreadCount); |
11 | Ferdi.setBadge(count); | ||
12 | } | ||
13 | }; | 11 | }; |
14 | 12 | ||
15 | Ferdi.loop(getMessages); | 13 | Ferdi.loop(getMessages); |