Keystrokes for Sploop.io

Keystrokes made for Sploop.io! | For support please join our Discord - https://discord.gg/zpVgaMdrrd

  1. // ==UserScript==
  2. // @name Keystrokes for Sploop.io
  3. // @version 0.4
  4. // @description Keystrokes made for Sploop.io! | For support please join our Discord - https://discord.gg/zpVgaMdrrd
  5. // @author Ashureth
  6. // @match *://*sploop.io/*
  7. // @license MIT
  8. // @grant none
  9. // @namespace Keystrokes
  10. // ==/UserScript==
  11.  
  12. // VERSIONS
  13.  
  14. /*
  15. 0.2 - Fixed some key bugs
  16. 0.3 - Fixed so that keys don't react when you're chatting or if you are in the clan tab.
  17. 0.4 - Added some smooth color changing to the keystrokes
  18. */
  19.  
  20.  
  21. function Blocking() {
  22. return document.getElementById('chat-wrapper').offsetParent == null && document.getElementById('clan-menu').offsetParent == null && document.getElementById('play-text').offsetParent == null;
  23. }
  24.  
  25. let html = `
  26. <html>
  27.  
  28. <style>
  29. .KeyBoard {
  30. position: absolute;
  31. width: 300px;
  32. height: 200px;
  33. top: 200px;
  34. left: -50px;
  35. padding: 15px;
  36. text-align: center;
  37. border-radius: 15px;
  38. }
  39. .line {
  40. width: 300px;
  41. height: 60px;
  42. display: flex;
  43. align-items: center;
  44. justify-content: center;
  45. }
  46. .line2 {
  47. width: 300px;
  48. height: 60px;
  49. display: flex;
  50. align-items: center;
  51. justify-content: center;
  52. }
  53. .Key {
  54. display: flex;
  55. justify-content: center;
  56. align-items: center;
  57. font-size: 20px;
  58. width: 50px;
  59. height: 50px;
  60. left: 0px;
  61. top: 0px;
  62. border: 3px solid black;
  63. background: #2F3336;
  64. color: #fff;
  65. margin: 5px;
  66. border-radius: 12px;
  67. box-shadow: 0px 0px 5px hsl(0, 0%, 0%);
  68. overflow: hidden;
  69. transition: .2s ease-in-out;
  70. }
  71. .Space {
  72. display: flex;
  73. justify-content: center;
  74. align-items: center;
  75. font-size: 25px;
  76. width: 200px;
  77. height: 50px;
  78. left: 0px;
  79. top: 0px;
  80. border: 3px solid black;
  81. background: #2F3336;
  82. color: #fff;
  83. margin: 2px;
  84. border-radius: 12px;
  85. box-shadow: 0px 0px 10px hsl(0, 0%, 0%);
  86. overflow: hidden;
  87. }
  88. .keyText {
  89. font-family: Helvetica;
  90. -webkit-user-select: none;
  91. -webkit-touch-callout: none;
  92. -moz-user-select: none;
  93. -ms-user-select: none;
  94. user-select: none;
  95. text-shadow: 0px 0px 10px hsl(0, 0%, 100%);
  96. }
  97.  
  98.  
  99. </style>
  100. <head>
  101.  
  102. <html>
  103. <head>
  104. </head>
  105. <body></body>
  106. </html>
  107.  
  108. <div class="KeyBoard" id='keyboard'>
  109. <div class="line">
  110. <div class="Key" id="keyQ">
  111. <span class="keyText">Q</span>
  112. </div>
  113. <div class="Key" id="keyW">
  114. <span class="keyText">W</span>
  115. </div>
  116. <div class="Key" id="keyE">
  117. <span class="keyText">E</span>
  118. </div>
  119. </div>
  120. <div class="line2">
  121. <div class="Key" id="keyA">
  122. <span class="keyText" id="keyA">A</span>
  123. </div>
  124. <div class="Key" id="keyS">
  125. <span class="keyText">S</span>
  126. </div>
  127. <div class="Key" id="keyD">
  128. <span class="keyText">D</span>
  129. </div>
  130. </div>
  131. <div class="line">
  132. <div class="Space" id="keySpace">
  133. <span class="keyText">━━━━━</span>
  134. </div>
  135. </div>
  136. </div>
  137. </head>
  138.  
  139. <body>
  140. </body>
  141.  
  142. </html>
  143. `
  144.  
  145. let backgroundd = document.getElementById('backgroundd');
  146.  
  147.  
  148. let HeldKeys = [];
  149. let EToggle = false;
  150.  
  151. setInterval(() => {
  152.  
  153. if(document.getElementById('play-text').offsetParent !== null) {
  154. EToggle = false;
  155. }
  156.  
  157. var Element;
  158.  
  159. let arr = ['W', 'A', 'S', 'D', 'E', 'Q', 'Space'];
  160.  
  161. for(let i of arr) {
  162. i != 'E' && document.getElementById(`key${i}`) && (document.getElementById(`key${i}`).style.background = '#2F3336');
  163. }
  164.  
  165.  
  166. for(let Key in HeldKeys) {
  167. if(HeldKeys[Key] != 'E' && HeldKeys[Key] != null) {
  168. Element = document.getElementById(`key${HeldKeys[Key]}`);
  169.  
  170. if(Element) {
  171. Element.style.background = '#52585e'
  172. }
  173. } else {
  174. Element = document.getElementById(`keyE`);
  175.  
  176. Element.style.background = EToggle ? '#52585e' : '#2F3336';
  177.  
  178. }
  179. }
  180. });
  181.  
  182. document.body.insertAdjacentHTML('beforeend', html);
  183.  
  184. let game = document.getElementById('game-canvas');
  185.  
  186. window.addEventListener('keydown', e => {
  187. if(!Blocking()) return;
  188. let isSpace = e.key === ' ';
  189. if(isSpace) {
  190. HeldKeys['Space'] = 'Space';
  191. } else {
  192. if(e.key == 'e') {
  193. EToggle = !EToggle;
  194. } else {
  195. HeldKeys[e.key.toUpperCase()] = e.key.toUpperCase();
  196. }
  197. }
  198. });
  199. window.addEventListener('keyup', e => {
  200. let isSpace = e.key === ' ';
  201. if(isSpace) {
  202. HeldKeys['Space'] = null;
  203. } else {
  204. HeldKeys[e.key.toUpperCase()] = null;
  205. }
  206. });