Skip to content

Instantly share code, notes, and snippets.

@chsh
Created February 9, 2012 05:22
Show Gist options
  • Save chsh/1777556 to your computer and use it in GitHub Desktop.
Save chsh/1777556 to your computer and use it in GitHub Desktop.
User Scripts for ChatWork.app made by Fluid.
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
var newBadge = '';
var totalCount = 0;
var roomsRoot = document.getElementById('cw_roomlist_items');
var ur_elms = roomsRoot.getElementsByClassName('cw_unread');
for (i = 0; i < ur_elms.length; i++) {
var elms = ur_elms[i].getElementsByClassName('cw_num_text');
for (j = 0; j < elms.length; j++) {
totalCount += parseInt(elms[j].innerHTML);
}
}
var numUnreads = totalCount + "";
if (numUnreads != '0') {
newBadge = numUnreads;
}
 
window.fluid.dockBadge = newBadge;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment