Skip to content

Commit

Permalink
Fix Discord badge counts (#461)
Browse files Browse the repository at this point in the history
Fixes `directCountPerServer`, as well as `indirectCountPerServer`.
  • Loading branch information
Cknight70 authored Nov 10, 2023
1 parent e73d4c2 commit 48ec989
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion recipes/discord/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "discord",
"name": "Discord",
"version": "1.8.1",
"version": "1.8.2",
"license": "MIT",
"config": {
"serviceURL": "https://discord.com/login",
Expand Down
6 changes: 2 additions & 4 deletions recipes/discord/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ module.exports = (Ferdium, settings) => {
const getMessages = () => {
let directCount = 0;
const directCountPerServer = document.querySelectorAll(
'[class*="lowerBadge-"] [class*="numberBadge-"]',
'[class*="lowerBadge_"] [class*="numberBadge_"]',
);

for (const directCountBadge of directCountPerServer) {
directCount += Ferdium.safeParseInt(directCountBadge.textContent);
}

const indirectCountPerServer = document.querySelectorAll(
'[class*="modeUnread-"]',
).length;
const indirectCountPerServer = document.title.search('• Discord') === -1 ? 0 : 1;

Ferdium.setBadge(directCount, indirectCountPerServer);
};
Expand Down

0 comments on commit 48ec989

Please sign in to comment.