Fast Down ATTACK Gobattle.io

When you enter the game press Q

  1. // ==UserScript==
  2. // @name Fast Down ATTACK Gobattle.io
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description When you enter the game press Q
  6. // @author You
  7. // @match https://gobattle.io/#! https://alpha.gobattle.io/#!
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=gobattle.io
  9. // @grant none
  10. // ==/UserScript==
  11. /*
  12. This script is for educational purposes and written by Kuwazy.
  13. It does not allow you to do the fastest attacks but aims to show you how to automate tasks on gobattle and emulate keyboard keys and execute attacks automatically.
  14. Discord: Kuwazy#8194
  15. */
  16.  
  17. const aerial_down_attack_button = "q"; // The key to be pressed to execute the attack.
  18. const attack_frequency = 700 // The attack frequency (in milliseconds).
  19.  
  20. const textfield = document.getElementById("shinobit-textfield"); // The chat input field (the place where you write the message you want to send).
  21.  
  22. /*
  23. It will serve us to have a reference to this element that allows us to know if the user writes a message in the chat.
  24. We want to prevent our attack from triggering when the user writes a message in the in-game messenger.
  25. You will frequently press the attack button while writing a message. it is to avoid this jenr of conflict. :D
  26. */
  27.  
  28.  
  29. let interval_id = null; // The identifier of the interval call. Will be developed below.
  30.  
  31. // When the user presses a button then...
  32. document.addEventListener("keydown", event => {
  33. // ...we execute the code between the brackets.
  34.  
  35. /* In this condition, we check if:
  36. The "aerial_down_attack_button" button is the pressed button
  37. AND
  38. We are not already performing the action.
  39. AND
  40. That the user does not write in the chat input field.
  41. */
  42.  
  43. // If the condition is validated then...
  44. if (event.key === aerial_down_attack_button && !interval_id && textfield !== document.activeElement){
  45. // ...we execute the code between the brackets.
  46.  
  47. // We execute a first attack to start. For this, we just need to call the "aerial_down_attack" function that we defined below in the code.
  48. aerial_down_attack();
  49.  
  50. // Then we ask the script to execute this attack function several times using the "setInterval" method.
  51. // We also give the frequency at which we want this function to be called.
  52. // We also store the id of the setintervale call in a variable. It will be useful for us to cancel the set call interval later.
  53. interval_id = setInterval(aerial_down_attack, attack_frequency);
  54. }
  55. });
  56.  
  57. // When the user releases a previously pressed button then...
  58. document.addEventListener("keyup", event => {
  59. // ...we execute the code between the brackets.
  60.  
  61. /* In this condition, we check if:
  62. The "aerial_down_attack_button" button is the pressed button
  63. AND
  64. That the user does not write in the chat input field.
  65. */
  66.  
  67. // If the condition is validated then...
  68. if (event.key === aerial_down_attack_button && textfield !== document.activeElement){
  69. // ...we execute the code between the brackets.
  70.  
  71. // We want to stop attacking. to do this, simply cancel the call to "setInterval".
  72. clearInterval(interval_id); // It is given the identifier of the "setInterval" to be cancelled.
  73. interval_id = null; // We return this variable to null to support the fact that we are no longer performing any action.
  74. }
  75. });
  76.  
  77.  
  78. // When this function is called, perform the "aerial_down_attack" attack.
  79. function aerial_down_attack(){
  80. // This function itself includes the functions to be executed to perform the attack:
  81.  
  82. jump();
  83.  
  84. // X2
  85. temporarily_crouched();
  86. temporarily_crouched();
  87.  
  88. sword_attack();
  89. }
  90.  
  91.  
  92. function jump(){
  93. //
  94. // /|\ _
  95. // | OR | Z |
  96. // | -
  97. //
  98.  
  99. // We define the key to emulate.
  100. const event = {
  101. "key": "ArrowUp",
  102. "keyCode": 38,
  103. "which": 38,
  104. "code": "ArrowUp",
  105. "location": 0,
  106. "altKey": false,
  107. "ctrlKey": false,
  108. "metaKey": false,
  109. "shiftKey": false,
  110. "repeat": false
  111. };
  112. // We press the button.
  113. document.dispatchEvent(new KeyboardEvent("keydown", event));
  114. // Then we stop pressing.
  115. document.dispatchEvent(new KeyboardEvent("keyup", event));
  116. }
  117.  
  118. function temporarily_crouched(){
  119. //
  120. // | _
  121. // | OR | S |
  122. // \|/ -
  123. //
  124.  
  125. const event = {
  126. "key": "ArrowDown",
  127. "keyCode": 40,
  128. "which": 40,
  129. "code": "ArrowDown",
  130. "location": 0,
  131. "altKey": false,
  132. "ctrlKey": false,
  133. "metaKey": false,
  134. "shiftKey": false,
  135. "repeat": false
  136. };
  137. // We press the button.
  138. document.dispatchEvent(new KeyboardEvent("keydown", event));
  139. // Then we stop pressing.
  140. document.dispatchEvent(new KeyboardEvent("keyup", event));
  141. }
  142.  
  143.  
  144. function sword_attack(){
  145. //
  146. // _
  147. // | V |
  148. // -
  149. //
  150.  
  151. // We define the key to emulate.
  152. const event = {
  153. "key": "v",
  154. "keyCode": 86,
  155. "which": 86,
  156. "code": "KeyV",
  157. "location": 0,
  158. "altKey": false,
  159. "ctrlKey": false,
  160. "metaKey": false,
  161. "shiftKey": false,
  162. "repeat": false
  163. };
  164. // We press the button.
  165. document.dispatchEvent(new KeyboardEvent("keydown", event));
  166. // Then we stop pressing.
  167. document.dispatchEvent(new KeyboardEvent("keyup", event));
  168. }