Created
November 23, 2016 05:36
-
-
Save scar45/bf2d57a615b000661ca28ea59dc79236 to your computer and use it in GitHub Desktop.
Rambox Custom Badge Code
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() { | |
var e = document.getElementsByClassName("mx_RoomTile_badge"); | |
var t = 0; | |
for(i = 0; i < e.length; i++) { | |
if (parseInt(e[i].textContent.trim()) % 1 === 0 ) { | |
t += parseInt(e[i].textContent.trim()); | |
} | |
} | |
updateBadge(t); | |
} | |
function updateBadge(e) { | |
e >= 1 ? document.title = "(" + e + ") " + originalTitle : document.title = originalTitle | |
} | |
var originalTitle = document.title; | |
setInterval(checkUnread, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment