diff options
author | 2023-05-23 14:32:33 -0700 | |
---|---|---|
committer | 2023-05-23 22:32:33 +0100 | |
commit | 7bcc6b18102725e5d2e737801ff114716c5a6825 (patch) | |
tree | 8bcab256ea3abd1560eb817f0640ab6655788e91 /recipes/github/webview.js | |
parent | Downgrade node to '18.15.0' (diff) | |
download | ferdium-recipes-7bcc6b18102725e5d2e737801ff114716c5a6825.tar.gz ferdium-recipes-7bcc6b18102725e5d2e737801ff114716c5a6825.tar.zst ferdium-recipes-7bcc6b18102725e5d2e737801ff114716c5a6825.zip |
fix(github): Include "new notifications" in direct total (#371)
Diffstat (limited to 'recipes/github/webview.js')
-rw-r--r-- | recipes/github/webview.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/recipes/github/webview.js b/recipes/github/webview.js index 1023975..b73e96e 100644 --- a/recipes/github/webview.js +++ b/recipes/github/webview.js | |||
@@ -1,11 +1,22 @@ | |||
1 | module.exports = Ferdium => { | 1 | module.exports = Ferdium => { |
2 | const _parseNewCount = (text) => { | ||
3 | const match = text.match(/\d+/); | ||
4 | return match ? Ferdium.safeParseInt(match[0]) : 0; | ||
5 | }; | ||
6 | |||
2 | const getMessages = () => { | 7 | const getMessages = () => { |
3 | const directCountElement = document.querySelector( | 8 | const directCountElement = document.querySelector( |
4 | '.filter-list.js-notification-inboxes .count', | 9 | '.filter-list.js-notification-inboxes .count', |
5 | ); | 10 | ); |
6 | const directCount = directCountElement | 11 | let directCount = directCountElement |
7 | ? Ferdium.safeParseInt(directCountElement.textContent) | 12 | ? Ferdium.safeParseInt(directCountElement.textContent) |
8 | : 0; | 13 | : 0; |
14 | |||
15 | const newCountElement = document.querySelector('a.h6[href="/notifications?query="]'); | ||
16 | const newCount = newCountElement ? | ||
17 | _parseNewCount(newCountElement.textContent) : 0; | ||
18 | directCount += newCount; | ||
19 | |||
9 | const indirectCount = document.querySelector( | 20 | const indirectCount = document.querySelector( |
10 | '[class*="mail-status unread"]:not([hidden])', | 21 | '[class*="mail-status unread"]:not([hidden])', |
11 | ) ? 1 : 0; | 22 | ) ? 1 : 0; |