Skip to content

Instantly share code, notes, and snippets.

@mohemohe
Last active October 23, 2017 13:03
Show Gist options
  • Save mohemohe/8ccc8a722d6a675164eecebdabe5f2ee to your computer and use it in GitHub Desktop.
Save mohemohe/8ccc8a722d6a675164eecebdabe5f2ee to your computer and use it in GitHub Desktop.
こぴぺした
function checkUnread() {
const unreadsArray = document.querySelectorAll('.channel_name .badge.pull-right');
let counter = 0;
unreadsArray.forEach((value, index, array) => {
const innterString = value.innerHTML;
const parseData = parseInt(innterString, 10);
if(!isNaN(parseData)) {
counter += parseData;
}
});
updateBadge(counter);
}
function updateBadge(e) {
e >= 1 ? document.title = "(" + e + ") " + originalTitle :
document.title = originalTitle
}
var originalTitle = document.title;
setInterval(checkUnread, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment