Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add badge for WeChat w/ Fluid
setInterval(updateDockBadge, 500)
function updateDockBadge() {
var dots = document.querySelectorAll('.nav_view .chat_item .avatar .web_wechat_reddot_middle')
var badge = [].reduce.call(dots, function(pv, cv) {
var badge = Math.floor(cv.textContent)
if (isNaN(badge)) {
return 0
}
return pv + badge
}, 0)
if (!badge && document.querySelector('.nav_view .chat_item .avatar .web_wechat_reddot')) {
badge = ' '
}
window.fluid.dockBadge = badge || ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment