From 7606f872a0728bbfa85db600e2aa7af84ae9fce6 Mon Sep 17 00:00:00 2001 From: Edgars Date: Wed, 28 Dec 2022 09:58:46 +0200 Subject: 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. --- recipes/element/package.json | 2 +- recipes/element/webview.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'recipes') diff --git a/recipes/element/package.json b/recipes/element/package.json index d694444..3564eef 100644 --- a/recipes/element/package.json +++ b/recipes/element/package.json @@ -1,7 +1,7 @@ { "id": "element", "name": "Element", - "version": "1.3.2", + "version": "1.3.3", "license": "MIT", "aliases": [ "Riot.im", 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 @@ module.exports = Ferdium => { function getMessages() { - let directCount = 0; - const spacesBar = document.querySelector('.mx_SpaceTreeLevel'); - for (const badge of spacesBar.querySelectorAll('.mx_NotificationBadge_count')) { - directCount += Ferdium.safeParseInt(badge.textContent); - } - const indirectCount = spacesBar.querySelectorAll('.mx_NotificationBadge_dot') + const matches = document.querySelector('title').textContent + .match('(?<=\\[)\\d+(?=])'); + const directCount = Ferdium.safeParseInt(matches !== null ? matches[0] : 0); + const indirectCount = document.querySelector('.mx_SpaceTreeLevel') + .querySelectorAll('.mx_NotificationBadge_dot') .length; Ferdium.setBadge(directCount, indirectCount); } -- cgit v1.2.3-54-g00ecf