aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/messenger/webview.js
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-05-24 10:59:37 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-05-24 11:01:59 +0530
commitfb98432857928b7c26a196fc2b9020c3a90531d9 (patch)
tree8f566eaa85a031321ebc215b5976c5bc6e8f508d /recipes/messenger/webview.js
parentChanged jira recipe to allow for self-hosted urls. Bumpted recipe version. (diff)
downloadferdium-recipes-fb98432857928b7c26a196fc2b9020c3a90531d9.tar.gz
ferdium-recipes-fb98432857928b7c26a196fc2b9020c3a90531d9.tar.zst
ferdium-recipes-fb98432857928b7c26a196fc2b9020c3a90531d9.zip
Fixing unread count in Messenger
Diffstat (limited to 'recipes/messenger/webview.js')
-rw-r--r--recipes/messenger/webview.js30
1 files changed, 27 insertions, 3 deletions
diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js
index ba7ae31..4efdf8c 100644
--- a/recipes/messenger/webview.js
+++ b/recipes/messenger/webview.js
@@ -2,9 +2,33 @@
2 2
3module.exports = Franz => { 3module.exports = Franz => {
4 const getMessages = function getMessages() { 4 const getMessages = function getMessages() {
5 let count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; 5 let count = 0
6 const messageRequestsElement = document.querySelector('._5nxf'); 6
7 let isNotification = /^\((\d+)\)/.test(document.title);
7 8
9 /*
10 * Notification case for group chats, workaround by tamas646
11 * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154
12 */
13 if (isNotification) {
14 count = parseInt(/^\((\d+)\)/.exec(document.title)[1]);
15 } else {
16 /*
17 * Notification case for direct messages, workaround by manavortex
18 * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765
19 */
20 count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length;
21 if (0 === count) {
22 count = document.querySelectorAll('.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa').length;
23 }
24 if (0 === count) { // might be obsolete, not sure - never ran into this case
25 count = document.querySelectorAll('[aria-label="Mark as read"]').length;
26 }
27 }
28 /*
29 * add count of message requests on top of notification counter
30 */
31 const messageRequestsElement = document.querySelector('._5nxf');
8 if (messageRequestsElement) { 32 if (messageRequestsElement) {
9 count += parseInt(messageRequestsElement.innerHTML, 10); 33 count += parseInt(messageRequestsElement.innerHTML, 10);
10 } 34 }
@@ -31,4 +55,4 @@ module.exports = Franz => {
31 return notification; 55 return notification;
32 }); 56 });
33 } 57 }
34}; \ No newline at end of file 58};