aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Feiko Joosten <feiko_joosten@hotmail.com>2020-04-21 20:12:58 +0200
committerLibravatar GitHub <noreply@github.com>2020-04-21 18:12:58 +0000
commit3c455ffd71c58e44b2a7f6c51bd9343d78c4edde (patch)
treef92e40451cb13c9127592d6b013d0f95a1ad12a8
parentFixes notifications for Steamchat (#121) (diff)
downloadferdium-recipes-3c455ffd71c58e44b2a7f6c51bd9343d78c4edde.tar.gz
ferdium-recipes-3c455ffd71c58e44b2a7f6c51bd9343d78c4edde.tar.zst
ferdium-recipes-3c455ffd71c58e44b2a7f6c51bd9343d78c4edde.zip
Fixes notifications for WhatsApp (#120)
- Fixes an issue where whatsapp doesn't properly detect notifications. - Added support for indirect notifications (muted chats)
-rw-r--r--all.json2
-rw-r--r--archives/whatsapp.tar.gzbin183369 -> 183419 bytes
-rw-r--r--uncompressed/whatsapp/package.json4
-rw-r--r--uncompressed/whatsapp/webview.js20
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 @@
972 "featured": false, 972 "featured": false,
973 "id": "whatsapp", 973 "id": "whatsapp",
974 "name": "WhatsApp", 974 "name": "WhatsApp",
975 "version": "2.0.0", 975 "version": "2.0.1",
976 "icons": { 976 "icons": {
977 "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/whatsapp/icon.png", 977 "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/whatsapp/icon.png",
978 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/whatsapp/icon.svg" 978 "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
--- a/archives/whatsapp.tar.gz
+++ b/archives/whatsapp.tar.gz
Binary files 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 @@
1{ 1{
2 "id": "whatsapp", 2 "id": "whatsapp",
3 "name": "WhatsApp", 3 "name": "WhatsApp",
4 "version": "2.0.0", 4 "version": "2.0.1",
5 "description": "WhatsApp", 5 "description": "WhatsApp",
6 "main": "index.js", 6 "main": "index.js",
7 "author": "Stefan Malzner <stefan@adlk.io>", 7 "author": "Stefan Malzner <stefan@adlk.io>",
@@ -9,6 +9,8 @@
9 "config": { 9 "config": {
10 "serviceURL": "https://web.whatsapp.com", 10 "serviceURL": "https://web.whatsapp.com",
11 "hasNotificationSound": true, 11 "hasNotificationSound": true,
12 "hasDirectMessages": true,
13 "hasIndirectMessages": true,
12 "disablewebsecurity": true 14 "disablewebsecurity": true
13 } 15 }
14} 16}
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 () => {
28 28
29module.exports = Franz => { 29module.exports = Franz => {
30 const getMessages = function getMessages() { 30 const getMessages = function getMessages() {
31 const elements = document.querySelectorAll('.CxUIE, .unread, ._0LqQ'); 31 const elements = document.querySelectorAll("[class=OUeyt]");
32 let count = 0; 32 var count = 0;
33 var indirectCount = 0;
33 34
34 for (let i = 0; i < elements.length; i += 1) { 35 for (var i = 0; i < elements.length; i += 1) {
35 if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { 36 var countValue = parseInt(elements[i].textContent, 10);
36 count += 1; 37
37 } 38 if (elements[i].parentNode.previousElementSibling === null || elements[i].parentNode.previousElementSibling.querySelectorAll("[data-icon=muted]").length === 0) {
39 count += countValue;
40 }
41 else {
42 indirectCount += countValue;
43 }
38 } 44 }
39 45
40 Franz.setBadge(count); 46 Franz.setBadge(count, indirectCount);
41 }; 47 };
42 48
43 Franz.injectCSS(path.join(__dirname, 'service.css')); 49 Franz.injectCSS(path.join(__dirname, 'service.css'));