aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/zalo/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/zalo/webview.js')
-rw-r--r--recipes/zalo/webview.js56
1 files changed, 52 insertions, 4 deletions
diff --git a/recipes/zalo/webview.js b/recipes/zalo/webview.js
index 785cb9a..8e4c3cd 100644
--- a/recipes/zalo/webview.js
+++ b/recipes/zalo/webview.js
@@ -1,8 +1,56 @@
1module.exports = Ferdium => { 1module.exports = Ferdium => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const notificationBadge = document.querySelectorAll('.tab-red-dot').length; 3 let count = 0;
4 Ferdium.setBadge(notificationBadge);
5 };
6 4
5 const unreadRed = document.querySelector('.unread-red');
6 if (unreadRed !== null) {
7 switch (unreadRed.classList[1]) {
8 case 'fa-num1':
9 count = 1;
10 break;
11 case 'fa-num2':
12 count = 2;
13 break;
14 case 'fa-num3':
15 count = 3;
16 break;
17 case 'fa-num4':
18 count = 4;
19 break;
20 case 'fa-num5':
21 count = 5;
22 break;
23 default: {
24 // fa-num5plus
25 const convUnread = document.querySelectorAll('.conv-unread:not(.func-unread__muted)');
26 if (convUnread.length === 0)
27 count = 6; // 5+
28 else
29 for (const convUnreadItem of convUnread) {
30 switch (convUnreadItem.classList[1]) {
31 case 'fa-1_24_Line':
32 count = count + 1;
33 break;
34 case 'fa-2_24_Line':
35 count = count + 2;
36 break;
37 case 'fa-3_24_Line':
38 count = count + 3;
39 break;
40 case 'fa-4_24_Line':
41 count = count + 4;
42 break;
43 case 'fa-5_24_Line':
44 count = count + 5;
45 break;
46 default: // fa-5plus_24_Line
47 count = count + 6;
48 }
49 }
50 }
51 }
52 }
53 Ferdium.setBadge(count);
54 };
7 Ferdium.loop(getMessages); 55 Ferdium.loop(getMessages);
8}; 56}; \ No newline at end of file