diff options
author | Mattia Panzeri <1754457+panz3r@users.noreply.github.com> | 2021-11-25 14:26:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-25 18:56:58 +0530 |
commit | 5283be9f0bcd77dd24920219deabe8e3b72463a2 (patch) | |
tree | cd2045a56f1ec5f4374717c49d523aff2150a8a3 /recipes/proton-mail/webview.js | |
parent | docs: Update the 'updating recipe' docs [skip ci] (diff) | |
download | ferdium-recipes-5283be9f0bcd77dd24920219deabe8e3b72463a2.tar.gz ferdium-recipes-5283be9f0bcd77dd24920219deabe8e3b72463a2.tar.zst ferdium-recipes-5283be9f0bcd77dd24920219deabe8e3b72463a2.zip |
Fix Protonmail unread counter (#773)
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); |