Skip to content

Instantly share code, notes, and snippets.

@chrisyip
Last active January 6, 2016 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisyip/c480ffb09e9ed616e573 to your computer and use it in GitHub Desktop.
Save chrisyip/c480ffb09e9ed616e573 to your computer and use it in GitHub Desktop.
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