Last active
January 6, 2016 11:05
-
-
Save chrisyip/c480ffb09e9ed616e573 to your computer and use it in GitHub Desktop.
Add badge for WeChat w/ Fluid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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