Greasy Fork 支持 简体中文。

Bloble.io Extreme Mod

Zoom, Base Builder, InstaFind

  1. // ==UserScript==
  2. // @name Bloble.io Extreme Mod
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Zoom, Base Builder, InstaFind
  6. // @author TigerYT and Blue Cyclone
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. //Remove Ad Container on Enter
  13.  
  14. document.querySelector("#enterGameButton").addEventListener("click", () => {
  15. setTimeout(() => {
  16. document.querySelector("#smallAdContainer").remove()
  17. }, 2000);
  18. })
  19.  
  20.  
  21. //BaseBuilder
  22. window.UIList = window.UIList || [];
  23. window.initFuncs = window.initFuncs || [];
  24. window.statusItems = window.statusItems || [];
  25.  
  26.  
  27. window.UIList.push({
  28. level: 0,
  29. x: 0,
  30. html: '<div onclick=buildGenerators()>Build Generators</div>'
  31. }, {
  32. level: 0,
  33. x: 1,
  34. html: '<div onclick=walls()>Build Walls</div>'
  35. }, {
  36. level: 0,
  37. x: 2,
  38. html: '<div onclick=buildHouses()>Build Offense</div>'
  39. }, {
  40. level: 0,
  41. x: 4,
  42. html: '<div onclick=buildHybrid()>Build Hybrid</div>'
  43. }, {
  44. level: 1,
  45. x: 0,
  46. html: '<div onclick=boulders()>Upgrade Boulders</div>'
  47. }, {
  48. level: 1,
  49. x: 1,
  50. html: '<div onclick=spikes()>Upgrade Spikes</div>'
  51. }, {
  52. level: 1,
  53. x: 2,
  54. html: '<div onclick=microGenerators()>Mico-Generators</div>'
  55. }, {
  56. level: 1,
  57. x: 3,
  58. html: '<div onclick=powerPlants()>Upgrade Power Plants</div>'
  59. }, {
  60. level: 2,
  61. x: 0,
  62. html: '<div onclick=sellGenerators()>Sell Generators</div>'
  63. }, {
  64. level: 2,
  65. x: 1,
  66. html: '<div onclick=sellall()>Sell all</div>'
  67. });
  68.  
  69. function emit2() {
  70. socket.emit.apply(socket, arguments);
  71. }
  72. window.walls = function () {
  73. for (i = -3.14; i < 3.14; i += .108) emit2("1", i, 1e3, 1)
  74. }
  75. window.sellGenerators = window.sellGenerators || function () {
  76. for (var a = [], d = 0; d < units.length; ++d) {
  77. if (units[d].type === 0 && units[d].owner == player.sid) {
  78. var name = getUnitFromPath(units[d].uPath).name;
  79. (name === 'Generator' || name === 'Power Plant') && a.push(units[d].id)
  80. }
  81. }
  82. socket.emit("3", a)
  83. }
  84. window.sellhouses = function () {
  85. for (var a = [], d = 0; d < units.length; ++d) units[d].type === 0 && units[d].owner == player.sid && getUnitFromPath(units[d].uPath).name === 'House' && a.push(units[d].id);
  86. socket.emit("3", a)
  87. }
  88. window.sellwalls = function () {
  89. for (var a = [], d = 0; d < units.length; ++d) units[d].type === 3 && units[d].owner == player.sid && getUnitFromPath(units[d].uPath).name === 'Wall' && a.push(units[d].id);
  90. socket.emit("3", a)
  91. }
  92. window.sellinner = function () {
  93. for (var a = [], d = 0; d < units.length; ++d) {
  94. if (units[d].type === 0 && units[d].owner == player.sid) {
  95. a.push(units[d].id)
  96. }
  97. }
  98. socket.emit("3", a)
  99. }
  100. window.sellall = function () {
  101. for (var a = [], d = 0; d < units.length; ++d)(units[d].type === 3 || units[d].type === 2 || units[d].type === 0) && units[d].owner == player.sid && a.push(units[d].id);
  102. socket.emit("3", a)
  103. }
  104. window.boulders = window.boulders || function () {
  105. for (var i = 0; i < units.length; ++i) 3 == units[i].type && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  106. }
  107. window.microGenerators = window.microGenerators || function () {
  108. for (var i = 0; i < units.length; ++i) 3 == units[i].type && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 1)
  109. }
  110. window.spikes = window.spikes || function () {
  111. for (var i = 0; i < units.length; ++i) 3 == units[i].type && "hexagon" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  112. }
  113. window.powerPlants = window.powerPlants || function () {
  114. for (var i = 0; i < units.length; ++i) 0 == units[i].type && "hexagon" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  115. }
  116. window.rapid = window.rapid || function () {
  117. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 1 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  118. }
  119. window.ranged = window.ranged || function () {
  120. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 1 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 1)
  121. }
  122. window.antiTank = window.antiTank || function () {
  123. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 4 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 1)
  124. }
  125. window.semiAuto = window.semiAuto || function () {
  126. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 4 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  127. }
  128. window.gatlins = window.gatlins || function () {
  129. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 2 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  130. }
  131. window.spotter = window.spotter || function () {
  132. for (var i = 0; i < units.length; ++i) 0 == units[i].type && 3 == units[i].turretIndex && "circle" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  133. };
  134. window.build = function (instr) {
  135. instr.forEach((ins) => {
  136. emit2.apply({}, ins);
  137. })
  138. }
  139. window.buildHybrid = function () {
  140. window.build([["1", 3.13, 243.85, 5], ["1", 2.87, 246.85, 2], ["1", 2.62, 243.85, 5], ["1", 2.37, 246.85, 2], ["1", 2.11, 243.85, 5], ["1", 1.86, 246.85, 2], ["1", 1.6, 243.85, 5], ["1", 1.34, 246.85, 2], ["1", 1.08, 243.85, 5], ["1", 0.82, 246.85, 2], ["1", 0.56, 243.85, 5], ["1", 0.3, 246.85, 2], ["1", 0.04, 243.85, 5], ["1", -0.21, 246.85, 2], ["1", -0.46, 243.85, 5], ["1", -0.72, 246.85, 2], ["1", -0.98, 243.85, 5], ["1", -1.23, 246.85, 2], ["1", -1.49, 243.85, 5], ["1", -1.74, 246.85, 2], ["1", -1.99, 243.85, 5], ["1", -2.25, 246.85, 2], ["1", -2.51, 243.85, 5], ["1", -2.77, 246.85, 2], ["1", 2.77, 190.49, 2], ["1", 2.43, 187.99, 2], ["1", 1.96, 188.53, 2], ["1", 2.76, 130, 4], ["1", 2.28, 130, 4], ["1", 1.79, 130, 4], ["1", 1.28, 130, 4], ["1", 0.79, 130, 4], ["1", 0.28, 130, 4], ["1", -0.19, 130, 4], ["1", -0.67, 130, 4], ["1", -1.17, 130, 4], ["1", -1.64, 130, 4], ["1", -2.13, 130, 4], ["1", -2.61, 130, 4], ["1", -3.06, 138.27, 4], ["1", -2.94, 195.69, 2], ["1", -2.4, 183.33, 2], ["1", -1.91, 180.8, 2], ["1", -1.41, 182.01, 2], ["1", -0.94, 182.52, 2], ["1", -0.45, 180.37, 2], ["1", 0.04, 178.74, 2], ["1", 0.53, 177.22, 2], ["1", 1.03, 181.72, 2], ["1", 1.49, 184.1, 2]]);
  141. }
  142. window.buildHouses = function () {
  143. window.build([["1", -0.09, 245.4, 1], ["1", 0.16, 243.15, 1], ["1", 0.41, 243.84, 1], ["1", 0.67, 244.57, 1], ["1", 0.04, 183.15, 5], ["1", 0.39, 184.96, 2], ["1", 0.72, 184.99, 4], ["1", 0.92, 245.85, 4], ["1", -0.34, 245.85, 4], ["1", -0.34, 140, 7], ["1", -0.6, 245.85, 4], ["1", 0.25, 130, 4], ["1", -0.88, 130, 4], ["1", -1.37, 130, 4], ["1", -1.86, 130, 4], ["1", -2.36, 130, 4], ["1", -2.88, 130, 4], ["1", 2.85, 130, 4], ["1", 2.36, 130, 4], ["1", 1.85, 130, 4], ["1", 1.38, 130, 4], ["1", 0.9, 130, 4], ["1", 1.19, 245.85, 4], ["1", 1.46, 245.85, 4], ["1", 1.73, 245.85, 4], ["1", 2, 245.85, 4], ["1", 2.26, 245.85, 4], ["1", 2.52, 245.85, 4], ["1", 2.78, 245.85, 4], ["1", 3.04, 245.85, 4], ["1", -2.99, 245.85, 4], ["1", -2.74, 245.85, 4], ["1", -2.49, 245.85, 4], ["1", -2.24, 245.85, 4], ["1", -1.99, 245.85, 4], ["1", -1.74, 245.85, 4], ["1", -1.48, 245.85, 4], ["1", -1.23, 245.85, 4], ["1", -0.94, 245.85, 4], ["1", -0.72, 187.11, 4], ["1", -1.06, 186.05, 4], ["1", -1.53, 186.15, 4], ["1", -1.87, 191.23, 4], ["1", -2.21, 185.53, 4], ["1", -2.55, 184.19, 4], ["1", 1.07, 186.28, 4], ["1", 1.61, 184.13, 4], ["1", 2.07, 185.66, 4], ["1", 2.39, 192.03, 4], ["1", 2.71, 186.8, 4], ["1", 3.06, 185.93, 4]])
  144. // window.build([["1", 0.24, 245.85, 4], ["1", 0.49, 245.85, 4], ["1", 0.74, 245.85, 4], ["1", -0.01, 245.85, 4], ["1", -0.26, 245.85, 4], ["1", -0.51, 245.85, 4], ["1", 1, 245.85, 4], ["1", 1.25, 245.85, 4], ["1", 1.5, 245.85, 4], ["1", 1.75, 245.85, 4], ["1", 2, 245.85, 4], ["1", 2.25, 245.85, 4], ["1", 2.5, 245.85, 4], ["1", 2.75, 245.85, 4], ["1", 3.01, 245.85, 4], ["1", -3.03, 245.85, 4], ["1", -3.01, 245.85, 4], ["1", -2.75, 245.85, 4], ["1", -2.49, 245.85, 4], ["1", -2.24, 245.85, 4], ["1", -1.98, 245.85, 4], ["1", -1.72, 245.85, 4], ["1", -1.46, 245.85, 4], ["1", -1.21, 245.85, 4], ["1", -0.96, 245.85, 4], ["1", -0.72, 203.14, 4], ["1", -0.39, 190.85, 4], ["1", -0.59, 130, 4], ["1", -0.05, 185.69, 4], ["1", 0.11, 130, 4], ["1", 0.31, 185.08, 5], ["1", 0.66, 187.02, 4], ["1", 1.02, 184.03, 4], ["1", 0.84, 130, 4], ["1", 1.36, 189.19, 4], ["1", 1.7, 186.55, 4], ["1", 1.44, 130, 4], ["1", 2.05, 186.48, 4], ["1", 1.92, 130, 4], ["1", 1.91, 130, 4], ["1", 2.38, 191.67, 4], ["1", 2.38, 130, 4], ["1", 2.71, 185.92, 4], ["1", 3.05, 185.84, 4], ["1", 2.87, 130, 4], ["1", -2.9, 188.9, 4], ["1", -2.57, 187.48, 4], ["1", -2.74, 130, 4], ["1", -2.24, 185.43, 4], ["1", -1.91, 186.44, 4], ["1", -2.07, 130, 4], ["1", -1.57, 190.81, 4], ["1", -1.58, 186.32, 4], ["1", -1.42, 130, 4], ["1", -1.24, 186.06, 4]]);
  145. }
  146. window.buildGenerators = function () {
  147. var arr = [["1", 3.11, 243.85, 3], ["1", -2.9, 243.85, 3], ["1", -2.63, 243.85, 3], ["1", -2.36, 243.85, 3], ["1", -2.06, 243.85, 3], ["1", -1.77, 243.85, 3], ["1", -1.5, 243.85, 3], ["1", -1.22, 243.85, 3], ["1", -0.94, 243.85, 3], ["1", -0.64, 243.85, 3], ["1", -0.36, 243.85, 3], ["1", -0.07, 243.85, 3], ["1", 0.2, 243.85, 3], ["1", 0.47, 243.85, 3], ["1", 0.76, 243.85, 3], ["1", 1.05, 243.85, 3], ["1", 1.35, 243.85, 3], ["1", 1.64, 243.85, 3], ["1", 1.92, 243.85, 3], ["1", 2.22, 243.85, 3], ["1", 2.49, 243.85, 3], ["1", 2.78, 243.85, 3], ["1", 3, 183.39, 3], ["1", -2.91, 178.82, 3], ["1", -2.5, 182.85, 3], ["1", -2.11, 178.92, 3], ["1", -1.72, 176.82, 3], ["1", -1.35, 177.59, 3], ["1", -0.98, 174.52, 3], ["1", -0.57, 179.76, 3], ["1", -0.19, 183.42, 3], ["1", 0.21, 176.37, 3], ["1", 0.63, 179.87, 3], ["1", 1.03, 175.57, 3], ["1", 1.43, 176.6, 3], ["1", 1.8, 181.19, 3], ["1", 2.19, 177.95, 3], ["1", 2.6, 178.66, 3]]
  148. window.build(arr);
  149. }
  150. window.makeUI = function () {
  151. if (window.hasMadeUI) return;
  152. window.hasMadeUI = true;
  153. window.statusItems.sort(function (a, b) {
  154. return a.order - b.order;
  155. })
  156. var levels = [];
  157. window.UIList.forEach((item) => {
  158. if (!levels[item.level]) levels[item.level] = [];
  159. levels[item.level].push(item)
  160. })
  161.  
  162. levels = levels.filter((a) => {
  163. if (a) {
  164. a.sort(function (a, b) {
  165. return a.x - b.x;
  166. })
  167. return true;
  168. } else {
  169. return false;
  170. }
  171. })
  172.  
  173. var headAppend = document.getElementsByTagName("head")[0],
  174. style = document.createElement("div");
  175.  
  176. var toast = document.createElement('div');
  177. toast.id = "snackbar";
  178. var css = document.createElement('div');
  179.  
  180. css.innerHTML = '<style>\n\
  181. #snackbar {\n\
  182. visibility: hidden;\n\
  183. min-width: 250px;\n\
  184. margin-left: -125px;\n\
  185. background-color: rgba(40, 40, 40, 0.5);\n\
  186. color: #fff;\n\
  187. text-align: center;\n\
  188. border-radius: 4px;\n\
  189. padding: 10px;\n\
  190. font-family: "regularF";\n\
  191. font-size: 20px;\n\
  192. position: fixed;\n\
  193. z-index: 100;\n\
  194. left: 50%;\n\
  195. top: 30px;\n\
  196. }\n\
  197. #snackbar.show {\n\
  198. visibility: visible;\n\
  199. -webkit-animation: fadein 0.5s;\n\
  200. animation: fadein 0.5s;\n\
  201. }\n\
  202. #snackbar.hide {\n\
  203. visibility: visible;\n\
  204. -webkit-animation: fadeout 0.5s;\n\
  205. animation: fadeout 0.5s;\n\
  206. }\n\
  207. @-webkit-keyframes fadein {\n\
  208. from {top: 0; opacity: 0;}\n\
  209. to {top: 30px; opacity: 1;}\n\
  210. }\n\
  211. @keyframes fadein {\n\
  212. from {top: 0; opacity: 0;}\n\
  213. to {top: 30px; opacity: 1;}\n\
  214. }\n\
  215. @-webkit-keyframes fadeout {\n\
  216. from {top: 30px; opacity: 1;}\n\
  217. to {top: 0; opacity: 0;}\n\
  218. }\n\
  219. @keyframes fadeout {\n\
  220. from {top: 30px; opacity: 1;}\n\
  221. to {top: 0; opacity: 0;}\n\
  222. }\n\
  223. </style>'
  224. var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
  225. style.innerHTML = "<style>\n\
  226. #noobscriptUI, #noobscriptUI > div > div {\n\
  227. background-color:rgba(40,40,40,.5);\n\
  228. margin-left: 3px;\n\
  229. border-radius:4px;\n\
  230. pointer-events:all\n\
  231. }\n\
  232. #noobscriptUI {\n\
  233. top: -" + (height + 12) + "px;\n\
  234. transition: 1s;\n\
  235. margin-left:10px;\n\
  236. position:absolute;\n\
  237. padding-left:24px;\n\
  238. margin-top:9px;\n\
  239. padding-top:15px;\n\
  240. width:580px;\n\
  241. height: " + height + "px;\n\
  242. font-family:arial;\n\
  243. left:25%\n\
  244. }\n\
  245. #noobscriptUI:hover{\n\
  246. top:0px\n\
  247. }\n\
  248. #noobscriptUI > div > div {\n\
  249. color:#fff;\n\
  250. padding:7px;\n\
  251. height:19px;\n\
  252. display:inline-block;\n\
  253. cursor:pointer;\n\
  254. font-size:15px\n\
  255. }\n\
  256. </style>"
  257.  
  258. headAppend.appendChild(style);
  259. headAppend.appendChild(css);
  260.  
  261.  
  262. var contAppend = document.getElementById("gameUiContainer"),
  263. menuA = document.createElement("div");
  264.  
  265. var code = ['<div id="noobscriptUI">\n'];
  266.  
  267. levels.forEach((items, i) => {
  268. code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
  269. items.forEach((el) => {
  270. code.push(' ' + el.html + '\n');
  271. })
  272. code.push(' </div>\n');
  273. })
  274. code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
  275. code.push('</div>');
  276.  
  277. menuA.innerHTML = code.join("");
  278. contAppend.insertBefore(menuA, contAppend.firstChild)
  279. contAppend.appendChild(toast)
  280. var toastTimeout = false;
  281. window.showToast = function (msg) {
  282. toast.textContent = msg;
  283.  
  284. if (toastTimeout) clearTimeout(toastTimeout);
  285. else toast.className = "show";
  286. toastTimeout = setTimeout(function () {
  287. toast.className = 'hide'
  288. setTimeout(function () {
  289. toast.className = '';
  290. }, 400);
  291. toastTimeout = false;
  292. }, 3000);
  293. }
  294. window.statusBar = function () {
  295. var el = document.getElementById('confinfo');
  296. var text = [];
  297.  
  298. window.statusItems.forEach((item, i) => {
  299. if (i !== 0) text.push(' ');
  300. if (item.name) text.push(item.name + ': ');
  301. text.push(item.value());
  302. })
  303.  
  304. el.textContent = text.join('');
  305. }
  306. window.statusBar();
  307.  
  308. window.initFuncs.forEach((func) => {
  309. func();
  310. })
  311. }
  312. setTimeout(() => {
  313. window.makeUI();
  314. }, 1000)
  315.  
  316. //InstaFind
  317.  
  318. var gotoUsers = [];
  319. var gotoIndex = 0;
  320. window.overrideSocketEvents = window.overrideSocketEvents || [];
  321. window.chatCommands = window.chatCommands || {};
  322.  
  323. window.chatCommands.find = function(split) {
  324. var name = split.slice(1).join(' ');
  325. if (name == '') {
  326. addChat('Please specify a username', 'Client')
  327. return;
  328. }
  329. window.goto(name)
  330. }
  331. window.overrideSocketEvents.push({
  332. name: "l",
  333. description: "Leaderboard Insta Find override",
  334. func: function(a) {
  335. var d = "",
  336. c = 1,
  337. b = 0;
  338. for (; b < a.length;) {
  339. d += "<div class='leaderboardItem' onclick=goto2(" + a[b] + ");><div style='display:inline-block;float:left;' class='whiteText'>" + c + ".</div> <div class='" + (player && a[b] == player.sid ? "leaderYou" : "leader") + "'>" + a[b + 1] + "</div><div class='scoreText'>" + a[b + 2] + "</div></div>", c++, b += 3;
  340. }
  341. leaderboardList.innerHTML = d;
  342. }
  343. })
  344. leaderboardList.style.pointerEvents = 'auto';
  345. chatListWrapper.style.pointerEvents = 'auto';
  346.  
  347. window.goto = function(username) {
  348. gotoUsers = users.filter((user) => {
  349. return user.name === username
  350. });
  351. gotoIndex = 0;
  352. if (gotoUsers[0]) {
  353. camX = gotoUsers[0].x - player.x;
  354. camY = gotoUsers[0].y - player.y;
  355. }
  356. addChat(gotoUsers.length + ' users found with the name ' + username, 'Client');
  357. return gotoUsers.length;
  358. }
  359. window.goto2 = function(id, go) {
  360. gotoUsers = users.filter((user) => {
  361. return user.sid === id;
  362. });
  363. gotoIndex = 0;
  364. if (!go && gotoUsers[0]) {
  365. camX = gotoUsers[0].x - player.x;
  366. camY = gotoUsers[0].y - player.y;
  367. }
  368. return gotoUsers.length;
  369. }
  370.  
  371. window.gotoLeft = function() {
  372. if (!gotoUsers.length) return;
  373.  
  374. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  375. if (gotoIndex <= 0) gotoIndex = gotoUsers.length;
  376. gotoIndex--;
  377. }
  378. camX = gotoUsers[gotoIndex].x - player.x;
  379. camY = gotoUsers[gotoIndex].y - player.y;
  380. }
  381.  
  382. window.gotoRight = function() {
  383. if (!gotoUsers.length) return;
  384.  
  385. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  386. if (gotoIndex >= gotoUsers.length - 1) gotoIndex = -1;
  387. gotoIndex++;
  388. }
  389. camX = gotoUsers[gotoIndex].x - player.x;
  390. camY = gotoUsers[gotoIndex].y - player.y;
  391. }
  392.  
  393. window.addChat = function(msg, from, color) {
  394. color = color || "#fff";
  395. var b = document.createElement("li");
  396. b.className = "chatother";
  397. b.innerHTML = '<span style="color:' + color + '">[' + from + ']</span> <span class="chatText">' + msg + "</span>";
  398. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  399. chatList.appendChild(b)
  400. }
  401.  
  402. window.resetCamera = function() { // Override
  403. camX = camXS = camY = camYS = 0;
  404. cameraKeys = {
  405. l: 0,
  406. r: 0,
  407. u: 0,
  408. d: 0
  409. }
  410.  
  411. if (socket && window.overrideSocketEvents && window.overrideSocketEvents.length) {
  412. window.overrideSocketEvents.forEach((item) => {
  413. socket.removeAllListeners(item.name)
  414. socket.on(item.name, item.func);
  415.  
  416. });
  417.  
  418. }
  419. }
  420.  
  421. window.addChatLine = function(a, d, c) {
  422. if (player) {
  423. var b = getUserBySID(a);
  424. if (c || 0 <= b) {
  425. var g = c ? "SERVER" : users[b].name;
  426. c = c ? "#fff" : playerColors[users[b].color] ? playerColors[users[b].color] : playerColors[0];
  427. player.sid == a && (c = "#fff");
  428. b = document.createElement("li");
  429. b.className = player.sid == a ? "chatme" : "chatother";
  430.  
  431. b.innerHTML = '<span style="color:' + c + '" onclick=goto2(' + a + ');>[' + g + ']</span> <span class="chatText">' + d + "</span>";
  432. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  433. chatList.appendChild(b)
  434. }
  435. }
  436. }
  437.  
  438. window.addEventListener("keyup", function(a) {
  439. a = a.keyCode ? a.keyCode : a.which;
  440. if (a === 190) {
  441. window.gotoRight()
  442. } else if (a === 188) {
  443. window.gotoLeft();
  444. }
  445.  
  446. });
  447.  
  448. //Zoom
  449.  
  450. var scroll = 0;
  451.  
  452. mainCanvas.addEventListener ? (window.addEventListener("mousewheel", zoom, !1),
  453. mainCanvas.addEventListener("DOMMouseScroll", zoom, !1)) : window.attachEvent("onmousewheel", zoom);
  454.  
  455. function zoom(a) {
  456. a = window.event || a;
  457. a.preventDefault();
  458. a.stopPropagation();
  459. scroll = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
  460. if (scroll == -1) { //zoom out
  461. if (maxScreenHeight < 10000) {
  462. (maxScreenHeight += 250, maxScreenWidth += 250, resize());
  463. scroll = 0
  464. }
  465. }
  466.  
  467. if (scroll == 1) { //zoom in
  468. if (maxScreenHeight > 1000) {
  469. (maxScreenHeight -= 250, maxScreenWidth -= 250, resize())
  470. scroll = 0
  471. }
  472. }
  473. }
  474.  
  475. mainCanvas.onkeydown = function(event) {
  476. var k = event.keyCode ? event.keyCode : event.which;
  477. if (k == 70) { // F to zoom out
  478. if (maxScreenHeight < 10000) {
  479. (maxScreenHeight += 250, maxScreenWidth += 250, resize());
  480. }
  481. }
  482. if (k == 67) {// C to zoom in
  483. if (maxScreenHeight > 1000) {
  484. (maxScreenHeight -= 250, maxScreenWidth -= 250, resize())
  485. }
  486.  
  487. }
  488.  
  489. {if(65==a||37==a)cameraKeys.l=0,updateCameraInput();if(68==a||39==a)cameraKeys.r=0,updateCameraInput();if(87==a||38==a)cameraKeys.u=0,updateCameraInput();if(83==a||40==a)cameraKeys.d=0,updateCameraInput();if(32==a){var d=unitList.indexOf(activeUnit);sendUnit(d)}void 0!=upgrInputsToIndex["k"+a]&&toggleActiveUnit(upgrInputsToIndex["k"+a]);46==a&&selUnits.length&&sellSelUnits();84==a&&toggleChat("none"==chatListWrapper.style.display);
  490. 27==a&&(toggleActiveUnit(),disableSelUnit(),showSelector=!1);82==a&&(camY=camX=0)}};mainCanvas.onkeydown=function(a){a=a.keyCode?a.keyCode:a.which;socket&&player&&!player.dead&&(65!=a&&37!=a||cameraKeys.l||(cameraKeys.l=-1,cameraKeys.r=0,updateCameraInput()),68!=a&&39!=a||cameraKeys.r||(cameraKeys.r=1,cameraKeys.l=0,updateCameraInput()),87!=a&&38!=a||cameraKeys.u||(cameraKeys.u=-1,cameraKeys.d=0,updateCameraInput()),83!=a&&40!=a||cameraKeys.d||(cameraKeys.d=1,cameraKeys.u=0,updateCameraInput()))}
  491.  
  492. addEventListener("keydown", function(a) {
  493. if (a.keyCode == 77){
  494. for(i=0;i<users.length;++i){
  495. if(users[i].name.startsWith("[G]")&&users[i].name !== player.name){
  496. camX = users[i].x-player.x;
  497. camY = users[i].y-player.y;
  498. }
  499. }
  500. }
  501. });