-
-
Save tdchien/5f0a3c7d65202c047392a9a7197d9187 to your computer and use it in GitHub Desktop.
function checkUnread() { | |
console.log('checkUnread run'); | |
var msg = document.getElementById("message-tab"); | |
var img = msg.querySelector(".tab-red-dot"); | |
if ((img == null) || (img == undefined)) { | |
// rambox.clearUnreadCount(); | |
document.title = originalTitle; | |
return; | |
} | |
var src = img.attributes["src"]; | |
src = src.value; | |
// src = 'https://zalo-chat-static.zadn.vn/message_notification_more.png'; | |
t = src.replace(/https\:\/\/zalo-chat-static.zadn.vn\/message_notification_|png|\./g, ''); | |
if (t === 'more') { | |
// rambox.setUnreadCount('5+') | |
document.title = "(5+) " + originalTitle | |
} else if (t >= 1) { | |
// rambox.setUnreadCount(e) | |
document.title = "(" + t + ") " + originalTitle | |
} else { | |
// rambox.clearUnreadCount() | |
document.title = originalTitle; | |
} | |
} | |
var originalTitle = document.title; | |
setInterval(checkUnread, 3000); |
Ash258
commented
Jun 15, 2018
- updateBadge is bad in many ways, no need to mix 2 types of if blocks
- It should use if.. else ifs, because it save some time and processing time (no need to return out of function).
- Dont use title hack.
- === should be use everytime in JS, unless its not needed
- Why do you use 5+ and not exact number??
- Why do you use that image hack? What is it's purpose?
@Ash258 Thank for your commend. I updated script with remove updateBadge method and using if else for update unread count.
For your question:
Dont use title hack.
Why do you use 5+ and not exact number??
Why do you use that image hack? What is it's purpose?
I have no idea for get unread messsage of zalo serrvice. They have no api for get so I get unread count from image icon.
I checked rambox api for update unread count but it's not work with me. So that is why I have to hack title.
rambox.setUnreadCount
rambox.setUnreadCount
Yeah... I think it work... Thanks, Chien ;)
@qspeed You're welcome
@tdchien i used your code and add to custom code on rambox 64bit 0.6.2 but nothing happen. what's wrong?
@D-Zen: Replace URL to https://chat.zalo.me. It worked for me.
@D-Zen: Replace URL to https://chat.zalo.me. It worked for me.
@kiemnx i follow your guide but nothing worked for me?
@D-Zen: Replace URL to https://chat.zalo.me. It worked for me.
@kiemnx i follow your guide but nothing worked for me?
![image](https://user-images.githubusercontent.com/30859070/63582724-21d04700-c589-11e9-9265-b305710f04af.png
Here is my configuration in Rambox.
@D-Zen: Replace URL to https://chat.zalo.me. It worked for me.
@kiemnx i follow your guide but nothing worked for me?
![image](https://user-images.githubusercontent.com/30859070/63582724-21d04700-c589-11e9-9265-b305710f04af.png
Here is my configuration in Rambox.
@kiemnx my config same but nothing worked, please show your advanced code
@D-Zen: Replace URL to https://chat.zalo.me. It worked for me.
@kiemnx i follow your guide but nothing worked for me?
![image](https://user-images.githubusercontent.com/30859070/63582724-21d04700-c589-11e9-9265-b305710f04af.png
Here is my configuration in Rambox.@kiemnx my config same but nothing worked, please show your advanced code
Here my whole config, no need advanced code. I add _Custom Service and just fill https://chat.zalo.me in url box, after that I can login zalo by my account.