diff options
author | 2023-11-09 22:33:21 -0700 | |
---|---|---|
committer | 2023-11-10 05:33:21 +0000 | |
commit | 48ec989b3d8be0af8e1d62789fb24a19fa0e948e (patch) | |
tree | f16ea1e657ce4f306c3c39dcc8c98a923385adf5 /recipes/discord/webview.js | |
parent | Update notification selectors for TikTok (#454) (diff) | |
download | ferdium-recipes-48ec989b3d8be0af8e1d62789fb24a19fa0e948e.tar.gz ferdium-recipes-48ec989b3d8be0af8e1d62789fb24a19fa0e948e.tar.zst ferdium-recipes-48ec989b3d8be0af8e1d62789fb24a19fa0e948e.zip |
Fix Discord badge counts (#461)
Fixes `directCountPerServer`, as well as `indirectCountPerServer`.
Diffstat (limited to 'recipes/discord/webview.js')
-rw-r--r-- | recipes/discord/webview.js | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js index 052ddac..938b3a1 100644 --- a/recipes/discord/webview.js +++ b/recipes/discord/webview.js | |||
@@ -8,16 +8,14 @@ module.exports = (Ferdium, settings) => { | |||
8 | const getMessages = () => { | 8 | const getMessages = () => { |
9 | let directCount = 0; | 9 | let directCount = 0; |
10 | const directCountPerServer = document.querySelectorAll( | 10 | const directCountPerServer = document.querySelectorAll( |
11 | '[class*="lowerBadge-"] [class*="numberBadge-"]', | 11 | '[class*="lowerBadge_"] [class*="numberBadge_"]', |
12 | ); | 12 | ); |
13 | 13 | ||
14 | for (const directCountBadge of directCountPerServer) { | 14 | for (const directCountBadge of directCountPerServer) { |
15 | directCount += Ferdium.safeParseInt(directCountBadge.textContent); | 15 | directCount += Ferdium.safeParseInt(directCountBadge.textContent); |
16 | } | 16 | } |
17 | 17 | ||
18 | const indirectCountPerServer = document.querySelectorAll( | 18 | const indirectCountPerServer = document.title.search('• Discord') === -1 ? 0 : 1; |
19 | '[class*="modeUnread-"]', | ||
20 | ).length; | ||
21 | 19 | ||
22 | Ferdium.setBadge(directCount, indirectCountPerServer); | 20 | Ferdium.setBadge(directCount, indirectCountPerServer); |
23 | }; | 21 | }; |