Sploop.io: Shows CPS and FPS (UPDATED)

-

  1. // ==UserScript==
  2. // @name Sploop.io: Shows CPS and FPS (UPDATED)
  3. // @namespace -
  4. // @version 0.5
  5. // @description -
  6. // @author hi
  7. // @match *://sploop.io/*
  8. // @match *://zombsroyale.io/*
  9. // @grant none
  10. // @antifeature tracking
  11. // @license MIT
  12. // ==/UserScript==
  13. var FPS,cps = 0,Mcps = 0,Hue = 0;
  14. (function() {
  15. var UPDATE_DELAY = 700;
  16. var lastUpdate = 0;
  17. var frames = 0;
  18. function updateCounter() {
  19. var now = Date.now();
  20. var elapsed = now - lastUpdate;
  21. if (elapsed < UPDATE_DELAY) {
  22. ++frames;
  23. } else {
  24. FPS = Math.round(frames / (elapsed / 1000));
  25. frames = 0;
  26. lastUpdate = now;
  27. }
  28. requestAnimationFrame(updateCounter);
  29. }
  30. lastUpdate = Date.now();
  31. requestAnimationFrame(updateCounter);
  32. })();
  33. document.addEventListener("mousedown", click, false);
  34. document.addEventListener("mouseup", endclick, false);
  35. function click(e) {
  36. if ((e.button == 0 || 1 || 2) || e.keycode == 32) {
  37. cps++
  38. setTimeout(() => {
  39. cps--
  40. }, 900);
  41. }
  42. if (e.button == 0) { document.getElementById("LeftClick").style.backgroundColor = "white";}
  43. if (e.button == 2) { document.getElementById("RightClick").style.backgroundColor = "white";}
  44. }
  45. function endclick(e) {
  46. if (e.button == 0) {document.getElementById("LeftClick").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  47. if (e.button == 2) {document.getElementById("RightClick").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  48. }
  49. document.addEventListener('keydown', (e)=>{
  50. if (e.keyCode == 32) {document.getElementById("SpaceBar").style.backgroundColor = "white";
  51. cps++
  52. setTimeout(() => {
  53. cps--
  54. }, 900);}
  55. if (e.keyCode == 87) {document.getElementById("keyW").style.backgroundColor = "white";}
  56. if (e.keyCode == 81) {document.getElementById("keyQ").style.backgroundColor = "white";}
  57. if (e.keyCode == 65) {document.getElementById("keyA").style.backgroundColor = "white";}
  58. if (e.keyCode == 83) {document.getElementById("keyS").style.backgroundColor = "white";}
  59. if (e.keyCode == 68) {document.getElementById("keyD").style.backgroundColor = "white";}
  60. })
  61. document.addEventListener('keyup', (e)=>{
  62. if (e.keyCode == 32) {document.getElementById("SpaceBar").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  63. if (e.keyCode == 87) {document.getElementById("keyW").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  64. if (e.keyCode == 81) {document.getElementById("keyQ").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  65. if (e.keyCode == 65) {document.getElementById("keyA").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  66. if (e.keyCode == 83) {document.getElementById("keyS").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  67. if (e.keyCode == 68) {document.getElementById("keyD").style.backgroundColor = "rgba(0, 0, 0, 0.4)";}
  68. })
  69. setInterval(() => {
  70. if (cps > Mcps) Mcps = cps
  71. Hue += Math.random() * .4
  72. Show.style.color = `hsl(${Hue}, 100%, 70%)`
  73. Panel.style.color = `hsl(${Hue}, 100%, 70%)`
  74. Show.innerHTML = `${FPS}FPS<br>${cps}CPS<br>${Mcps}MCPS`
  75. }, 0);
  76. let Show = document.createElement("div");
  77. Show.id = "SHOW"
  78. document.body.prepend(Show);
  79. let Panel = document.createElement("div");
  80. Panel.innerHTML = `
  81. <div id="Panel">
  82. <div id="keyW">W</div>
  83. <div id="keyQ">Q</div>
  84. <div id="keyA">A</div>
  85. <div id="keyS">S</div>
  86. <div id="keyD">D</div>
  87. <div id="LeftClick">LMB</div>
  88. <div id="RightClick">RMB</div>
  89. <div id="SpaceBar">________</div>
  90. </div>
  91. `
  92. document.body.appendChild(Panel)
  93.  
  94. var styleItem = document.createElement("style");
  95. styleItem.type = "text/css";
  96. styleItem.appendChild(document.createTextNode(`
  97. #SHOW {
  98. font-size: 18px;
  99. position: absolute;
  100. width: 90px;
  101. height: 75px;
  102. top:30px;
  103. left:10px;
  104. z-index:1000000;
  105. display: block;
  106. text-align: center;
  107. border-radius: 20px;
  108. background-color: rgba(0, 0, 0, 0.4);
  109. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  110. }
  111.  
  112. #Panel {
  113. position: relative;
  114. width: 150px;
  115. height: 180px;
  116. top: 120px;
  117. left: 10px;
  118. z-index: 1000000;
  119. display: block;
  120. text-align: center;
  121. }
  122.  
  123.  
  124. #keyW {
  125. position: absolute;
  126. width: 50px;
  127. height: 45px;
  128. top: 0;
  129. left: 50px;
  130. background-color: rgba(0, 0, 0, 0.4);
  131. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  132. border-top-left-radius: 10px;
  133. border-top-right-radius: 10px;
  134. }
  135.  
  136. #keyQ {
  137. position: absolute;
  138. width: 50px;
  139. height: 45px;
  140. top: 0;
  141. left: 0px;
  142. background-color: rgba(0, 0, 0, 0.4);
  143. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  144. border-top-left-radius: 10px;
  145. border-top-right-radius: 10px;
  146. }
  147.  
  148. #keyA {
  149. position: absolute;
  150. width: 50px;
  151. height: 45px;
  152. top: 45px;
  153. left: 0;
  154. background-color: rgba(0, 0, 0, 0.4);
  155. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  156. border-top-left-radius: 10px;
  157. }
  158.  
  159. #keyS {
  160. position: absolute;
  161. width: 50px;
  162. height: 45px;
  163. top: 45px;
  164. left: 50px;
  165. background-color: rgba(0, 0, 0, 0.4);
  166. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  167. }
  168.  
  169. #keyD {
  170. position: absolute;
  171. width: 50px;
  172. height: 45px;
  173. top: 45px;
  174. right: 0;
  175. background-color: rgba(0, 0, 0, 0.4);
  176. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  177. border-top-right-radius: 10px;
  178. }
  179.  
  180. #LeftClick {
  181. position: absolute;
  182. width: 75px;
  183. height: 45px;
  184. top: 90px;
  185. left: 0;
  186. background-color: rgba(0, 0, 0, 0.4);
  187. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  188. }
  189.  
  190. #RightClick {
  191. position: absolute;
  192. width: 75px;
  193. height: 45px;
  194. top: 90px;
  195. right: 0;
  196. background-color: rgba(0, 0, 0, 0.4);
  197. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  198. }
  199.  
  200. #SpaceBar {
  201. position: absolute;
  202. width: 150px;
  203. height: 45px;
  204. bottom: 0;
  205. left: 0;
  206. border-bottom-left-radius: 10px;
  207. border-bottom-right-radius: 10px;
  208. background-color: rgba(0, 0, 0, 0.4);
  209. box-shadow: 0 0 2px #6dd1ff,0 0 0 4px #353535, 0 0 0 5px #3e3e3e, inset 0 0 10px rgba(0, 0, 0, 1), 0 5px 20px rgba(0,0,0,.5), inset 0 0 15px rgba(0,0,0,.2);
  210. }
  211.  
  212. `))
  213. document.head.appendChild(styleItem);
  214. document.getElementById("SHOW").addEventListener('mousedown', function (e) {
  215.  
  216. let prevX = e.clientX;
  217. let prevY = e.clientY;
  218.  
  219. window.addEventListener('mousemove', mousemove);
  220. window.addEventListener('mouseup', mouseup);
  221. function mousemove(e) {
  222. let newX = prevX - e.clientX;
  223. let newY = prevY - e.clientY;
  224.  
  225.  
  226. const rect = document.getElementById("SHOW").getBoundingClientRect();
  227.  
  228. document.getElementById("SHOW").style.left = rect.left - newX + 'px';
  229. document.getElementById("SHOW").style.top = rect.top - newY + 'px';
  230.  
  231. prevX = e.clientX;
  232. prevY = e.clientY;
  233. }
  234. function mouseup() {
  235. window.removeEventListener('mousemove', mousemove);
  236. window.removeEventListener('mouseup', mouseup);
  237. }
  238. });
  239. document.getElementById("Panel").addEventListener('mousedown', function (e) {
  240.  
  241. let prevX = e.clientX;
  242. let prevY = e.clientY;
  243.  
  244. window.addEventListener('mousemove', mousemove);
  245. window.addEventListener('mouseup', mouseup);
  246. function mousemove(e) {
  247. let newX = prevX - e.clientX;
  248. let newY = prevY - e.clientY;
  249.  
  250.  
  251. const rect = document.getElementById("Panel").getBoundingClientRect();
  252.  
  253. document.getElementById("Panel").style.left = rect.left - newX + 'px';
  254. document.getElementById("Panel").style.top = rect.top - newY + 'px';
  255.  
  256. prevX = e.clientX;
  257. prevY = e.clientY;
  258. }
  259. function mouseup() {
  260. window.removeEventListener('mousemove', mousemove);
  261. window.removeEventListener('mouseup', mouseup);
  262. }
  263. });