Last active
January 2, 2018 05:21
-
-
Save Dinir/220a35d4fb90dd918328fcb792e17723 to your computer and use it in GitHub Desktop.
add random number of digits to Streamlabs' host alert message in the viewer count
This file contains hidden or 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
var randomNumber = function(length, isLengthRandom = false) { | |
var number = 0; | |
actualLength = isLengthRandom? | |
parseInt(Math.random()*length)+1: | |
length; | |
number = parseInt(Math.random()*Math.pow(10, actualLength)); | |
return number; | |
} | |
var formatEachLetter = function(str, format, indicator) { | |
var formatted = ""; | |
for(var i=0; i<str.length; i++) { | |
formatted += format.replace(indicator, str[i]); | |
} | |
return formatted; | |
} | |
var modifyNumber = setInterval(function() { | |
var numberDom = document. | |
querySelector("#alert-message > span:nth-child(2) > span"); | |
numberDom.innerHTML = | |
numberDom.innerHTML.trim() + | |
formatEachLetter( | |
""+randomNumber(3, true), | |
'<span class="animated-letter None">#</span>', | |
"#" | |
); | |
clearInterval(modifyNumber); | |
}, 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment