Skip to content

Commit

Permalink
Add bot files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dabsunter committed Aug 26, 2016
1 parent 2050cad commit 501cb2b
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions dictionary.js

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions exploder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
function writeChat(text){
var line = document.createElement('li');
line[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = text;
document.getElementById("ChatLog").appendChild(line);
}

function updateStatus(text){
currentStatus[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = text;
}

function setWord(w, i){
channel.socket.emit("setWord", {word: w.substring(0,i),validate: (w.length == i)});
if (i<w.length) {
setTimeout(function(){setWord(w,++i);},rand(75,175));
}
}

function rand(min, max){
return Math.trunc(Math.random()*(max-min)+min);
}

channel.socket.on("setActivePlayerIndex", function (a) {
if(channel.data.actors[channel.data.activePlayerIndex].authId === app.user.authId && injector.autoInject){
setTimeout(injector.inject,rand(400,1100));
}
});
channel.socket.on("failWord", function (a) {
if(channel.data.actors[channel.data.activePlayerIndex].authId === app.user.authId && injector.autoInject){
setTimeout(injector.inject,rand(400,1100));
}
});

var injector = {
lastWord: 0,
autoInject: false,

toggleAutoInject: function(){
if(injector.autoInject){
injector.autoInject = false;
autoInjectIndicator[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Auto Inject Off';
} else {
injector.autoInject = true;
autoInjectIndicator[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Auto Inject On';
}
},

inject: function() {
if(window.app.user.authId == channel.data.actors[channel.data.activePlayerIndex].authId){
updateStatus("Injecting normally");
var q = new RegExp(channel.data.wordRoot,"i");
var i = injector.lastWord;
while(i != ++injector.lastWord){
if(injector.lastWord==words.length){
injector.lastWord = 0;
}
if(words[injector.lastWord].match(q)){
for(var j = 0;j<channel.data.actorsByAuthId[window.app.user.authId].lockedLetters.length;j++){
if(words[injector.lastWord].match(new RegExp(channel.data.actorsByAuthId[window.app.user.authId].lockedLetters[j],"i"))) {
setWord(words[injector.lastWord],1);
return;
}
}
}
}
injector.lastWord = 0;
updateStatus("Normal Inject Failed");
}
}
};

function createInLine(parent,newThingType){
var line = document.createElement('li');
var thing = document.createElement(newThingType);
parent.appendChild(line);
line.appendChild(thing);
return thing;
}

parentThing = document.getElementById("SettingsTab");
parentThing.align = "left";
injectButton = createInLine(parentThing,'button');
injectButton[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Inject';
injectButton.addEventListener('click',injector.inject);
autoButton = createInLine(parentThing,'button');
autoButton[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Auto ';
autoButton.addEventListener('click',injector.toggleAutoInject);
var autoInjectIndicator = document.createElement('li');
parentThing.appendChild(autoInjectIndicator);
var currentStatus = document.createElement('li');
parentThing.appendChild(currentStatus);
var wordScript = document.createElement("script");
wordScript.src = "http://dabsunter.github.io/sparklin-exploder/dictionary.js";
document.head.appendChild(wordScript);

0 comments on commit 501cb2b

Please sign in to comment.