diff options
Diffstat (limited to 'recipes')
-rw-r--r-- | recipes/element/package.json | 2 | ||||
-rw-r--r-- | recipes/element/webview.js | 25 |
2 files changed, 8 insertions, 19 deletions
diff --git a/recipes/element/package.json b/recipes/element/package.json index 58ca48d..beba777 100644 --- a/recipes/element/package.json +++ b/recipes/element/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "element", | 2 | "id": "element", |
3 | "name": "Element", | 3 | "name": "Element", |
4 | "version": "1.3.0", | 4 | "version": "1.3.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "aliases": [ | 6 | "aliases": [ |
7 | "Riot.im", | 7 | "Riot.im", |
diff --git a/recipes/element/webview.js b/recipes/element/webview.js index ebe557f..3528418 100644 --- a/recipes/element/webview.js +++ b/recipes/element/webview.js | |||
@@ -1,25 +1,14 @@ | |||
1 | module.exports = Ferdium => { | 1 | module.exports = Ferdium => { |
2 | function getMessages() { | 2 | function getMessages() { |
3 | const badges = document.querySelectorAll('.mx_RoomList .mx_RoomSublist_tiles .mx_NotificationBadge'); | ||
4 | // Number of messages from rooms which has "All Messages" notifications enabled. | ||
5 | // Always incremented for private rooms by default, incremented for group chats if | ||
6 | // "All Messages" is selected for them in notifications settings. | ||
7 | let directCount = 0; | 3 | let directCount = 0; |
8 | // Number of messages for rooms which has "Only Highlights" notifications level set. | 4 | const spacesBar = document.querySelector('.mx_SpaceTreeLevel'); |
9 | // Appears in rooms list with dots on right. | 5 | spacesBar.querySelectorAll('.mx_NotificationBadge_count').forEach((badge) => { |
10 | let indirectCount = 0; | 6 | directCount += Ferdium.safeParseInt(badge.textContent); |
11 | 7 | }); | |
12 | for (const badge of badges) { | 8 | const indirectCount = spacesBar.querySelectorAll('.mx_NotificationBadge_dot') |
13 | if (badge.classList.contains('mx_NotificationBadge_dot')) { | 9 | .length; |
14 | indirectCount++; | ||
15 | } else { | ||
16 | directCount += Ferdium.safeParseInt(badge.childNodes[0].textContent); | ||
17 | } | ||
18 | } | ||
19 | |||
20 | // set Ferdium badge | ||
21 | Ferdium.setBadge(directCount, indirectCount); | 10 | Ferdium.setBadge(directCount, indirectCount); |
22 | } | 11 | } |
12 | |||
23 | Ferdium.loop(getMessages); | 13 | Ferdium.loop(getMessages); |
24 | }; | 14 | }; |
25 | |||