Nitrotype Bot

nitro type hack

  1. // ==UserScript==
  2. // @license MIT
  3. // @description nitro type hack
  4. // @name Nitrotype Bot
  5. // @name Nitro Type Bot 2.0
  6. // @match https://www.nitrotype.com/race
  7. // @match https://www.nitrotype.com/race/*
  8. // @author adl212
  9. // @author RedHawk
  10. // @run-at document-start
  11. // @grant none
  12. // @version 6.9.6
  13. // @namespace https://greatest.deepsurf.us/users/943086
  14. // ==/UserScript==
  15. var wpm = 200;
  16. var accuracy = 100;
  17. const sockets = [];
  18. const nativeWebSocket = window.WebSocket;
  19. window.WebSocket = function(...args){
  20. const socket = new nativeWebSocket(...args);
  21. sockets.push(socket);
  22. return socket;
  23. };
  24. function sleep(s) {
  25. var ms = s*1000;
  26. return new Promise(resolve => setTimeout(resolve, ms));
  27. }
  28. async function main(ws) {
  29. console.log('Message from server ', event.data);
  30. var message = event.data;
  31. function scan_for_text(message){ //Scanning messages to see if we can find the typing text.
  32. try {
  33. message = JSON.parse(message.slice(1,)).payload
  34. return message.l
  35. }
  36. catch {
  37. return null
  38. }
  39. return null
  40. }
  41. async function type(msg, speed, accuracy, nitros='true') {
  42. function len(x) {
  43. return x.length;
  44. }
  45. function str(x) {
  46. return x.toString()
  47. }
  48. function int(x) {
  49. return Number(x)
  50. }
  51. if ((len(msg) == 0) || (msg[0].startsWith("{'user"))) { //These are wrong messages
  52. return
  53. }
  54. function randrange(min, max) {
  55. return Math.floor(Math.random() * (max - min) ) + min;
  56. }
  57. var delay1 = randrange(7, 9) / 10 //If the delays are longer apart, they have more variety. Put in race function
  58. var delay2 = randrange(11, 14) / 10
  59. var words = msg.split(" ") //Turn into a list
  60. var wordString = words.join(' ') //Sounds nicer than "msg"
  61. function findLongestWord(str) {
  62. var longestWord = str.split(' ').sort(function(a, b) { return b.length - a.length; });
  63. return longestWord[0].length;
  64. }
  65. var biggestWord = findLongestWord(wordString);
  66. var list = [];
  67. for (var w in words.slice(0,words.length-1)) {
  68. list.push(w + ' ')
  69. }
  70. function round(x, p) {
  71. return Number.parseFloat(x).toPrecision(p);
  72. }
  73. words = list + words.slice(words.length-1)
  74. var numOfChars = wordString.length
  75. var numOfWords = numOfChars/5
  76. var numOfSecs = (numOfWords/speed) * 60
  77. var sleepTime = numOfSecs / numOfChars
  78. var sleep1 = round((sleepTime * delay1), 6) * 10000000
  79. var sleep2 = round((sleepTime * delay2), 6) * 10000000 //Get time to sleep after each char
  80. if(nitros == 'true'){
  81. var usedNitro = false
  82. } else if (nitros == 'random') { //Random check to see if we should use nitros
  83. var check = randrange(1,3)
  84. if(check == 1) {
  85. usedNitro = false
  86. }
  87. else {
  88. usedNitro = true
  89. }
  90. } else {
  91. usedNitro = true
  92. }
  93. await sleep(4.3);
  94. ws.send('4{"stream":"race","msg":"update","payload":{"t":1,"f":0}}') //First character has to have "f":0
  95. var t = 2
  96. var e = 1
  97. console.log(words);
  98. for (w in words) {
  99. if(int(len(w)) >= int(biggestWord) && usedNitro == false) {
  100. t += len(w)
  101. var payload = '4{"stream":"race","msg":"update","payload":{"n":1,"t":' + str(t) + ',"s":' + str(len(w)) + '}}' //Using nitro
  102. ws.send(payload)
  103. await sleep(0.2)
  104. payload = '4{"stream":"race","msg":"update","payload":{"t":' + str(t) + '}}' //sending another character
  105. ws.send(payload)
  106. t += 1
  107. usedNitro = true
  108. } else {
  109. for (var c in w) {
  110. var errorProbability = randrange(0,100) / 100
  111. var accuracyWrongPercentage = 1 - accuracy/100
  112. if(accuracyWrongPercentage >= errorProbability) {
  113. payload = '4{"stream":"race","msg":"update","payload":{"e":' + str(e) + '}}' //sending error
  114. ws.send(payload)
  115. e += 1
  116. }
  117. if ((t % 4 == 0) || (t >= (numOfChars - 4))) {
  118. payload = '4{"stream":"race","msg":"update","payload":{"t":' + str(t) + '}}' //sending character
  119. ws.send(payload)
  120. }
  121. t += 1
  122. var sleeptime = randrange(int(sleep1), int(sleep2)) / 10000000 //sleep between each character at a random interval according to the WPM
  123. await sleep(sleeptime)
  124. }
  125. }
  126. }
  127. ws.close()
  128. }
  129. var words = scan_for_text(message)
  130. if (words) {
  131. await type(words, wpm, accuracy)
  132. location.reload();
  133. }
  134. }
  135. setTimeout( function () {
  136. var ws = sockets[0];
  137. ws.addEventListener('message', async function(event) {await main(ws, event)});
  138. }, 5000)