From 811a30974ca10aed701312f54155d4efb7a90a02 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 15 May 2022 02:24:25 -0500 Subject: Fix unread message count for groupme and hostnet recipes --- recipes/groupme/webview.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'recipes/groupme/webview.js') diff --git a/recipes/groupme/webview.js b/recipes/groupme/webview.js index e2d6954..0d5afc3 100644 --- a/recipes/groupme/webview.js +++ b/recipes/groupme/webview.js @@ -1,9 +1,17 @@ module.exports = Ferdium => { const getMessages = () => { - const directMessages = document.querySelectorAll('.badge-count:not(.ng-hide)').length; + + // array-ify the list of conversations + const allConversations = [...document.querySelectorAll('#tray .tray-list .list-item')] + // for each conversation on the list... + const filteredConversations = allConversations.filter(e => { + // keep it on the list if [1] it has unread messages (not .ng-hide), and [2] it isn't muted (not .overlay) + return (!e.innerHTML.includes('ng-hide') && !e.innerHTML.includes('overlay')) + }); + const unreadConversations = filteredConversations.length; // set Ferdium badge - Ferdium.setBadge(directMessages); + Ferdium.setBadge(unreadConversations); }; Ferdium.loop(getMessages); -- cgit v1.2.3-54-g00ecf