diff options
author | 2022-10-03 18:07:01 +0200 | |
---|---|---|
committer | 2022-10-04 07:51:50 +0000 | |
commit | 2e7b17768f679cd94352d0f544e8f95966f3c894 (patch) | |
tree | fdf83b9cf6784d5e0c761848fe75d5db14d530a1 /recipes/cinny/webview.js | |
parent | Fix for 39c3f6 failing build (diff) | |
download | ferdium-recipes-2e7b17768f679cd94352d0f544e8f95966f3c894.tar.gz ferdium-recipes-2e7b17768f679cd94352d0f544e8f95966f3c894.tar.zst ferdium-recipes-2e7b17768f679cd94352d0f544e8f95966f3c894.zip |
Add Cinny.in recipe
Diffstat (limited to 'recipes/cinny/webview.js')
-rw-r--r-- | recipes/cinny/webview.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/recipes/cinny/webview.js b/recipes/cinny/webview.js new file mode 100644 index 0000000..f4fd306 --- /dev/null +++ b/recipes/cinny/webview.js | |||
@@ -0,0 +1,22 @@ | |||
1 | module.exports = Ferdium => { | ||
2 | function getMessages() { | ||
3 | // Number of messages from rooms which has "All Messages" notifications enabled or when mentionned in a room with "Mentions & Keyword" notifications level. | ||
4 | let directCount = 0; | ||
5 | // Number of messages for rooms which has "Mentions & Keyword" notifications level set which does not directly mention you. | ||
6 | let indirectCount = 0; | ||
7 | |||
8 | // Retrieves notification badges | ||
9 | const badges = document.querySelectorAll('.sidebar .notification-badge'); | ||
10 | for (const badge of badges) { | ||
11 | if (badge.childNodes.length === 0) { | ||
12 | indirectCount++; | ||
13 | } else { | ||
14 | directCount += Ferdium.safeParseInt(badge.childNodes[0].textContent); | ||
15 | } | ||
16 | } | ||
17 | |||
18 | // Set Ferdium badge | ||
19 | Ferdium.setBadge(directCount, indirectCount); | ||
20 | } | ||
21 | Ferdium.loop(getMessages); | ||
22 | }; | ||