From 3c455ffd71c58e44b2a7f6c51bd9343d78c4edde Mon Sep 17 00:00:00 2001 From: Feiko Joosten Date: Tue, 21 Apr 2020 20:12:58 +0200 Subject: Fixes notifications for WhatsApp (#120) - Fixes an issue where whatsapp doesn't properly detect notifications. - Added support for indirect notifications (muted chats) --- all.json | 2 +- archives/whatsapp.tar.gz | Bin 183369 -> 183419 bytes uncompressed/whatsapp/package.json | 4 +++- uncompressed/whatsapp/webview.js | 20 +++++++++++++------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/all.json b/all.json index 796b7cd..1d4a784 100644 --- a/all.json +++ b/all.json @@ -972,7 +972,7 @@ "featured": false, "id": "whatsapp", "name": "WhatsApp", - "version": "2.0.0", + "version": "2.0.1", "icons": { "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/whatsapp/icon.png", "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/whatsapp/icon.svg" diff --git a/archives/whatsapp.tar.gz b/archives/whatsapp.tar.gz index 1c45a71..c8c859d 100644 Binary files a/archives/whatsapp.tar.gz and b/archives/whatsapp.tar.gz differ diff --git a/uncompressed/whatsapp/package.json b/uncompressed/whatsapp/package.json index 210e8d1..49afab1 100644 --- a/uncompressed/whatsapp/package.json +++ b/uncompressed/whatsapp/package.json @@ -1,7 +1,7 @@ { "id": "whatsapp", "name": "WhatsApp", - "version": "2.0.0", + "version": "2.0.1", "description": "WhatsApp", "main": "index.js", "author": "Stefan Malzner ", @@ -9,6 +9,8 @@ "config": { "serviceURL": "https://web.whatsapp.com", "hasNotificationSound": true, + "hasDirectMessages": true, + "hasIndirectMessages": true, "disablewebsecurity": true } } diff --git a/uncompressed/whatsapp/webview.js b/uncompressed/whatsapp/webview.js index 989680a..6cc173a 100644 --- a/uncompressed/whatsapp/webview.js +++ b/uncompressed/whatsapp/webview.js @@ -28,16 +28,22 @@ window.addEventListener('beforeunload', async () => { module.exports = Franz => { const getMessages = function getMessages() { - const elements = document.querySelectorAll('.CxUIE, .unread, ._0LqQ'); - let count = 0; + const elements = document.querySelectorAll("[class=OUeyt]"); + var count = 0; + var indirectCount = 0; - for (let i = 0; i < elements.length; i += 1) { - if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { - count += 1; - } + for (var i = 0; i < elements.length; i += 1) { + var countValue = parseInt(elements[i].textContent, 10); + + if (elements[i].parentNode.previousElementSibling === null || elements[i].parentNode.previousElementSibling.querySelectorAll("[data-icon=muted]").length === 0) { + count += countValue; + } + else { + indirectCount += countValue; + } } - Franz.setBadge(count); + Franz.setBadge(count, indirectCount); }; Franz.injectCSS(path.join(__dirname, 'service.css')); -- cgit v1.2.3-70-g09d2