Skip to content

Commit

Permalink
Add new badge count logic & new logo for Zalo
Browse files Browse the repository at this point in the history
  • Loading branch information
survfate authored and vraravam committed Jun 29, 2023
1 parent b21abf5 commit 340c1de
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
Empty file added recipes/zalo/darkmode.css
Empty file.
11 changes: 10 additions & 1 deletion recipes/zalo/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion recipes/zalo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "zalo",
"name": "Zalo",
"version": "1.3.0",
"version": "1.4.0",
"license": "MIT",
"config": {
"serviceURL": "https://chat.zalo.me/",
Expand Down
56 changes: 52 additions & 4 deletions recipes/zalo/webview.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
module.exports = Ferdium => {
const getMessages = () => {
const notificationBadge = document.querySelectorAll('.tab-red-dot').length;
Ferdium.setBadge(notificationBadge);
};
let count = 0;

const unreadRed = document.querySelector('.unread-red');
if (unreadRed !== null) {
switch (unreadRed.classList[1]) {
case 'fa-num1':
count = 1;
break;
case 'fa-num2':
count = 2;
break;
case 'fa-num3':
count = 3;
break;
case 'fa-num4':
count = 4;
break;
case 'fa-num5':
count = 5;
break;
default: {
// fa-num5plus
const convUnread = document.querySelectorAll('.conv-unread:not(.func-unread__muted)');
if (convUnread.length === 0)
count = 6; // 5+
else
for (const convUnreadItem of convUnread) {
switch (convUnreadItem.classList[1]) {
case 'fa-1_24_Line':
count = count + 1;
break;
case 'fa-2_24_Line':
count = count + 2;
break;
case 'fa-3_24_Line':
count = count + 3;
break;
case 'fa-4_24_Line':
count = count + 4;
break;
case 'fa-5_24_Line':
count = count + 5;
break;
default: // fa-5plus_24_Line
count = count + 6;
}
}
}
}
}
Ferdium.setBadge(count);
};
Ferdium.loop(getMessages);
};
};

0 comments on commit 340c1de

Please sign in to comment.