Skip to content

Instantly share code, notes, and snippets.

@chsh chsh/userscript.js
Created Jul 9, 2014

Embed
What would you like to do?
Show unread badges for ChatWork.
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
$('.promotionArea').css('display', 'none');
function updateDockBadge() {
var newBadge = '';
var totalCount = 0;
var useUnreadStatus = true;
var useToUnreadStatus = false;
var useTaskStatus = false;
// id: _chatUnreadStatus -> unread rooms
if (useUnreadStatus) {
var elm = document.getElementById('_chatUnreadStatus');
if (elm.style.display != 'none') {
totalCount += parseInt(elm.innerHTML);
}
}
// id: _chatToUnreadStatus -> unread rooms (to me)
if (useToUnreadStatus) {
var elm = document.getElementById('_chatToUnreadStatus');
if (elm.style.display != 'none') {
totalCount += parseInt(elm.innerHTML);
}
}
// id: _chatTaskStatus -> uncompleted tasks
if (useTaskStatus) {
var elm = document.getElementById('_chatTaskStatus');
if (elm.style.display != 'none') {
totalCount += parseInt(elm.innerHTML);
}
}
// 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;
}
@chsh

This comment has been minimized.

Copy link
Owner Author

commented Jul 9, 2014

Add patterns: chatwork.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.