Starve.io L3Mod

Starve.io L3Mod, save home, talk with friends, share map ! And more... soon xD

  1. // ==UserScript==
  2. // @name Starve.io L3Mod
  3. // @namespace Starve.io L3Mod
  4. // @version 0.1
  5. // @description Starve.io L3Mod, save home, talk with friends, share map ! And more... soon xD
  6. // @author l3mpik
  7. // @match *://starve.io/*
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
  10. // @grant none
  11. // ==/UserScript==
  12. window.l3 = function() {
  13. this.socket = null;
  14. this.version = "1.0";
  15. this.name = "";
  16. this.binds = {};
  17. }
  18. l3.prototype = {
  19. get: function(data) {
  20. return document.getElementById(data.toString());
  21. },
  22. getRoom: function(callback) {
  23. var me = this;
  24. try {
  25. //callback(window.webSocket.url), future use bots? :D
  26. return client.socket.url;
  27. } catch(e) {
  28. console.error("Undefined ws.url, connect to server!");
  29. }
  30. },
  31. connect: function(data) {
  32. var me = this;
  33. me.socket = io.connect("ws://5.196.23.192:1000");
  34. me.room = data;
  35. me.socket.on('request_room', function() {
  36. me.socket.emit('request_room', me.room);
  37. });
  38. me.socket.on('disconnect', function(e) {
  39. console.log("%c Kurwa. Jeden Way jesteś Banned! :D", "background: #000000; color: yellow; font-size: 2em;");
  40. });
  41. me.handleMessages();
  42. },
  43. getName: function() {
  44. var me = this;
  45. me.name = me.get("nickname_input").value;
  46. return me.name;
  47. },
  48. sendChat: function(data) {
  49. var me = this;
  50. me.socket.emit('chat', {
  51. user: me.getName(),
  52. message: data
  53. });
  54. },
  55. handleMessages: function(data) {
  56. var me = this;
  57. var message_counter = 0;
  58. var offset = 100;
  59. me.socket.on('chat', function(data) {
  60. if(data.user === me.getName()) {
  61. //return
  62. } else {
  63. //console.log("User:", data.user, "Message:", data.message);
  64. message_counter += 10;
  65. var r_id = me.randomId(data);
  66. offset = offset + message_counter;
  67. $("body").append('<div id="' + r_id + '" class="row" style="width: 30%; position: absolute; z-index: 1; bottom: ' + offset + 'px;"> <div class="alert alert-success" role="alert"> <span class="glyphicon glyphicon-user" aria-hidden="true" style="margin-left: 5px;"></span> <div id="l3_user">' + data.user + '</div>:<div id="l3_message">' + data.message + '</div> </div> </div>');
  68. setTimeout(() => {
  69. $("#" + r_id).fadeOut("slow");
  70. $("#" + r_id).remove();
  71. message_counter -= 10;
  72. }, 3000);
  73. }
  74. });
  75. },
  76. handlebinds: function() {
  77. var me = this;
  78. me.binds = [];
  79. me.binds.push('`|respawn');
  80. function isBind(e) {
  81. for(var i in me.binds) {
  82. var bind = me.binds[i].split("|");
  83. if(bind[0] === e.key) {
  84. switch(bind[1]) {
  85. case 'respawn':
  86. me.respawn();
  87. break;
  88. }
  89. }
  90. }
  91. }
  92. document.addEventListener('keydown', isBind, false);
  93. console.log("%c Binds initialization Success!", "background: #000000; color: yellow;");
  94. },
  95. respawn: function() {
  96. var me = this;
  97. me.client.socket.close(1000);
  98. },
  99. randomId: function(data) {
  100. return Math.floor(Math.random() * (2 + data.user.length * data.message.length + 2))
  101. },
  102. override(client, callback) {
  103. var me = this;
  104. try {
  105. client.send_chat = function(data) {
  106. world.fast_units[user.uid].text = data;
  107. this.socket.send(JSON.stringify([0, data]));
  108. me.sendChat(data);
  109. };
  110. client.connect = function() {
  111. this.timeout_number = 0;
  112. this.connect_timeout();
  113. me.name = me.getName();
  114. if(me.socket !== null && me.socket !== void(0)) {
  115. me.socket.disconnect();
  116. }
  117. me.connect(me.getRoom());
  118. };
  119. window['create_minimap'] = function(c, g) {
  120. console.log("Spoofing data:", c, " And this array:", g);
  121. var f = document.createElement("canvas"),
  122. d = f.getContext("2d");
  123. f.width = 200 * c;
  124. f.height = 200 * c;
  125. f.id = "minimap";
  126. d.translate(12 * c, 8 * c);
  127. d.fillStyle = g[9];
  128. d.fillRect(-7, 0, f.width - 10, f.height - 18);
  129. d.fillStyle = g[0];
  130. d.fillRect(0, 0, f.width - 25, f.height - 25);
  131. create_minimap_object(d, c, g[1], "p", 5, -1);
  132. create_minimap_object(d, c, g[2], "s", 3, 2, 2);
  133. create_minimap_object(d, c, g[3], "s", 4, 1, 1);
  134. create_minimap_object(d, c, g[4], "s", 5, 0, 0);
  135. create_minimap_object(d, c, g[5], "t", 3, 5, 4);
  136. create_minimap_object(d, c, g[6], "t", 4, 3,
  137. 2);
  138. create_minimap_object(d, c, g[7], "t", 4, 1, 0);
  139. create_minimap_object(d, c, g[8], "b", 4, 3, 2);
  140. create_minimap_object(d, c, g[9], "b", 4, 1, 0);
  141. create_minimap_object(d, c, g[10], "g", 3, 2, 2);
  142. create_minimap_object(d, c, g[11], "g", 4, 1, 1);
  143. create_minimap_object(d, c, g[12], "g", 5, 0, 0);
  144. create_minimap_object(d, c, g[13], "d", 3, 2, 2);
  145. create_minimap_object(d, c, g[14], "d", 4, 1, 1);
  146. create_minimap_object(d, c, g[15], "d", 5, 0, 0);
  147. d.translate(-7, -2);
  148. round_rect(d, 0, 0, f.width - 9, f.height - 14, 10);
  149. d.lineWidth = 5;
  150. d.strokeStyle = g[16];
  151. d.stroke();
  152. };
  153. me.client = client;
  154. callback();
  155. } catch(e) {
  156. console.error("Kurwa error : ", e)
  157. }
  158. },
  159. isReady(callback) {
  160. var me = this;
  161. if(window.client && window.Client && window.game && window.world && window.user) {
  162. callback();
  163. return true;
  164. } else {
  165. return false;
  166. }
  167. },
  168. inject(data) {
  169. var link = document.createElement("link");
  170. link.href = data;
  171. link.type = "text/css";
  172. link.rel = "stylesheet";
  173. document.getElementsByTagName("head")[0].appendChild(link);
  174. console.log("%c Injection Success!", "background: #000000; color: yellow;");
  175. }
  176. }
  177. setTimeout(function() {
  178. var app = new window.l3();
  179. app.isReady(function() {
  180. console.log("Before:", create_minimap);
  181. console.log("%c Game is ready! Im working.... okay? ", "background: #000000; color: yellow;");
  182. app.inject("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css");
  183. app.override(window.client, function() {
  184. console.log("%c Override Success!", "background: #000000; color: yellow;");
  185. });
  186. console.log("Before:", create_minimap);
  187. app.handlebinds();
  188. });
  189. }, 2000);