diff options
Diffstat (limited to 'recipes/gmail')
-rw-r--r-- | recipes/gmail/package.json | 2 | ||||
-rw-r--r-- | recipes/gmail/webview.js | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/recipes/gmail/package.json b/recipes/gmail/package.json index dfbb834..518f856 100644 --- a/recipes/gmail/package.json +++ b/recipes/gmail/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "gmail", | 2 | "id": "gmail", |
3 | "name": "Gmail", | 3 | "name": "Gmail", |
4 | "version": "1.5.0", | 4 | "version": "1.5.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://mail.google.com" | 7 | "serviceURL": "https://mail.google.com" |
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); |