Advertisement
Guest User

bot

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.08 KB | None | 0 0
  1. // ==UserScript==
  2. // @name GUI For YT Printscreen
  3. // @version 1.0
  4. // @description Best GUI Client
  5. // @author AuraYoutube
  6. // @match *.cellcraft.io/*
  7. // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. var socket = io.connect("ws://Bots-printscreenz1995427027.codeanyapp.com:8081");
  13. var maxBots = 500;
  14. var serverURL = null;
  15. var origin = location.origin;
  16. var botName = "";
  17. var client_uuid = "GFB";
  18.  
  19. var userCoordinates = {
  20. x : 0,
  21. y : 0,
  22. l : 0,
  23. ma : 0,
  24. mb : 0
  25. };
  26. function reset() {
  27. socket.emit("pos", {
  28. "x" : userCoordinates.x - userCoordinates.ma,
  29. "y" : userCoordinates.y - userCoordinates.mb,
  30. "l" : userCoordinates.l,
  31. "p" : 0,
  32. "c" : false,
  33. "botName" : window.name || botName
  34. });
  35. }
  36. function init() {
  37. last_transmited_game_server = serverURL;
  38. socket.emit("cmd", {
  39. "name" : "connect_server",
  40. "ip" : serverURL,
  41. "origin" : location.origin,
  42. "max" : maxBots,
  43. "BotName" : botName
  44. });
  45. }
  46. function msToTime(s) {
  47. if(s<0){return '0h 0m 0s';}
  48. var ms = s % 1000;
  49. s = (s - ms) / 1000;
  50. var secs = s % 60;
  51. s = (s - secs) / 60;
  52. var mins = s % 60;
  53. var hrs = (s - mins) / 60;
  54. secs = (secs.toString().length<2 ? '0' : '') + secs;
  55. mins = (mins.toString().length<2 ? '0' : '') + mins;
  56. hrs = (hrs.toString().length<2 ? '0' : '') + hrs;
  57. return hrs + ':' + mins + ':' + secs;
  58. }
  59. socket.on('time-left', function(count) {
  60. $("#timeCount").html(msToTime(count));
  61. });
  62. setTimeout(function() {
  63. window.__WebSocket = window.WebSocket;
  64. window.fakeWebSocket = function() {
  65. return{
  66. readyState : 0
  67. };
  68. };
  69. window._WebSocket = window.WebSocket = function(url) {
  70. return new window.fakeWebSocket(url);
  71. };
  72. window.addEventListener("load", function() {
  73. if (!window.OldSocket) {
  74. OldSocket = window.__WebSocket;
  75. }
  76. window._WebSocket = window.WebSocket = window.fakeWebSocket = function(vfs) {
  77. var socket = new OldSocket(vfs);
  78. socket.binaryType = "arraybuffer";
  79. var self = {};
  80. var m;
  81. for (m in socket) {
  82. self[m] = socket[m];
  83. }
  84. self.send = function() {
  85. var data = new DataView(arguments[0]);
  86. if (data.byteLength == 21) {
  87. if (data.getInt8(0, true) == 16) {
  88. userCoordinates.x = data.getFloat64(1, true);
  89. userCoordinates.y = data.getFloat64(9, true);
  90. userCoordinates.l = data.byteLength;
  91. }
  92. } else {
  93. if (data.byteLength == 13) {
  94. if (data.getUint8(0, true) == 16) {
  95. userCoordinates.x = data.getInt32(1, true);
  96. userCoordinates.y = data.getInt32(5, true);
  97. userCoordinates.l = data.byteLength;
  98. } else {
  99. if (data.byteLength > 4) {
  100. if (data.getUint8(0, true) == 16) {
  101. userCoordinates.x = data.getInt16(1, true);
  102. userCoordinates.y = data.getInt16(3, true);
  103. userCoordinates.l = data.byteLength;
  104. }
  105. }
  106. }
  107. }
  108. }
  109. return socket.send.apply(socket, arguments);
  110. };
  111. socket.onmessage = function() {
  112. var data = new DataView(arguments[0].data);
  113. if (data.byteLength > 16) {
  114. if (data.getUint8(0, true) == 64) {
  115. userCoordinates.ma = data.getFloat64(1, true);
  116. userCoordinates.mb = data.getFloat64(9, true);
  117. }
  118. }
  119. if (self.onmessage) {
  120. self.onmessage.apply(socket, arguments);
  121. }
  122. };
  123. socket.onopen = function() {
  124. serverURL = socket.url;
  125. self.readyState = 1;
  126. self.onopen.apply(socket, arguments);
  127. };
  128. socket.onclose = function() {
  129. self.readyState = 0;
  130. self.onclose.apply(socket, arguments);
  131. };
  132. return self;
  133. };
  134. });
  135. var xhtml = "";
  136. var css = "position: absolute; left: 1.5em; top: 10em; color: #e74c3c; padding: 20px 20px; border-radius: 8px; font-family: \'Ubuntu\'; color: #e74c3c; z-index: 9999; min-height: 10px; min-width: 200px; background-image: url(https://media.giphy.com/media/xTiTnxpQ3ghPiB2Hp6/giphy.gif);";
  137. xhtml += '<div id="botMenu" style="' + css + '">';
  138. xhtml += '<center><b style="color: #FFFFFF; font-family: arial;">PrintScreen Bots<b></center>';
  139. xhtml += "<hr>";
  140. xhtml += '<b style="color: #FFFFFF; font-family: arial;">Bots:</b> <span id="minionCount" class="label label-info pull-right" style="border-radius: 1px;">Connecting...</span><br>';
  141. xhtml += '<b style="color: #FFFFFF; font-family: arial;">Server IP: </b> <span id="serverURL" class="label label-warning pull-right" style="border-radius: 1px;">Connecting...</span>';
  142. xhtml += "<br>";
  143. xhtml += '<b style="color: #FFFFFF; font-family: arial;">Time Left: </b> <span id="timeCount" class="label label-success pull-right" style="border-radius: 1px;">00:00:00</span>';
  144. xhtml += "<hr>";
  145. xhtml += '<b style="color: #FFFFFF; font-family: arial;">UUID:</b> <span id="uuidCount" class="label label-info pull-right" style="border-radius: 1px;">Waiting...</span><br>';
  146. xhtml += "<hr>";
  147. xhtml += "<left><b style='color: #FFFFFF; font-family: arial;'>R - Bots Feed </left> ";
  148. xhtml += "<br>";
  149. xhtml += "<left><b style='color: #FFFFFF; font-family: arial;'>E - Split Bots </left>";
  150. xhtml += "<br>";
  151. xhtml += '<button id="start-bots" style="margin: 10px; left: 200px; opacity: 0.9; background-color: #1da0a5; width: 150px;" class="btn btn-needs-server btn-success">Start Bots</button>';
  152. if (!document.contains(document.getElementById("q"))) {
  153. var e = document.createElement("div");
  154. e.id = "minionsBlock";
  155. e.innerHTML = xhtml;
  156. document.body.appendChild(e);
  157. }
  158. socket.on("time-left", function(tail) {
  159. $("#timeCount").html(isArray(tail));
  160. });
  161. last_transmited_game_server = null;
  162. socket.on("force-login", function(dataAndEvents) {
  163. socket.emit("login", {
  164. "uuid" : "GFB",
  165. "type" : "client"
  166. });
  167. });
  168. socket.emit("login", client_uuid);
  169. socket.on("spawn-count", function(o) {
  170. document.getElementById("minionCount").innerHTML = o + "/" + maxBots;
  171. document.getElementById("uuidCount").innerHTML = client_uuid;
  172. document.getElementById("serverURL").innerHTML = serverURL;
  173. });
  174. document.getElementById("start-bots").onclick = function() {
  175. socket.emit("pos", {
  176. "r" : init(),
  177. "x" : userCoordinates.x - userCoordinates.ma,
  178. "y" : userCoordinates.y - userCoordinates.mb,
  179. "l" : userCoordinates.l,
  180. "p" : 0,
  181. "botName" : window.name || botName,
  182. "bpi" : botsPerIp
  183. });
  184. };
  185. interval_id = setInterval(function() {
  186. reset();
  187. }, 500);
  188. console.log(client_uuid);
  189. document.addEventListener('keydown', function(e) {
  190. var key = e.keyCode || e.which;
  191. switch (key) {
  192. case 16:
  193. if(!window.__botclonsData.sa){
  194. window.__botclonsData.sa=true;
  195. window.__botclonsData.s = setInterval(function() {
  196. $("body").trigger($.Event("keydown", { keyCode: 32}));
  197. $("body").trigger($.Event("keyup", { keyCode: 32}));
  198. }, 10);
  199. }
  200. break;
  201. case 87:
  202. if(!window.__botclonsData.wa){
  203. window.__botclonsData.wa=true;
  204. window.__botclonsData.w = setInterval(function() {
  205. $("body").trigger($.Event("keydown", { keyCode: 87}));
  206. $("body").trigger($.Event("keyup", { keyCode: 87}));
  207. }, 10);
  208. }
  209. break;
  210. case 65:
  211. window.__botclonsData.p--;
  212. document.getElementById('ismoveToMouse').innerHTML = window.__botclonsData.p;
  213. break;
  214. case 67:
  215. window.__botclonsData.q=!window.__botclonsData.q;
  216. if(window.__botclonsData.q) { document.getElementById('dfdghehfj').innerHTML = "On"; } else { document.getElementById('dfdghehfj').innerHTML = "Off"; }
  217. break;
  218. case 69:
  219. socket.emit("cmd", {
  220. "name": "split"
  221. });
  222. break;
  223. case 82:
  224. socket.emit("cmd", {
  225. "name": "eject"
  226. });
  227. break;
  228. case 80:
  229. window.__botclonsData.p++;
  230. document.getElementById('ismoveToMouse').innerHTML = window.__botclonsData.p;
  231. break;
  232. }
  233. });
  234. document.addEventListener('keyup', function(e) {
  235. var key = e.keyCode || e.which;
  236. console.log(key);
  237. switch (key) {
  238. case 87:
  239. clearInterval(window.__botclonsData.w);
  240. window.__botclonsData.wa=false;
  241. break;
  242. case 16:
  243. clearInterval(window.__botclonsData.s);
  244. window.__botclonsData.sa=false;
  245. break;
  246. }
  247. });
  248. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement