Skip to content

Instantly share code, notes, and snippets.

@rougetimelord
Last active November 10, 2023 17:36
Show Gist options
  • Save rougetimelord/5d3410517dee069dfce29ebeb9a21185 to your computer and use it in GitHub Desktop.
Save rougetimelord/5d3410517dee069dfce29ebeb9a21185 to your computer and use it in GitHub Desktop.
Spam twitch chat easily
//By rouge(https://github.com/rougetimelord) (c)2016
//Purpose: Create randomly uppercased strings to spam the chats of "twitchplays" streams
//Hook text box
var field = document.getElementsByClassName("js-chat_input")[0];
//Initialize attached text box
var div = document.createElement("div");
div.style.position = "absolute"; div.style.top = "0px"; div.style.left = "0px"; div.style.color = "#FFF"; div.style.zIndex = "100";
var form = document.createElement('form');
var txt = document.createElement('input');
txt.type = 'text'; txt.name = "Cmd";
var btn = document.createElement('input');
btn.type = "button"; btn.value = "Spam away";
btn.addEventListener("click", function(){typer(1);}, false);
var btn2 = document.createElement('input');
btn2.type = "button"; btn2.value = "stop spamming";
btn2.addEventListener("click", function(){typer(0);}, false);
//Attach to DOM
form.appendChild(txt);
form.appendChild(btn);
form.appendChild(btn2);
div.appendChild(form);
document.body.appendChild(div);
//Loop function called every 1000ms
var looper = function(){
var input = txt.value;
var output = "";
for(var i = 0; i < input.length; i++)
{
output += ((Math.floor(Math.random() * 2) + 1) == 1) ? input[i].toUpperCase() : input[i];
}
field.value = output;
}
var loop;
//Initialize or destroy loop
var typer = function(a){
if(a == 1){loop = setInterval(looper, 1E3)}else{clearInterval(loop)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment