Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. function writeChat(text){
  2. var line = document.createElement('li');
  3. line[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = text;
  4. document.getElementById("ChatLog").appendChild(line);
  5.  
  6. }
  7. function updateStatus(text){
  8. currentStatus[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = text;
  9. }
  10. channel.socket.on("setActivePlayerIndex", function (a) {
  11. if(channel.data.actors[channel.data.activePlayerIndex].authId === app.user.authId && injector.autoInject){
  12. setTimeout(injector.inject,250);
  13. }
  14. });
  15. var injector = {
  16. lastWord: null,
  17. autoInject: false,
  18. toggleAutoInject: function(){
  19. if(injector.autoInject){
  20. injector.autoInject = false;
  21. autoInjectIndicator[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Auto Inject Off';
  22. }
  23. else
  24. {
  25. injector.autoInject = true;
  26. autoInjectIndicator[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Auto Inject On';
  27. }
  28. },
  29. inject: function() {
  30. injector.lastWord = null;
  31. if(window.app.user.authId == channel.data.actors[channel.data.activePlayerIndex].authId){
  32. updateStatus("Injecting normally");
  33. var q = channel.data.wordRoot;
  34. for(var i = 0;i<=injector.wordList.length; i++){
  35. if(i==injector.wordList.length){
  36. updateStatus("Normal Inject Failed");
  37. setTimeout(injector.injectPanic());
  38. return;
  39. }
  40. if(injector.wordList[i].indexOf(q.toLowerCase())!=-1){
  41. for(var j = 0;j<channel.data.actorsByAuthId[window.app.user.authId].lockedLetters.length;j++){
  42. if(injector.wordList[i].indexOf(channel.data.actorsByAuthId[window.app.user.authId].lockedLetters[j].toLowerCase())!=-1){
  43. channel.socket.emit("setWord", {word: injector.wordList[i],validate: true});
  44. injector.lastWord = i;
  45. setTimeout(injector.injectInternal,250);
  46. return;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. },
  53. injectInternal: function() {
  54. var q = channel.data.wordRoot;
  55. if(window.app.user.authId == channel.data.actors[channel.data.activePlayerIndex].authId){
  56. for(var i = injector.lastWord+1;i<=injector.wordList.length;i++){
  57. if(i==injector.wordList.length){
  58. updateStatus("Normal Injection Failed");
  59. setTimeout(injector.injectPanic(),250);
  60. return;
  61. }
  62. if(injector.wordList[i].indexOf(q.toLowerCase())!=-1){
  63. for(var j = 0;j<channel.data.actorsByAuthId[window.app.user.authId].lockedLetters.length;j++){
  64. if(injector.wordList[i].indexOf(channel.data.actorsByAuthId[window.app.user.authId].lockedLetters[j].toLowerCase())!=-1){
  65. channel.socket.emit("setWord", {word: injector.wordList[i],validate: true});
  66. injector.lastWord = i;
  67. setTimeout(injector.injectInternal,250);
  68. return;
  69. }
  70. }
  71. }
  72. }
  73. setTimeout(injector.injectPanic,250);
  74.  
  75. }
  76. },
  77. injectPanic: function() {
  78. injector.lastWord = null;
  79. if(window.app.user.authId == channel.data.actors[channel.data.activePlayerIndex].authId){
  80. updateStatus("Starting Panic Injection");
  81. var q = channel.data.wordRoot;
  82. for(var i = 0;i<=injector.wordList.length; i++){
  83. if(i==injector.wordList.length){
  84. updateStatus("No Words Work. GAME OVER");
  85. return;
  86. }
  87. if(injector.wordList[i].indexOf(q.toLowerCase())!=-1){
  88. channel.socket.emit("setWord", {word: injector.wordList[i],validate: true});
  89. injector.lastWord = i;
  90. setTimeout(injector.injectInternalPanic,250);
  91. return;
  92. }
  93. }
  94. }
  95. },
  96. injectInternalPanic: function() {
  97. var q = channel.data.wordRoot;
  98. if(window.app.user.authId == channel.data.actors[channel.data.activePlayerIndex].authId){
  99. for(var i = injector.lastWord+1;i<=injector.wordList.length;i++){
  100. if(i==injector.wordList.length){
  101. updateStatus("No Words Work. GAME OVER");
  102. return;
  103. }
  104. if(injector.wordList[i].indexOf(q.toLowerCase())!=-1){
  105. channel.socket.emit("setWord", {word: injector.wordList[i],validate: true});
  106. injector.lastWord = i;
  107. setTimeout(injector.injectInternalPanic,250);
  108. return;
  109. }
  110. }
  111. }
  112. }
  113. };
  114. function createInLine(parent,newThingType){
  115. var line = document.createElement('li');
  116. var thing = document.createElement(newThingType);
  117. parent.appendChild(line);
  118. line.appendChild(thing);
  119. return thing;
  120. }
  121. parentThing = document.getElementById("SettingsTab");
  122. injectButton = createInLine(parentThing,'button');
  123. injectButton[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Inject';
  124. parentThing.align = "left";
  125. injectButton.addEventListener('click',injector.inject);
  126. panicButton = createInLine(parentThing,'button');
  127. panicButton[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Panic ';
  128. panicButton.addEventListener('click',injector.injectPanic);
  129. autoButton = createInLine(parentThing,'button');
  130. autoButton[(typeof document.body.style.WebkitAppearance=="string")?"innerText":"innerHTML"] = 'Auto ';
  131. autoButton.addEventListener('click',injector.toggleAutoInject);
  132. var autoInjectIndicator = document.createElement('li');
  133. parentThing.appendChild(autoInjectIndicator);
  134. var currentStatus = document.createElement('li');
  135. parentThing.appendChild(currentStatus);
  136.  
  137. var wordScript = document.createElement("script");
  138. wordScript.src = "https://dl.dropboxusercontent.com/u/9328924/wordf.js";
  139. document.head.appendChild(wordScript);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement