Advertisement
Guest User

Erka Slither.io Hack and Mod :D

a guest
Apr 21st, 2016
11,799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.90 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Slither.io Mod
  3. // @namespace Erka
  4. // @version 0.1
  5. // @description Mod
  6. // @author SLITio
  7. // @match http://slither.io
  8. // @updateURL xxxxxxxxxxxxxxxxxxxxx
  9. // @run-at document-body
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14.  
  15. (function(w) {
  16. var modVersion = "v2.0",
  17. renderMode = 2, // 3 - normal, 2 - optimized, 1 - simple (mobile)
  18. normalMode = false,
  19. gameFPS = null,
  20. positionHUD = null,
  21. ipHUD = null,
  22. fpsHUD = null,
  23. styleHUD = "color: #FFF; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 14px; position: fixed; opacity: 0.35; z-index: 7;",
  24. inpNick = null,
  25. currentIP = null,
  26. retry = 0,
  27. bgImage = null;
  28. function init() {
  29. // Append DIVs
  30. appendDiv("position-hud", "nsi", styleHUD + "right: 30; bottom: 120px;");
  31. appendDiv("ip-hud", "nsi", styleHUD + "right: 30; bottom: 150px;");
  32. appendDiv("fps-hud", "nsi", styleHUD + "right: 30; bottom: 170px;");
  33. positionHUD = document.getElementById("position-hud");
  34. ipHUD = document.getElementById("ip-hud");
  35. fpsHUD = document.getElementById("fps-hud");
  36. // Add zoom
  37. if (/firefox/i.test(navigator.userAgent)) {
  38. document.addEventListener("DOMMouseScroll", zoom, false);
  39. } else {
  40. document.body.onmousewheel = zoom;
  41. }
  42. // Quick resp (ESC)
  43. w.onkeydown = function(e) {
  44. if (e.keyCode == 27) {
  45. forceConnect();
  46. }
  47. }
  48. // Hijack console log
  49. /*
  50. if (w.console) {
  51. w.console.logOld = console.log;
  52. w.console.log = getConsoleLog;
  53. }
  54. */
  55. // Set menu
  56. setMenu();
  57. // Set leaderboard
  58. setLeaderboard();
  59. // Set graphics
  60. setGraphics();
  61. // Update loop
  62. updateLoop();
  63. // Show FPS
  64. showFPS();
  65. }
  66. // Append DIV
  67. function appendDiv(id, className, style) {
  68. var div = document.createElement("div");
  69. if (id) {
  70. div.id = id;
  71. }
  72. if (className) {
  73. div.className = className;
  74. }
  75. if (style) {
  76. div.style = style;
  77. }
  78. document.body.appendChild(div);
  79. }
  80. // Zoom
  81. function zoom(e) {
  82. if (!w.gsc) {
  83. return;
  84. }
  85. w.gsc *= Math.pow(0.9, e.wheelDelta / -120 || e.detail / 2 || 0);
  86. }
  87. // Get console log
  88. function getConsoleLog(log) {
  89. //w.console.logOld(log);
  90. if (log.indexOf("FPS") != -1) {
  91. gameFPS = log;
  92. }
  93. }
  94. // Set menu
  95. function setMenu() {
  96. var login = document.getElementById("login");
  97. if (login) {
  98. // Load settings
  99. loadSettings();
  100. // Message
  101. var div = document.createElement("div");
  102. div.style.width = "700px";
  103. div.style.color = "#85f9ae";
  104. div.style.fontFamily = "'Lucida Sans Unicode', 'Lucida Grande', sans-serif";
  105. div.style.fontSize = "14px";
  106. div.style.textAlign = "center";
  107. div.style.opacity = "2";
  108. div.style.margin = "0 auto";
  109. div.style.padding = "5px 0";
  110.  
  111. login.appendChild(div);
  112. // Menu container
  113. var sltMenu = document.createElement("div");
  114. sltMenu.style.width = "360px";
  115. sltMenu.style.color = "#8058D0";
  116. sltMenu.style.backgroundColor = "#1e262e";
  117. sltMenu.style.borderRadius = "29px";
  118. sltMenu.style.fontFamily = "'Lucida Sans Unicode', 'Lucida Grande', sans-serif";
  119. sltMenu.style.fontSize = "14px";
  120. sltMenu.style.textAlign = "center";
  121. sltMenu.style.margin = "0 auto 100px auto";
  122. sltMenu.style.padding = "10px 14px";
  123.  
  124. login.appendChild(sltMenu);
  125. // IP input container
  126. var div = document.createElement("div");
  127. div.style.color = "#8058D0";
  128. div.style.backgroundColor = "#4C447C";
  129. div.style.borderRadius = "29px";
  130. div.style.margin = "10 auto";
  131. div.style.padding = "8px";
  132. sltMenu.appendChild(div);
  133. // IP input
  134. var input = document.createElement("input");
  135. input.id = "server-ip";
  136. input.type = "text";
  137. input.placeholder = "IP";
  138. input.style.height = "26px";
  139. input.style.display = "inline-block";
  140. input.style.background = "none";
  141. input.style.color = "#ffffff";
  142. input.style.border = "none";
  143. input.style.outline = "none";
  144. div.appendChild(input);
  145. // Connect (play) button
  146. var button = document.createElement("input");
  147. button.id = "connect-btn";
  148. button.type = "button";
  149. button.value = "Connect";
  150. button.style.height = "24px";
  151. button.style.display = "inline-block";
  152. button.style.borderRadius = "12px";
  153. button.style.color = "#FFF";
  154. button.style.backgroundColor = "#DC2024";
  155. button.style.border = "none";
  156. button.style.outline = "none";
  157. button.style.cursor = "pointer";
  158. button.style.padding = "0 20px";
  159. div.appendChild(button);
  160. // Select server container
  161. var div = document.createElement("div");
  162. div.style.backgroundColor = "#919191";
  163. div.style.borderRadius = "29px";
  164. div.style.margin = "10 auto";
  165. div.style.padding = "8px";
  166. sltMenu.appendChild(div);
  167. // Select server
  168.  
  169. // Select graph
  170. var select = document.createElement("select");
  171. select.id = "select-graph";
  172. select.style.background = "none";
  173. select.style.border = "none";
  174. select.style.outline = "none";
  175. div.appendChild(select);
  176. var option = document.createElement("option");
  177. option.value = "3";
  178. option.text = " Quality (Super)";
  179. select.appendChild(option);
  180. var option = document.createElement("option");
  181. option.value = "2";
  182. option.text = " Quality(Recording)";
  183. select.appendChild(option);
  184. var option = document.createElement("option");
  185. option.value = "1";
  186. option.text = " Quality (No Lag)";
  187. select.appendChild(option);
  188. // Menu footer
  189. sltMenu.innerHTML += '<a href="https://www.youtube.com/channel/UCHN1q9mi-plz7XRqTVP041g" target="_blank" style="color: #DC2024; opacity: 2;">Subscribe My Youtube Channel</a> ';
  190.  
  191. // Get IP input
  192. inpIP = document.getElementById("server-ip");
  193. // Get nick
  194. var nick = document.getElementById("nick");
  195. nick.addEventListener("input", getNick, false);
  196. // Force connect
  197. var connectBtn = document.getElementById("connect-btn");
  198. connectBtn.onclick = forceConnect;
  199. // Get servers list
  200. getServersList();
  201. // Set graphic mode
  202. var selectGraph = document.getElementById("select-graph");
  203. if (renderMode == 1) {
  204. selectGraph.selectedIndex = 2;
  205. } else if (renderMode == 2) {
  206. selectGraph.selectedIndex = 1;
  207. } else {
  208. selectGraph.selectedIndex = 0;
  209. normalMode = true;
  210. }
  211. selectGraph.onchange = function() {
  212. var mode = selectGraph.value;
  213. if (mode) {
  214. renderMode = mode;
  215. localStorage.setItem("rendermode", renderMode);
  216. }
  217. };
  218. resizeView();
  219. } else {
  220. setTimeout(setMenu, 100);
  221. }
  222. }
  223. // Load settings
  224. function loadSettings() {
  225. if (w.localStorage.getItem("nick") != null) {
  226. var nick = w.localStorage.getItem("nick");
  227. document.getElementById("nick").value = nick;
  228. }
  229. if (w.localStorage.getItem("rendermode") != null) {
  230. var mode = parseInt(w.localStorage.getItem("rendermode"));
  231. if (mode >= 1 && mode <= 3) {
  232. renderMode = mode;
  233. }
  234. }
  235. }
  236. // Get nick
  237. function getNick() {
  238. var nick = document.getElementById("nick").value;
  239. w.localStorage.setItem("nick", nick);
  240. }
  241. // Connection status
  242. function connectionStatus() {
  243. if (!w.connecting || retry == 10) {
  244. w.forcing = false;
  245. retry = 0;
  246. return;
  247. }
  248. retry++;
  249. setTimeout(connectionStatus, 1000);
  250. }
  251. // Force connect
  252. function forceConnect() {
  253. if (inpIP.value.length == 0 || !w.connect) {
  254. return;
  255. }
  256. w.forcing = true;
  257. if (!w.bso) {
  258. w.bso = {};
  259. }
  260. var srv = inpIP.value.trim().split(":");
  261. w.bso.ip = srv[0];
  262. w.bso.po = srv[1];
  263. w.connect();
  264. setTimeout(connectionStatus, 1000);
  265. }
  266. // Get servers list
  267. function getServersList() {
  268. if (w.sos && w.sos.length > 0) {
  269. var selectSrv = document.getElementById("select-srv");
  270. for (var i = 0; i < sos.length; i++) {
  271. var srv = sos[i];
  272. var option = document.createElement("option");
  273. option.value = srv.ip + ":" + srv.po;
  274. option.text = (i + 1) + ". " + option.value;
  275. selectSrv.appendChild(option);
  276. }
  277. selectSrv.onchange = function() {
  278. var srv = selectSrv.value;
  279. inpIP.value = srv;
  280. };
  281. } else {
  282. setTimeout(getServersList, 100);
  283. }
  284. }
  285. // Resize view
  286. function resizeView() {
  287. if (w.resize) {
  288. w.lww = 0; // Reset width (force resize)
  289. w.wsu = 0; // Clear ad space
  290. w.resize();
  291. var wh = Math.ceil(w.innerHeight);
  292. if (wh < 800) {
  293. var login = document.getElementById("login");
  294. w.lgbsc = wh / 800;
  295. login.style.top = - (Math.round(wh * (1 - w.lgbsc) * 1E5) / 1E5) + "px";
  296. if (w.trf) {
  297. w.trf(login, "scale(" + w.lgbsc + "," + w.lgbsc + ")");
  298. }
  299. }
  300. } else {
  301. setTimeout(resizeView, 100);
  302. }
  303. }
  304. // Set leaderboard
  305. function setLeaderboard() {
  306. if (w.lbh) {
  307. w.lbh.textContent = "Leaderboard";
  308. w.lbh.style.fontSize = "20px";
  309. } else {
  310. setTimeout(setLeaderboard, 100);
  311. }
  312. }
  313. // Set normal mode
  314. function setNormalMode() {
  315. normalMode = true;
  316. w.ggbg = true;
  317. if (!w.bgp2 && bgImage) {
  318. w.bgp2 = bgImage;
  319. }
  320. w.render_mode = 2;
  321. }
  322. // Set graphics
  323. function setGraphics() {
  324. if (renderMode == 3) {
  325. if (!normalMode) {
  326. setNormalMode();
  327. }
  328. return;
  329. }
  330. if (normalMode) {
  331. normalMode = false;
  332. }
  333. if (w.want_quality && w.want_quality != 0) {
  334. w.want_quality = 0;
  335. w.localStorage.setItem("qual", "0");
  336. w.grqi.src = "/s/lowquality.png";
  337. }
  338. if (w.ggbg && w.gbgmc) {
  339. w.ggbg = false;
  340. }
  341. if (w.bgp2) {
  342. bgImage = w.bgp2;
  343. w.bgp2 = null;
  344. }
  345. if (w.high_quality) {
  346. w.high_quality = false;
  347. }
  348. if (w.gla && w.gla != 0) {
  349. w.gla = 0;
  350. }
  351. if (w.render_mode && w.render_mode != renderMode) {
  352. w.render_mode = renderMode;
  353. }
  354. }
  355. // Show FPS
  356. function showFPS() {
  357. if (w.playing && fpsHUD && w.fps && w.lrd_mtm) {
  358. if (Date.now() - w.lrd_mtm > 970) {
  359.  
  360. }
  361. }
  362. setTimeout(showFPS, 30);
  363. }
  364. // Update loop
  365. function updateLoop() {
  366. setGraphics();
  367. if (w.playing) {
  368. if (positionHUD) {
  369. positionHUD.textContent = "X: " + (~~w.view_xx || 0) + " Y: " + (~~w.view_yy || 0);
  370. }
  371. if (inpIP && w.bso && currentIP != w.bso.ip + ":" + w.bso.po) {
  372. currentIP = w.bso.ip + ":" + w.bso.po;
  373. inpIP.value = currentIP;
  374. if (ipHUD) {
  375. ipHUD.textContent = "IP: " + currentIP;
  376. }
  377. }
  378. }
  379. setTimeout(updateLoop, 1000);
  380. }
  381. // Init
  382. init();
  383. })(window);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement