diff options
author | 2022-12-28 09:58:46 +0200 | |
---|---|---|
committer | 2023-01-02 13:23:19 +0530 | |
commit | 7606f872a0728bbfa85db600e2aa7af84ae9fce6 (patch) | |
tree | 2917e6fe90ae1bb2160ca349836f3a17900ca8ba /recipes/element/webview.js | |
parent | Update pnpm to 7.21.0 (diff) | |
download | ferdium-recipes-7606f872a0728bbfa85db600e2aa7af84ae9fce6.tar.gz ferdium-recipes-7606f872a0728bbfa85db600e2aa7af84ae9fce6.tar.zst ferdium-recipes-7606f872a0728bbfa85db600e2aa7af84ae9fce6.zip |
Use unread rooms count like Element app does
This change uses unread rooms instead of messages count like Element
(web)app does
Unread rooms count is extracted from the `title` tag.
Diffstat (limited to 'recipes/element/webview.js')
-rw-r--r-- | recipes/element/webview.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/recipes/element/webview.js b/recipes/element/webview.js index 6ff8664..f88baac 100644 --- a/recipes/element/webview.js +++ b/recipes/element/webview.js | |||
@@ -1,11 +1,10 @@ | |||
1 | module.exports = Ferdium => { | 1 | module.exports = Ferdium => { |
2 | function getMessages() { | 2 | function getMessages() { |
3 | let directCount = 0; | 3 | const matches = document.querySelector('title').textContent |
4 | const spacesBar = document.querySelector('.mx_SpaceTreeLevel'); | 4 | .match('(?<=\\[)\\d+(?=])'); |
5 | for (const badge of spacesBar.querySelectorAll('.mx_NotificationBadge_count')) { | 5 | const directCount = Ferdium.safeParseInt(matches !== null ? matches[0] : 0); |
6 | directCount += Ferdium.safeParseInt(badge.textContent); | 6 | const indirectCount = document.querySelector('.mx_SpaceTreeLevel') |
7 | } | 7 | .querySelectorAll('.mx_NotificationBadge_dot') |
8 | const indirectCount = spacesBar.querySelectorAll('.mx_NotificationBadge_dot') | ||
9 | .length; | 8 | .length; |
10 | Ferdium.setBadge(directCount, indirectCount); | 9 | Ferdium.setBadge(directCount, indirectCount); |
11 | } | 10 | } |