aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/whatsapp
diff options
context:
space:
mode:
authorLibravatar Boro Vukovic <TheBoroer@users.noreply.github.com>2021-03-05 05:34:45 -0500
committerLibravatar GitHub <noreply@github.com>2021-03-05 11:34:45 +0100
commit99d1452db8112addb9d864a56a38a787286540ed (patch)
treec936b0d3148f1f031f293bb505d0eeffe9c0a993 /recipes/whatsapp
parentAdd recipe for Webex Teams (#435) (diff)
downloadferdium-recipes-99d1452db8112addb9d864a56a38a787286540ed.tar.gz
ferdium-recipes-99d1452db8112addb9d864a56a38a787286540ed.tar.zst
ferdium-recipes-99d1452db8112addb9d864a56a38a787286540ed.zip
Fix WhatsApp unread notification badge with new method (#446)
Diffstat (limited to 'recipes/whatsapp')
-rw-r--r--recipes/whatsapp/webview.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js
index 26839d3..169b54c 100644
--- a/recipes/whatsapp/webview.js
+++ b/recipes/whatsapp/webview.js
@@ -28,21 +28,24 @@ window.addEventListener('beforeunload', async () => {
28 28
29module.exports = Franz => { 29module.exports = Franz => {
30 const getMessages = function getMessages() { 30 const getMessages = function getMessages() {
31 const elements = document.querySelectorAll('._31gEB, .CxUIE, .unread, ._0LqQ, .m61XR, .ZKn2B, .VOr2j');
32 var count = 0; 31 var count = 0;
33 var indirectCount = 0; 32 var indirectCount = 0;
34 33
35 for (var i = 0; i < elements.length; i += 1) { 34 var parentChatElem = document.querySelector("#pane-side").children[0].children[0].children[0];
36 var countValue = parseInt(elements[i].textContent || '0', 10); 35 var chatElems = parentChatElem.children;
37 36 for (var i = 0; i < chatElems.length; i++) {
38 if (elements[i].parentNode.previousElementSibling === null || elements[i].parentNode.previousElementSibling.querySelectorAll("[data-icon=muted]").length === 0) { 37 var chatElem = chatElems[i];
38 var unreadElem = chatElem.children[0].children[0].children[1].children[1].children[1];
39
40 var countValue = parseInt(unreadElem.textContent) || 0; // Returns 0 in case of isNaN
41
42 if (unreadElem.querySelectorAll("[data-icon=muted]").length === 0) {
39 count += countValue; 43 count += countValue;
40 } 44 } else {
41 else { 45 indirectCount += countValue;
42 indirectCount += countValue; 46 }
43 }
44 } 47 }
45 48
46 Franz.setBadge(count, indirectCount); 49 Franz.setBadge(count, indirectCount);
47 }; 50 };
48 51