diff options
author | 2020-04-21 20:09:20 +0200 | |
---|---|---|
committer | 2020-04-21 18:09:20 +0000 | |
commit | 40c192c65045200ff813680d7ff4133eebd56052 (patch) | |
tree | b11be16685343683fa6013aac67e22ea2c258002 /uncompressed | |
parent | Merge pull request #127 from Serubin/fix/slack-draft-notifications (diff) | |
download | ferdium-recipes-40c192c65045200ff813680d7ff4133eebd56052.tar.gz ferdium-recipes-40c192c65045200ff813680d7ff4133eebd56052.tar.zst ferdium-recipes-40c192c65045200ff813680d7ff4133eebd56052.zip |
Adds support for indirect messages in Discord (#122)
- Adds support for indirect messages
- Fixes an issue where notifications are no longer detected
Known issues:
- Doesn't properly work when hovering over a guild.
- Doesn't properly keep muted guilds, while its opened in mind.
Diffstat (limited to 'uncompressed')
-rw-r--r-- | uncompressed/discord/package.json | 4 | ||||
-rw-r--r-- | uncompressed/discord/webview.js | 34 |
2 files changed, 19 insertions, 19 deletions
diff --git a/uncompressed/discord/package.json b/uncompressed/discord/package.json index 76b680d..59a14d2 100644 --- a/uncompressed/discord/package.json +++ b/uncompressed/discord/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "discord", | 2 | "id": "discord", |
3 | "name": "Discord", | 3 | "name": "Discord", |
4 | "version": "1.1.1", | 4 | "version": "1.1.2", |
5 | "description": "Discord", | 5 | "description": "Discord", |
6 | "main": "index.js", | 6 | "main": "index.js", |
7 | "author": "Stefan Malzner <stefan@adlk.io>", | 7 | "author": "Stefan Malzner <stefan@adlk.io>", |
@@ -12,7 +12,7 @@ | |||
12 | "popup": [], | 12 | "popup": [], |
13 | "hasNotificationSound": true, | 13 | "hasNotificationSound": true, |
14 | "hasDirectMessages": true, | 14 | "hasDirectMessages": true, |
15 | "hasIndirectMessages": false, | 15 | "hasIndirectMessages": true, |
16 | "hasTeamID": false, | 16 | "hasTeamID": false, |
17 | "hasPredefinedUrl": true, | 17 | "hasPredefinedUrl": true, |
18 | "hasCustomUrl": false, | 18 | "hasCustomUrl": false, |
diff --git a/uncompressed/discord/webview.js b/uncompressed/discord/webview.js index 2a204dc..bcc8904 100644 --- a/uncompressed/discord/webview.js +++ b/uncompressed/discord/webview.js | |||
@@ -11,23 +11,23 @@ module.exports = Franz => { | |||
11 | ]; | 11 | ]; |
12 | 12 | ||
13 | const getMessages = function getMessages() { | 13 | const getMessages = function getMessages() { |
14 | // Get direct messages | 14 | const direct = document.querySelector('[class*="guilds-"]').querySelectorAll('[class^="numberBadge-"]').length; |
15 | let direct = 0; | 15 | |
16 | 16 | var indirect = 0; | |
17 | document.querySelectorAll('[class^="numberBadge-2s8kKX"]').forEach((directElement) => { | 17 | var guilds = document.querySelector("[data-ref-id=guildsnav]"); |
18 | direct = direct + parseInt(directElement.innerHTML); | 18 | if(guilds != null) { |
19 | }); | 19 | var channelPills = [].slice.call(guilds.querySelectorAll("[class*=item-2hkk8m]")); |
20 | 20 | indirect += channelPills.filter(y => y.clientHeight == 8).length; | |
21 | // Get indirect messages | 21 | |
22 | let indirect = 0; | 22 | var activeWindow = channelPills.find(y => y.clientHeight == 40); |
23 | 23 | if(activeWindow != null) { | |
24 | document.querySelectorAll('link[rel="icon"]').forEach((linkElement) => { | 24 | var unreadChannels = document.querySelector("[class*=modeUnread]"); |
25 | if(iconValues.indexOf(linkElement.getAttribute('href')) !== -1) { | 25 | |
26 | indirect = 1; | 26 | if(unreadChannels != null) |
27 | } | 27 | indirect++; |
28 | }); | 28 | } |
29 | 29 | } | |
30 | // Set badge | 30 | |
31 | Franz.setBadge(direct, indirect); | 31 | Franz.setBadge(direct, indirect); |
32 | }; | 32 | }; |
33 | 33 | ||