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/package.json | 2 +- recipes/groupme/webview.js | 12 ++++++++++-- recipes/hostnet/package.json | 2 +- recipes/hostnet/webview.js | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'recipes') diff --git a/recipes/groupme/package.json b/recipes/groupme/package.json index 983c679..0fa12ad 100644 --- a/recipes/groupme/package.json +++ b/recipes/groupme/package.json @@ -1,7 +1,7 @@ { "id": "groupme", "name": "GroupMe", - "version": "1.2.0", + "version": "1.2.1", "license": "MIT", "config": { "serviceURL": "https://web.groupme.com", 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); diff --git a/recipes/hostnet/package.json b/recipes/hostnet/package.json index f7bd962..24487b8 100644 --- a/recipes/hostnet/package.json +++ b/recipes/hostnet/package.json @@ -1,7 +1,7 @@ { "id": "hostnet", "name": "Hostnet", - "version": "1.2.0", + "version": "1.2.1", "license": "MIT", "config": { "serviceURL": "https://appsuite.hostnet.nl/appsuite/" diff --git a/recipes/hostnet/webview.js b/recipes/hostnet/webview.js index 0f0b809..9a1266f 100644 --- a/recipes/hostnet/webview.js +++ b/recipes/hostnet/webview.js @@ -1,6 +1,6 @@ module.exports = Ferdium => { const getMessages = () => { - Ferdium.setBadge(Number.parseInt(document.querySelectorAll('.badge.topbar-launcherbadge')[0].firstChild.data)); + Ferdium.setBadge(Ferdium.safeParseInt(document.querySelectorAll('.badge.topbar-launcherbadge')[0].firstChild.data)); }; Ferdium.loop(getMessages); -- cgit v1.2.3-70-g09d2