SLITio by szymy

slither.io MOD

  1. // ==UserScript==
  2. // @name SLITio by szymy
  3. // @namespace slitio.szymy
  4. // @version 0.1.18
  5. // @description slither.io MOD
  6. // @author szymy
  7. // @match http://slither.io/*
  8. // @run-at document-body
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // Source: http://slitio.ogario.ovh
  13.  
  14. (function(w) {
  15. var modVersion = "v0.1.18",
  16. renderMode = 2, // 3 - normal, 2 - optimized, 1 - simple (mobile)
  17. normalMode = false,
  18. gameFPS = null,
  19. positionHUD = null,
  20. ipHUD = null,
  21. scoreHUD = 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. rotate = false,
  29. highScore = 0;
  30. function init() {
  31. // Append DIVs
  32. appendDiv("position-hud", "nsi", styleHUD + "right: 30; bottom: 120px;");
  33. appendDiv("ip-hud", "nsi", styleHUD + "right: 30; bottom: 150px;");
  34. appendDiv("score-hud", "nsi", styleHUD + "right: 30; bottom: 170px;");
  35. appendDiv("fps-hud", "nsi", styleHUD + "right: 30; bottom: 190px;");
  36. positionHUD = document.getElementById("position-hud");
  37. ipHUD = document.getElementById("ip-hud");
  38. scoreHUD = document.getElementById("score-hud");
  39. fpsHUD = document.getElementById("fps-hud");
  40. // Add zoom
  41. if (/firefox/i.test(navigator.userAgent)) {
  42. document.addEventListener("DOMMouseScroll", zoom, false);
  43. } else {
  44. document.body.onmousewheel = zoom;
  45. }
  46. // Keys
  47. w.addEventListener("keydown", function(e) {
  48. switch(e.keyCode) {
  49. // ESC - quick resp
  50. case 27: quickResp();
  51. break;
  52. // A - Auto skin rotator
  53. case 65:
  54. rotate = !rotate;
  55. rotateSkin();
  56. break;
  57. // Q - Quit to menu
  58. case 81: quit();
  59. break;
  60. // S - Change skin
  61. case 83: changeSkin();
  62. break;
  63. // Z - Reset zoom
  64. case 90: resetZoom();
  65. break;
  66. }
  67. }, false);
  68. // Hijack console log
  69. /*
  70. if (w.console) {
  71. w.console.logOld = console.log;
  72. w.console.log = getConsoleLog;
  73. }
  74. */
  75. // Set menu
  76. setMenu();
  77. // Set leaderboard
  78. setLeaderboard();
  79. // Set graphics
  80. setGraphics();
  81. // Update loop
  82. updateLoop();
  83. // Show FPS
  84. showFPS();
  85. }
  86. // Append DIV
  87. function appendDiv(id, className, style) {
  88. var div = document.createElement("div");
  89. if (id) {
  90. div.id = id;
  91. }
  92. if (className) {
  93. div.className = className;
  94. }
  95. if (style) {
  96. div.style = style;
  97. }
  98. document.body.appendChild(div);
  99. }
  100. // Zoom
  101. function zoom(e) {
  102. if (!w.gsc || !w.playing) {
  103. return;
  104. }
  105. w.gsc *= Math.pow(0.9, e.wheelDelta / -120 || e.detail / 2 || 0);
  106. }
  107. // Reset zoom
  108. function resetZoom() {
  109. w.gsc = 0.9;
  110. }
  111. // Get console log
  112. function getConsoleLog(log) {
  113. //w.console.logOld(log);
  114. if (log.indexOf("FPS") != -1) {
  115. gameFPS = log;
  116. }
  117. }
  118. // Set menu
  119. function setMenu() {
  120. var login = document.getElementById("login");
  121. if (login) {
  122. // Unblock skins
  123. w.localStorage.setItem("edttsg", "1");
  124. // Load settings
  125. loadSettings();
  126. // Keys info
  127. var div = document.createElement("div");
  128. div.style.width = "300px";
  129. div.style.color = "#56ac81";
  130. div.style.fontFamily = "'Lucida Sans Unicode', 'Lucida Grande', sans-serif";
  131. div.style.fontSize = "12px";
  132. div.style.textAlign = "center";
  133. div.style.opacity = "0.5";
  134. div.style.margin = "0 auto";
  135. div.style.padding = "10px 0";
  136. div.innerHTML = "[ESC] - Quick resp | [Q] - Quit to menu<br/>[A] - Auto skin rotator | [S] - Change skin<br/>[Z] - Reset zoom | [Space] - Boost";
  137. login.appendChild(div);
  138. // Menu container
  139. var sltMenu = document.createElement("div");
  140. sltMenu.style.width = "260px";
  141. sltMenu.style.color = "#8058D0";
  142. sltMenu.style.backgroundColor = "#1e262e";
  143. sltMenu.style.borderRadius = "29px";
  144. sltMenu.style.fontFamily = "'Lucida Sans Unicode', 'Lucida Grande', sans-serif";
  145. sltMenu.style.fontSize = "14px";
  146. sltMenu.style.textAlign = "center";
  147. sltMenu.style.margin = "0 auto 100px auto";
  148. sltMenu.style.padding = "10px 14px";
  149. sltMenu.innerHTML = "MOD: <strong>SLITio by szymy</strong> | <strong>" + modVersion + "</strong>";
  150. login.appendChild(sltMenu);
  151. // IP input container
  152. var div = document.createElement("div");
  153. div.style.color = "#8058D0";
  154. div.style.backgroundColor = "#4C447C";
  155. div.style.borderRadius = "29px";
  156. div.style.margin = "10 auto";
  157. div.style.padding = "8px";
  158. sltMenu.appendChild(div);
  159. // IP input
  160. var input = document.createElement("input");
  161. input.id = "server-ip";
  162. input.type = "text";
  163. input.placeholder = "Server address (IP:port)";
  164. input.style.height = "24px";
  165. input.style.display = "inline-block";
  166. input.style.background = "none";
  167. input.style.color = "#e0e0ff";
  168. input.style.border = "none";
  169. input.style.outline = "none";
  170. div.appendChild(input);
  171. // Connect (play) button
  172. var button = document.createElement("input");
  173. button.id = "connect-btn";
  174. button.type = "button";
  175. button.value = "Play";
  176. button.style.height = "24px";
  177. button.style.display = "inline-block";
  178. button.style.borderRadius = "12px";
  179. button.style.color = "#FFF";
  180. button.style.backgroundColor = "#56ac81";
  181. button.style.border = "none";
  182. button.style.outline = "none";
  183. button.style.cursor = "pointer";
  184. button.style.padding = "0 20px";
  185. div.appendChild(button);
  186. // Select server container
  187. var div = document.createElement("div");
  188. div.style.backgroundColor = "#919191";
  189. div.style.borderRadius = "29px";
  190. div.style.margin = "10 auto";
  191. div.style.padding = "8px";
  192. sltMenu.appendChild(div);
  193. // Select server
  194. var select = document.createElement("select");
  195. select.id = "select-srv";
  196. select.style.background = "none";
  197. select.style.border = "none";
  198. select.style.outline = "none";
  199. var option = document.createElement("option");
  200. option.value = "";
  201. option.text = "-- Select a server --";
  202. select.appendChild(option);
  203. div.appendChild(select);
  204. // Select graph container
  205. var div = document.createElement("div");
  206. div.style.backgroundColor = "#A5A5A5";
  207. div.style.borderRadius = "29px";
  208. div.style.margin = "10 auto";
  209. div.style.padding = "8px";
  210. sltMenu.appendChild(div);
  211. // Select graph
  212. var select = document.createElement("select");
  213. select.id = "select-graph";
  214. select.style.background = "none";
  215. select.style.border = "none";
  216. select.style.outline = "none";
  217. div.appendChild(select);
  218. var option = document.createElement("option");
  219. option.value = "3";
  220. option.text = "Graphics: normal";
  221. select.appendChild(option);
  222. var option = document.createElement("option");
  223. option.value = "2";
  224. option.text = "Graphics: optimized";
  225. select.appendChild(option);
  226. var option = document.createElement("option");
  227. option.value = "1";
  228. option.text = "Graphics: low";
  229. select.appendChild(option);
  230. // Menu footer
  231. sltMenu.innerHTML += '<a href="http://ogario.ovh" target="_blank" style="color: #56ac81;">Visit ogario.ovh</a> | ';
  232. sltMenu.innerHTML += '<a href="https://www.youtube.com/channel/UCaWiPNJWnhzYDrBQoXokn6w" target="_blank" style="color: #56ac81;">YT Channel</a>';
  233. // Get IP input
  234. inpIP = document.getElementById("server-ip");
  235. // Get nick
  236. var nick = document.getElementById("nick");
  237. nick.addEventListener("input", getNick, false);
  238. // Force connect
  239. var connectBtn = document.getElementById("connect-btn");
  240. connectBtn.onclick = forceConnect;
  241. // Get servers list
  242. getServersList();
  243. // Set graphic mode
  244. var selectGraph = document.getElementById("select-graph");
  245. if (renderMode == 1) {
  246. selectGraph.selectedIndex = 2;
  247. } else if (renderMode == 2) {
  248. selectGraph.selectedIndex = 1;
  249. } else {
  250. selectGraph.selectedIndex = 0;
  251. normalMode = true;
  252. }
  253. selectGraph.onchange = function() {
  254. var mode = selectGraph.value;
  255. if (mode) {
  256. renderMode = mode;
  257. w.localStorage.setItem("rendermode", renderMode);
  258. }
  259. };
  260. resizeView();
  261. } else {
  262. setTimeout(setMenu, 100);
  263. }
  264. }
  265. // Load settings
  266. function loadSettings() {
  267. if (w.localStorage.getItem("nick") != null) {
  268. var nick = w.localStorage.getItem("nick");
  269. document.getElementById("nick").value = nick;
  270. }
  271. if (w.localStorage.getItem("rendermode") != null) {
  272. var mode = parseInt(w.localStorage.getItem("rendermode"));
  273. if (mode >= 1 && mode <= 3) {
  274. renderMode = mode;
  275. }
  276. }
  277. if (w.localStorage.getItem("highscore") != null) {
  278. var score = parseFloat(w.localStorage.getItem("highscore"));
  279. if (score > 0) {
  280. highScore = score;
  281. }
  282. }
  283. }
  284. // Get nick
  285. function getNick() {
  286. var nick = document.getElementById("nick").value;
  287. w.localStorage.setItem("nick", nick);
  288. }
  289. // Connection status
  290. function connectionStatus() {
  291. if (!w.connecting || retry == 10) {
  292. w.forcing = false;
  293. retry = 0;
  294. return;
  295. }
  296. retry++;
  297. setTimeout(connectionStatus, 1000);
  298. }
  299. // Force connect
  300. function forceConnect() {
  301. if (inpIP.value.length == 0 || !w.connect) {
  302. return;
  303. }
  304. w.forcing = true;
  305. if (!w.bso) {
  306. w.bso = {};
  307. }
  308. var srv = inpIP.value.trim().split(":");
  309. w.bso.ip = srv[0];
  310. w.bso.po = srv[1];
  311. w.connect();
  312. setTimeout(connectionStatus, 1000);
  313. }
  314. // Get servers list
  315. function getServersList() {
  316. if (w.sos && w.sos.length > 0) {
  317. var selectSrv = document.getElementById("select-srv");
  318. for (var i = 0; i < sos.length; i++) {
  319. var srv = sos[i];
  320. var option = document.createElement("option");
  321. option.value = srv.ip + ":" + srv.po;
  322. option.text = (i + 1) + ". " + option.value;
  323. selectSrv.appendChild(option);
  324. }
  325. selectSrv.onchange = function() {
  326. var srv = selectSrv.value;
  327. inpIP.value = srv;
  328. };
  329. } else {
  330. setTimeout(getServersList, 100);
  331. }
  332. }
  333. // Resize view
  334. function resizeView() {
  335. if (w.resize) {
  336. w.lww = 0; // Reset width (force resize)
  337. w.wsu = 0; // Clear ad space
  338. w.resize();
  339. var wh = Math.ceil(w.innerHeight);
  340. if (wh < 800) {
  341. var login = document.getElementById("login");
  342. w.lgbsc = wh / 800;
  343. login.style.top = - (Math.round(wh * (1 - w.lgbsc) * 1E5) / 1E5) + "px";
  344. if (w.trf) {
  345. w.trf(login, "scale(" + w.lgbsc + "," + w.lgbsc + ")");
  346. }
  347. }
  348. } else {
  349. setTimeout(resizeView, 100);
  350. }
  351. }
  352. // Set leaderboard
  353. function setLeaderboard() {
  354. if (w.lbh) {
  355. w.lbh.textContent = "MOD: SLITio by szymy";
  356. w.lbh.style.fontSize = "20px";
  357. } else {
  358. setTimeout(setLeaderboard, 100);
  359. }
  360. }
  361. // Set normal mode
  362. function setNormalMode() {
  363. normalMode = true;
  364. w.ggbg = true;
  365. if (!w.bgp2 && bgImage) {
  366. w.bgp2 = bgImage;
  367. }
  368. w.render_mode = 2;
  369. }
  370. // Set graphics
  371. function setGraphics() {
  372. if (renderMode == 3) {
  373. if (!normalMode) {
  374. setNormalMode();
  375. }
  376. return;
  377. }
  378. if (normalMode) {
  379. normalMode = false;
  380. }
  381. if (w.want_quality && w.want_quality != 0) {
  382. w.want_quality = 0;
  383. w.localStorage.setItem("qual", "0");
  384. w.grqi.src = "/s/lowquality.png";
  385. }
  386. if (w.ggbg && w.gbgmc) {
  387. w.ggbg = false;
  388. }
  389. if (w.bgp2) {
  390. bgImage = w.bgp2;
  391. w.bgp2 = null;
  392. }
  393. if (w.high_quality) {
  394. w.high_quality = false;
  395. }
  396. if (w.gla && w.gla != 0) {
  397. w.gla = 0;
  398. }
  399. if (w.render_mode && w.render_mode != renderMode) {
  400. w.render_mode = renderMode;
  401. }
  402. }
  403. // Quick resp
  404. function quickResp() {
  405. w.dead_mtm = 0;
  406. w.login_fr = 0;
  407. forceConnect();
  408. }
  409. // Quit to menu
  410. function quit() {
  411. if (w.playing && w.resetGame) {
  412. w.want_close_socket = true;
  413. w.dead_mtm = 0;
  414. if (w.play_btn) {
  415. w.play_btn.setEnabled(true);
  416. }
  417. w.resetGame();
  418. }
  419. }
  420. // Change skin
  421. function changeSkin() {
  422. if (w.playing && w.snake != null) {
  423. var skin = w.snake.rcv,
  424. max = w.max_skin_cv || 25;
  425. skin++;
  426. if (skin > max) {
  427. skin = 0;
  428. }
  429. w.setSkin(w.snake, skin);
  430. }
  431. }
  432. // Rotate skin
  433. function rotateSkin() {
  434. if (!rotate) {
  435. return;
  436. }
  437. changeSkin();
  438. setTimeout(rotateSkin, 500);
  439. }
  440. // Set high score
  441. function setHighScore() {
  442. if (!w.snake || !w.fpsls || !w.fmlts) {
  443. return;
  444. }
  445. var currentScore = Math.floor(150 * (w.fpsls[w.snake.sct] + w.snake.fam / w.fmlts[w.snake.sct] - 1) - 50) / 10;
  446. if (currentScore > highScore) {
  447. highScore = currentScore;
  448. w.localStorage.setItem("highscore", highScore);
  449. }
  450. if (scoreHUD && highScore > 0) {
  451. scoreHUD.textContent = "Best score: " + highScore;
  452. }
  453. }
  454. // Show FPS
  455. function showFPS() {
  456. if (w.playing && fpsHUD && w.fps && w.lrd_mtm) {
  457. if (Date.now() - w.lrd_mtm > 970) {
  458. fpsHUD.textContent = "FPS: " + w.fps;
  459. }
  460. }
  461. setTimeout(showFPS, 30);
  462. }
  463. // Update loop
  464. function updateLoop() {
  465. setGraphics();
  466. setHighScore();
  467. if (w.playing) {
  468. if (positionHUD) {
  469. positionHUD.textContent = "X: " + (~~w.view_xx || 0) + " Y: " + (~~w.view_yy || 0);
  470. }
  471. if (inpIP && w.bso && currentIP != w.bso.ip + ":" + w.bso.po) {
  472. currentIP = w.bso.ip + ":" + w.bso.po;
  473. inpIP.value = currentIP;
  474. if (ipHUD) {
  475. ipHUD.textContent = "Server: " + currentIP;
  476. }
  477. }
  478. } else {
  479. positionHUD.textContent = "";
  480. fpsHUD.textContent = "";
  481. }
  482. setTimeout(updateLoop, 1000);
  483. }
  484. // Init
  485. init();
  486. })(window);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址