Last active
October 23, 2017 13:03
-
-
Save mohemohe/8ccc8a722d6a675164eecebdabe5f2ee to your computer and use it in GitHub Desktop.
こぴぺした
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
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