diff options
Diffstat (limited to 'recipes/gmail/webview.js')
-rw-r--r-- | recipes/gmail/webview.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js index be22b66..fb8cf76 100644 --- a/recipes/gmail/webview.js +++ b/recipes/gmail/webview.js | |||
@@ -15,8 +15,8 @@ module.exports = Ferdium => { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | const getMessages = () => { | 17 | const getMessages = () => { |
18 | let count = 0; | 18 | let countImportant = 0; |
19 | 19 | let countNonImportant = 0; | |
20 | const inboxLinks = document.querySelectorAll('.J-Ke.n0'); | 20 | const inboxLinks = document.querySelectorAll('.J-Ke.n0'); |
21 | if (inboxLinks.length > 0) { | 21 | if (inboxLinks.length > 0) { |
22 | let parentNode = inboxLinks[0].parentNode; | 22 | let parentNode = inboxLinks[0].parentNode; |
@@ -25,14 +25,23 @@ module.exports = Ferdium => { | |||
25 | if (parentNodeOfParentNode) { | 25 | if (parentNodeOfParentNode) { |
26 | const unreadCounts = parentNodeOfParentNode.querySelectorAll('.bsU'); | 26 | const unreadCounts = parentNodeOfParentNode.querySelectorAll('.bsU'); |
27 | if (unreadCounts.length > 0) { | 27 | if (unreadCounts.length > 0) { |
28 | count = Ferdium.safeParseInt(unreadCounts[0].textContent.replace(/[^\p{N}]/gu, '')); | 28 | let unreadCount = unreadCounts[0].textContent; |
29 | if (unreadCount.includes(':')) { | ||
30 | let counts = unreadCount | ||
31 | .split(':') | ||
32 | .map(s => Ferdium.safeParseInt(s.replace(/[^\p{N}]/gu, ''))); | ||
33 | countImportant = counts[0]; | ||
34 | countNonImportant = counts[1] - counts[0]; | ||
35 | } else { | ||
36 | countImportant = Ferdium.safeParseInt( | ||
37 | unreadCount.replace(/[^\p{N}]/gu, ''), | ||
38 | ); | ||
39 | } | ||
29 | } | 40 | } |
30 | } | 41 | } |
31 | } | 42 | } |
32 | } | 43 | } |
33 | 44 | Ferdium.setBadge(countImportant, countNonImportant); | |
34 | // set Ferdium badge | ||
35 | Ferdium.setBadge(count); | ||
36 | }; | 45 | }; |
37 | 46 | ||
38 | Ferdium.loop(getMessages); | 47 | Ferdium.loop(getMessages); |