MORE compact noobscript (no base transparent)

GREAT for Noobscript V4 Parte 3 users

  1. // ==UserScript==
  2. // @name MORE compact noobscript (no base transparent)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description GREAT for Noobscript V4 Parte 3 users
  6. // @author barely heard of 5O5
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. $("#youtuberOf").hide();
  12. $("#youtubeFollow").hide();
  13. $("#adCard").hide();
  14. $("#mobileInstructions").hide();
  15. $("#promoImgHolder").hide();
  16. $("#downloadButtonContainer").hide();
  17. $("#mobileDownloadButtonContainer").hide();
  18. $(".downloadBadge").hide();
  19.  
  20. //One-click auto defence/buy/upgrade
  21. window.UIList = window.UIList || [];
  22. window.initFuncs = window.initFuncs || [];
  23. window.statusItems = window.statusItems || [];
  24. window.autoUpgrade = false;
  25. window.autoHybrid = false;
  26. window.UIList.push({
  27. level: 4,
  28. x: 1,
  29. html: '<div id=auto2 onclick=autoupgrade()>Auto Upgrade Powerplant/micro:Disabled</div>'
  30. }, {
  31. level: 4,
  32. x: 2,
  33. html: '<div id=auto3 onclick=autohybrid()>Auto Upgrade(Hybrid):Disabled</div>'
  34. });
  35.  
  36. //Auto upgrade micro/power plant
  37. window.autoupgrade = function () {
  38. var elaaaa = document.getElementById('auto2');
  39. if (autoUpgrade) {
  40. autoUpgrade = false
  41. elaaaa.textContent = 'Auto Upgrade Powerplant/micro:Disabled'
  42. clearInterval(testeee)
  43. } else {
  44. autoUpgrade = true;
  45. elaaaa.textContent = 'Auto Upgrade Powerplant/micro:Enabled';
  46. window.testeee = setInterval(autoupgrades,1000)
  47. function autoupgrades() {
  48. 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);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)
  49. }
  50. }
  51. window.statusBar();
  52. return autoUpgrade()
  53. }
  54.  
  55. //Auto upgrade (Hybrid)
  56. window.autohybrid = function () {
  57. var elaaaaa = document.getElementById('auto3');
  58. if (autoHybrid) {
  59. autoHybrid = false
  60. elaaaaa.textContent = 'Auto Upgrade (Hybrid):Disabled'
  61. clearInterval(testeeee)
  62. } else {
  63. autoHybrid = true;
  64. elaaaaa.textContent = 'Auto Upgrade (Hybrid):Enabled';
  65. window.testeeee = setInterval(autohybrids,1000)
  66. function autohybrids() {
  67. 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);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);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);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)
  68. }
  69. }
  70. window.statusBar();
  71. return autoHybrid()
  72. }
  73.  
  74. //Troop selecting
  75. window.addEventListener("keyup", function(a) {
  76. a = a.keyCode ? a.keyCode : a.which;
  77.  
  78. if (a === 81) { // All troops except commander
  79. selUnits = [];
  80. units.forEach((unit) => {
  81. if (unit.owner === player.sid && unit.type === 1) {
  82. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  83. unit.info.name !== 'Commander' && selUnits.push(unit)
  84. }
  85. });
  86. selUnitType = "Unit";
  87. } else if (a === 69) { // All troops
  88. selUnits = [];
  89. units.forEach((unit) => {
  90. if (unit.owner === player.sid && unit.type === 1) {
  91. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  92. selUnits.push(unit)
  93. }
  94. });
  95. selUnitType = "Unit";
  96. } else if (a === 67) { // Commander only
  97. selUnits = [];
  98. units.every((unit) => {
  99. if (unit.owner === player.sid && unit.type === 1) {
  100. if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
  101. if (unit.info.name === 'Commander') {
  102. selUnits.push(unit)
  103. return false;
  104. }
  105. }
  106. return true;
  107. });
  108. selUnitType = "Unit";
  109. }
  110. });
  111.  
  112. //Zoom
  113. var scroll=0;
  114. mainCanvas["addEventListener"]?(window["addEventListener"]("mousewheel",zoom,!1),mainCanvas["addEventListener"]("DOMMouseScroll",zoom,!1)):window["attachEvent"]("onmousewheel",zoom);function zoom(a)
  115. {
  116. a= window["event"]|| a;a["preventDefault"]();a["stopPropagation"]();scroll= Math["max"](-1,Math["min"](1,a["wheelDelta"]|| -a["detail"]));if(scroll== -1)
  117. {
  118. if(maxScreenHeight< 10000)
  119. {
  120. (maxScreenHeight+= 250,maxScreenWidth+= 250,resize());scroll= 0
  121. }
  122. }
  123. if(scroll== 1)
  124. {
  125. if(maxScreenHeight> 1000)
  126. {
  127. (maxScreenHeight-= 250,maxScreenWidth-= 250,resize());scroll= 0
  128. }
  129. }
  130. }
  131. mainCanvas["onkeydown"]= function(event)
  132. {
  133. var k=event["keyCode"]?event["keyCode"]:event["which"];
  134. if(k== 70)
  135. {
  136. if(maxScreenHeight< 10000)
  137. {
  138. (maxScreenHeight+= 250,maxScreenWidth+= 250,resize())
  139. }
  140. }
  141. if(k== 67)
  142. {
  143. if(maxScreenHeight> 1000)
  144. {
  145. (maxScreenHeight-= 250,maxScreenWidth-= 250,resize())
  146. }
  147. }
  148. {
  149. if(65== a|| 37== a)
  150. {
  151. cameraKeys["l"]= 0,updateCameraInput()
  152. }
  153. if(68== a|| 39== a)
  154. {
  155. cameraKeys["r"]= 0,updateCameraInput()
  156. }
  157. if(87== a|| 38== a)
  158. {
  159. cameraKeys["u"]= 0,updateCameraInput()
  160. }
  161. if(83== a|| 40== a)
  162. {
  163. cameraKeys["d"]= 0,updateCameraInput()
  164. }
  165. if(32== a)
  166. {
  167. var d=unitList["indexOf"](activeUnit);
  168. sendUnit(d)
  169. }
  170. void(0)!= upgrInputsToIndex["k"+ a]&& toggleActiveUnit(upgrInputsToIndex["k"+ a]);46== a&& selUnits["length"]&& sellSelUnits();84== a&& toggleChat("none"== chatListWrapper["style"]["display"]);27== a&& (toggleActiveUnit(),disableSelUnit(),showSelector= !1);82== a&& (camY= camX= 0)
  171. }
  172. }
  173. ;mainCanvas["onkeydown"]= function(a)
  174. {
  175. 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()))
  176. }
  177.  
  178. //Dark theme
  179. window.UIList = window.UIList || [];
  180. window.initFuncs = window.initFuncs || [];
  181. window.statusItems = window.statusItems || [];
  182. window.useTheme = true;
  183. window.UIList.push({
  184. level: 0,
  185. x: 0,
  186. html: '<div id="Theme" onclick=theme()>White Theme</div>'
  187. });
  188. window.theme = function () {
  189. var el = document.getElementById('Theme');
  190. if (useTheme) {
  191. useTheme = false
  192. backgroundColor = "#ebebeb",
  193. outerColor="#d6d6d6"
  194. indicatorColor =
  195. "rgba(0,0,0,0.08)",
  196. turretColor = "#A8A8A8",
  197. bulletColor = "#A8A8A8",
  198. redColor = "rgba(255, 0, 0, 0.1)",
  199. el.textContent = 'White Theme'
  200. } else {
  201. useTheme = true;
  202. backgroundColor = "#0c0d15",
  203. outerColor = "#05060b",
  204. indicatorColor = "#878787",
  205. "rgba(255, 0, 0, 0.1)",//rgba(169,168,168)
  206. turretColor = "#A8A8A8",
  207. bulletColor = "#A8A8A8",
  208. redColor = "rgba(255, 0, 0, 0.5)",
  209. el.textContent = 'Ðårk †hêmê';
  210. populate();
  211. }
  212. window.statusBar();
  213. return useTheme;
  214. }
  215.  
  216. //One-click upgrade/sell
  217. window.UIList = window.UIList || [];
  218. window.initFuncs = window.initFuncs || [];
  219. window.statusItems = window.statusItems || [];
  220. window.UIList.push({
  221. level: 1,
  222. x: 1,
  223. html: '<div onclick=greaterBarracks()>Upgrade Greater Barracks</div>'
  224. }, {
  225. level: 1,
  226. x: 2,
  227. html: '<div onclick=instantspike()>Instant Spike</div>'
  228. }, {
  229. level: 1,
  230. x: 3,
  231. html: '<div onclick=sellGenerators()>Sell Generators</div>'
  232. }, {
  233. level: 2,
  234. x: 1,
  235. html: '<div onclick=sellHouse()>Sell House</div>'
  236. }, {
  237. level: 2,
  238. x: 2,
  239. html: '<div onclick=sellall()>Sell All</div>'
  240. },{
  241. level: 2,
  242. x: 3,
  243. html: '<div onclick=sellw()>Sell Inner Walls</div>'
  244. }, {
  245. level: 2,
  246. x: 4,
  247. html: '<div onclick=sellbarracks()>Sell All Barracks</div>'
  248. });
  249.  
  250. function emit2() {
  251. socket.emit.apply(socket, arguments);
  252. }
  253. window.sellw = function () {
  254. 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);
  255. socket.emit("3", a)
  256. }
  257. window.sellGenerators = window.sellGenerators || function () {
  258. for (var a = [], d = 0; d < units.length; ++d) {
  259. if (units[d].type === 0 && units[d].owner == player.sid) {
  260. var name = getUnitFromPath(units[d].uPath).name;
  261. (name === 'Generator' || name === 'Power Plant') && a.push(units[d].id)
  262. }
  263. }
  264. socket.emit("3", a)
  265. }
  266. window.instantspike = window.instantspike || function () {
  267. 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)
  268. }
  269. setInterval(inspike,100)
  270. function inspike() {
  271. 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)
  272. }
  273. window.greaterBarracks = window.greaterBarracks || function () {
  274. for (var i = 0; i < units.length; ++i) 2 == units[i].type && "square" == units[i].shape && units[i].owner == player.sid && socket.emit("4", units[i].id, 0)
  275. }
  276. window.sellbarracks = function () {
  277. for (var a = [], d = 0; d < units.length; ++d) {
  278. if (units[d].type === 2 && units[d].owner == player.sid) {
  279. var name = getUnitFromPath(units[d].uPath).name;
  280. (name === 'Barracks' || name === 'Greater Barracks' || name === 'Tank Factory' || name === 'Siege Factory' || name === 'Blitz Factory') && a.push(units[d].id)
  281. }
  282. }
  283. socket.emit("3", a)
  284. }
  285. window.sellHouse = function () {
  286. 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);
  287. socket.emit("3", a)
  288. }
  289. window.sellwalls = function () {
  290. 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);
  291. socket.emit("3", a)
  292. }
  293. window.sellinner = function () {
  294. for (var a = [], d = 0; d < units.length; ++d) {
  295. if (units[d].type === 0 && units[d].owner == player.sid) {
  296. a.push(units[d].id)
  297. }
  298. }
  299. socket.emit("3", a)
  300. }
  301. window.sellall = function () {
  302. 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);
  303. socket.emit("3", a)
  304. }
  305.  
  306. window.makeUI = function () {
  307. if (window.hasMadeUI) return;
  308. window.hasMadeUI = true;
  309. window.statusItems.sort(function (a, b) {
  310. return a.order - b.order;
  311. })
  312. var levels = [];
  313. window.UIList.forEach((item) => {
  314. if (!levels[item.level]) levels[item.level] = [];
  315. levels[item.level].push(item)
  316. })
  317.  
  318. levels = levels.filter((a) => {
  319. if (a) {
  320. a.sort(function (a, b) {
  321. return a.x - b.x;
  322. })
  323. return true;
  324. } else {
  325. return false;
  326. }
  327. })
  328.  
  329. var headAppend = document.getElementsByTagName("head")[0],
  330. style = document.createElement("div");
  331.  
  332. var toast = document.createElement('div');
  333. toast.id = "snackbar";
  334. var css = document.createElement('div');
  335.  
  336. css.innerHTML = '<style>\n\
  337. #snackbar {\n\
  338. visibility: hidden;\n\
  339. min-width: 250px;\n\
  340. margin-left: -125px;\n\
  341. background-color: rgba(40, 40, 40, 0.5);\n\
  342. color: #fff;\n\
  343. text-align: center;\n\
  344. border-radius: 4px;\n\
  345. padding: 10px;\n\
  346. font-family: "regularF";\n\
  347. font-size: 16px;\n\
  348. position: left;\n\
  349. z-index: 100;\n\
  350. left: 50%;\n\
  351. top: 30px;\n\
  352. }\n\
  353. #snackbar.show {\n\
  354. visibility: visible;\n\
  355. -webkit-animation: fadein 0.1s;\n\
  356. animation: fadein 0.1s;\n\
  357. }\n\
  358. #snackbar.hide {\n\
  359. visibility: visible;\n\
  360. -webkit-animation: fadeout 0.1s;\n\
  361. animation: fadeout 0.1s;\n\
  362. }\n\
  363. @-webkit-keyframes fadein {\n\
  364. from {top: 0; opacity: 0;}\n\
  365. to {top: 30px; opacity: 1;}\n\
  366. }\n\
  367. @keyframes fadein {\n\
  368. from {top: 0; opacity: 0;}\n\
  369. to {top: 30px; opacity: 1;}\n\
  370. }\n\
  371. @-webkit-keyframes fadeout {\n\
  372. from {top: 30px; opacity: 1;}\n\
  373. to {top: 0; opacity: 0;}\n\
  374. }\n\
  375. @keyframes fadeout {\n\
  376. from {top: 30px; opacity: 1;}\n\
  377. to {top: 0; opacity: 0;}\n\
  378. }\n\
  379. </style>'
  380. var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
  381. style.innerHTML = "<style>\n\
  382. #noobscriptUI, #noobscriptUI > div > div {\n\
  383. background-color:rgba(40,40,40,.5);\n\
  384. margin-left: 3px;\n\
  385. border-radius:4px;\n\
  386. pointer-events:all\n\
  387. }\n\
  388. #noobscriptUI {\n\
  389. top: -" + (height + 12) + "px;\n\
  390. transition: 0.5s;\n\
  391. margin-left:10px;\n\
  392. position:absolute;\n\
  393. padding-left:24px;\n\
  394. margin-top:9px;\n\
  395. padding-top:15px;\n\
  396. width:580px;\n\
  397. height: " + height + "px;\n\
  398. font-family:arial;\n\
  399. left:25%\n\
  400. }\n\
  401. #noobscriptUI:hover{\n\
  402. top:0px\n\
  403. }\n\
  404. #noobscriptUI > div > div {\n\
  405. color:#fff;\n\
  406. padding:7px;\n\
  407. height:19px;\n\
  408. display:inline-block;\n\
  409. cursor:pointer;\n\
  410. font-size:16px\n\
  411. }\n\
  412. </style>"
  413.  
  414. headAppend.appendChild(style);
  415. headAppend.appendChild(css);
  416.  
  417.  
  418. var contAppend = document.getElementById("gameUiContainer"),
  419. menuA = document.createElement("div");
  420.  
  421. var code = ['<div id="noobscriptUI">\n'];
  422.  
  423. levels.forEach((items, i) => {
  424. code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
  425. items.forEach((el) => {
  426. code.push(' ' + el.html + '\n');
  427. })
  428. code.push(' </div>\n');
  429. })
  430. code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
  431. code.push('</div>');
  432.  
  433. menuA.innerHTML = code.join("");
  434. contAppend.insertBefore(menuA, contAppend.firstChild)
  435. contAppend.appendChild(toast)
  436. var toastTimeout = false;
  437. window.showToast = function (msg) {
  438. toast.textContent = msg;
  439.  
  440. if (toastTimeout) clearTimeout(toastTimeout);
  441. else toast.className = "show";
  442. toastTimeout = setTimeout(function () {
  443. toast.className = 'hide'
  444. setTimeout(function () {
  445. toast.className = '';
  446. }, 400);
  447. toastTimeout = false;
  448. }, 3000);
  449. }
  450. window.statusBar = function () {
  451. var el = document.getElementById('confinfo');
  452. var text = [];
  453.  
  454. window.statusItems.forEach((item, i) => {
  455. if (i !== 0) text.push(' ');
  456. if (item.name) text.push(item.name + ': ');
  457. text.push(item.value());
  458. })
  459.  
  460. el.textContent = text.join('');
  461. }
  462. window.statusBar();
  463.  
  464. window.initFuncs.forEach((func) => {
  465. func();
  466. })
  467. }
  468. setTimeout(() => {
  469. window.makeUI();
  470. }, 1000)
  471.  
  472. //Another one-click upgrade
  473. window.makeUI = function () {
  474. if (window.hasMadeUI) return;
  475. window.hasMadeUI = true;
  476. window.statusItems.sort(function (a, b) {
  477. return a.order - b.order;
  478. })
  479. var levels = [];
  480. window.UIList.forEach((item) => {
  481. if (!levels[item.level]) levels[item.level] = [];
  482. levels[item.level].push(item)
  483. })
  484.  
  485. levels = levels.filter((a) => {
  486. if (a) {
  487. a.sort(function (a, b) {
  488. return a.x - b.x;
  489. })
  490. return true;
  491. } else {
  492. return false;
  493. }
  494. })
  495.  
  496. var headAppend = document.getElementsByTagName("head")[0],
  497. style = document.createElement("div");
  498.  
  499. var toast = document.createElement('div');
  500. toast.id = "snackbar";
  501. var css = document.createElement('div');
  502.  
  503. css.innerHTML = '<style>\n\
  504. #snackbar {\n\
  505. visibility: hidden;\n\
  506. min-width: 250px;\n\
  507. margin-left: -125px;\n\
  508. background-color: rgba(40, 40, 40, 0.5);\n\
  509. color: #fff;\n\
  510. text-align: center;\n\
  511. border-radius: 4px;\n\
  512. padding: 10px;\n\
  513. font-family: "regularF";\n\
  514. font-size: 16px;\n\
  515. position: left;\n\
  516. z-index: 100;\n\
  517. left: 50%;\n\
  518. top: 30px;\n\
  519. }\n\
  520. #snackbar.show {\n\
  521. visibility: visible;\n\
  522. -webkit-animation: fadein 0.1s;\n\
  523. animation: fadein 0.1s;\n\
  524. }\n\
  525. #snackbar.hide {\n\
  526. visibility: visible;\n\
  527. -webkit-animation: fadeout 0.1s;\n\
  528. animation: fadeout 0.1s;\n\
  529. }\n\
  530. @-webkit-keyframes fadein {\n\
  531. from {top: 0; opacity: 0;}\n\
  532. to {top: 30px; opacity: 1;}\n\
  533. }\n\
  534. @keyframes fadein {\n\
  535. from {top: 0; opacity: 0;}\n\
  536. to {top: 30px; opacity: 1;}\n\
  537. }\n\
  538. @-webkit-keyframes fadeout {\n\
  539. from {top: 30px; opacity: 1;}\n\
  540. to {top: 0; opacity: 0;}\n\
  541. }\n\
  542. @keyframes fadeout {\n\
  543. from {top: 30px; opacity: 1;}\n\
  544. to {top: 0; opacity: 0;}\n\
  545. }\n\
  546. </style>'
  547. var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
  548. style.innerHTML = "<style>\n\
  549. #noobscriptUI, #noobscriptUI > div > div {\n\
  550. background-color:rgba(40,40,40,.5);\n\
  551. margin-left: 3px;\n\
  552. border-radius:4px;\n\
  553. pointer-events:all\n\
  554. }\n\
  555. #noobscriptUI {\n\
  556. top: -" + (height + 12) + "px;\n\
  557. transition: 0.5s;\n\
  558. margin-left:10px;\n\
  559. position:absolute;\n\
  560. padding-left:24px;\n\
  561. margin-top:9px;\n\
  562. padding-top:15px;\n\
  563. width:580px;\n\
  564. height: " + height + "px;\n\
  565. font-family:arial;\n\
  566. left:25%\n\
  567. }\n\
  568. #noobscriptUI:hover{\n\
  569. top:0px\n\
  570. }\n\
  571. #noobscriptUI > div > div {\n\
  572. color:#fff;\n\
  573. padding:7px;\n\
  574. height:19px;\n\
  575. display:inline-block;\n\
  576. cursor:pointer;\n\
  577. font-size:16px\n\
  578. }\n\
  579. </style>"
  580.  
  581. headAppend.appendChild(style);
  582. headAppend.appendChild(css);
  583.  
  584.  
  585. var contAppend = document.getElementById("gameUiContainer"),
  586. menuA = document.createElement("div");
  587.  
  588. var code = ['<div id="noobscriptUI">\n'];
  589.  
  590. levels.forEach((items, i) => {
  591. code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
  592. items.forEach((el) => {
  593. code.push(' ' + el.html + '\n');
  594. })
  595. code.push(' </div>\n');
  596. })
  597. code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
  598. code.push('</div>');
  599.  
  600. menuA.innerHTML = code.join("");
  601. contAppend.insertBefore(menuA, contAppend.firstChild)
  602. contAppend.appendChild(toast)
  603. var toastTimeout = false;
  604. window.showToast = function (msg) {
  605. toast.textContent = msg;
  606.  
  607. if (toastTimeout) clearTimeout(toastTimeout);
  608. else toast.className = "show";
  609. toastTimeout = setTimeout(function () {
  610. toast.className = 'hide'
  611. setTimeout(function () {
  612. toast.className = '';
  613. }, 400);
  614. toastTimeout = false;
  615. }, 3000);
  616. }
  617. window.statusBar = function () {
  618. var el = document.getElementById('confinfo');
  619. var text = [];
  620.  
  621. window.statusItems.forEach((item, i) => {
  622. if (i !== 0) text.push(' ');
  623. if (item.name) text.push(item.name + ': ');
  624. text.push(item.value());
  625. })
  626.  
  627. el.textContent = text.join('');
  628. }
  629. window.statusBar();
  630.  
  631. window.initFuncs.forEach((func) => {
  632. func();
  633. })
  634. }
  635. setTimeout(() => {
  636. window.makeUI();
  637. }, 1000)
  638. var headAppend=document.getElementsByTagName("head")[0],style=document.createElement("div");style.innerHTML="<style>#upgradeScriptCont,.buttonClass{background-color:rgba(40,40,40,.5);margin-left: 3px;border-radius:4px;pointer-events:all}#upgradeScriptCont{top: -138px;transition: 1s;margin-left:10px;position:absolute;padding-left:24px;margin-top:9px;padding-top:15px;width:530px;height:128px;font-family:arial;left:28%}#upgradeScriptCont:hover{top:0px}.buttonClass{color:#fff;padding:7px;height:19px;display:inline-block;cursor:pointer;font-size:15px}.hoverMessage{color: white;font-size: 14px;position: relative;left: 457px;bottom: 2px;pointer-events: none;}</style>",headAppend.appendChild(style);var contAppend=document.getElementById("gameUiContainer"),menuA=document.createElement("div");menuA.innerHTML="<div id=upgradeScriptCont><div id=layer1><div id=walls class=buttonClass onclick=walls()>Buy Walls</div><div id=upgradeBoulders class=buttonClass onclick=boulders()>Upgrade Boulders</div><div id=upgradeSpikes class=buttonClass onclick=spikes()>Upgrade Spikes</div><div id=upgradeGen class=buttonClass onclick=powerPlants()>Upgrade Power Plants</div></div><div id=layer2 style=margin-top:7px;margin-left:7px><div id=walls class=buttonClass onclick=generators()>Buy Generators</div><div id=upgradeBoulders class=buttonClass onclick=rapid()>Upgrade Rapid</div><div id=upgradeSpikes class=buttonClass onclick=ranged()>Upgrade Ranged</div><div id=upgradeGen class=buttonClass onclick=antiTank()>Upgrade anti-tank</div></div><div id=layer3 style=margin-top:7px;margin-left:-16px><div id=walls class=buttonClass onclick=gatlins()>Upgrade Gatlins</div><div id=upgradeBoulders class=buttonClass onclick=spotter()>Upgrade spotter</div><div id=upgradeMicro class=buttonClass onclick=microGenerators()>Upgrade Micro-Gen</div><div id=upgradeSpikes class=buttonClass onclick=semiAuto()>Upgrade Semi-auto</div></div><span class=hoverMessage>Hover over</span></div>",contAppend.insertBefore(menuA,contAppend.firstChild),window.walls=function(){for(i=-3.14;i<3.14;i+=.108)socket.emit("1",i,1e3,1)},window.generators=function(){for(i=-3.14;i<3.14;i+=.075)socket.emit("1",i,132,3)},window.boulders=function(){for(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)},window.microGenerators=function(){for(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)},window.spikes=function(){for(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)},window.powerPlants=function(){for(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)},window.rapid=function(){for(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)},window.ranged=function(){for(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)},window.antiTank=function(){for(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)},window.semiAuto=function(){for(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)},window.gatlins=function(){for(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)},window.spotter=function(){for(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)};
  639.  
  640. //InstaFind
  641. var gotoUsers = [];
  642. var gotoIndex = 0;
  643. window.overrideSocketEvents = window.overrideSocketEvents || [];
  644. window.chatCommands = window.chatCommands || {};
  645.  
  646. window.chatCommands.find = function(split) {
  647. var name = split.slice(1).join(' ');
  648. if (name == '') {
  649. addChat('Please specify a username', 'Client')
  650. return;
  651. }
  652. window.goto(name)
  653. }
  654. window.overrideSocketEvents.push({
  655. name: "l",
  656. description: "Leaderboard Insta Find override",
  657. func: function(a) {
  658. var d = "",
  659. c = 1,
  660. b = 0;
  661. for (; b < a.length;) {
  662. 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;
  663. }
  664. leaderboardList.innerHTML = d;
  665. }
  666. })
  667. leaderboardList.style.pointerEvents = 'auto';
  668. chatListWrapper.style.pointerEvents = 'auto';
  669.  
  670. window.goto = function(username) {
  671. gotoUsers = users.filter((user) => {
  672. return user.name === username
  673. });
  674. gotoIndex = 0;
  675. if (gotoUsers[0]) {
  676. camX = gotoUsers[0].x - player.x;
  677. camY = gotoUsers[0].y - player.y;
  678. }
  679. addChat(gotoUsers.length + ' users found with the name ' + username, 'Client');
  680. return gotoUsers.length;
  681. }
  682. window.goto2 = function(id, go) {
  683. gotoUsers = users.filter((user) => {
  684. return user.sid === id;
  685. });
  686. gotoIndex = 0;
  687. if (!go && gotoUsers[0]) {
  688. camX = gotoUsers[0].x - player.x;
  689. camY = gotoUsers[0].y - player.y;
  690. }
  691. return gotoUsers.length;
  692. }
  693.  
  694. window.gotoLeft = function() {
  695. if (!gotoUsers.length) return;
  696.  
  697. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  698. if (gotoIndex <= 0) gotoIndex = gotoUsers.length;
  699. gotoIndex--;
  700. }
  701. camX = gotoUsers[gotoIndex].x - player.x;
  702. camY = gotoUsers[gotoIndex].y - player.y;
  703. }
  704.  
  705. window.gotoRight = function() {
  706. if (!gotoUsers.length) return;
  707.  
  708. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  709. if (gotoIndex >= gotoUsers.length - 1) gotoIndex = -1;
  710. gotoIndex++;
  711. }
  712. camX = gotoUsers[gotoIndex].x - player.x;
  713. camY = gotoUsers[gotoIndex].y - player.y;
  714. }
  715.  
  716. window.addChat = function(msg, from, color) {
  717. color = color || "#fff";
  718. var b = document.createElement("li");
  719. b.className = "chatother";
  720. b.innerHTML = '<span style="color:' + color + '">[' + from + ']</span> <span class="chatText">' + msg + "</span>";
  721. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  722. chatList.appendChild(b)
  723. }
  724.  
  725. // Override
  726. window.resetCamera = function() {
  727. camX = camXS = camY = camYS = 0;
  728. cameraKeys = {
  729. l: 0,
  730. r: 0,
  731. u: 0,
  732. d: 0
  733. }
  734.  
  735. if (socket && window.overrideSocketEvents && window.overrideSocketEvents.length) {
  736. window.overrideSocketEvents.forEach((item) => {
  737. socket.removeAllListeners(item.name)
  738. socket.on(item.name, item.func);
  739.  
  740. });
  741.  
  742. }
  743. }
  744.  
  745. window.addChatLine = function(a, d, c) {
  746. if (player) {
  747. var b = getUserBySID(a);
  748. if (c || 0 <= b) {
  749. var g = c ? "SERVER" : users[b].name;
  750. c = c ? "#fff" : playerColors[users[b].color] ? playerColors[users[b].color] : playerColors[0];
  751. player.sid == a && (c = "#fff");
  752. b = document.createElement("li");
  753. b.className = player.sid == a ? "chatme" : "chatother";
  754.  
  755. b.innerHTML = '<span style="color:' + c + '" onclick=goto2(' + a + ');>[' + g + ']</span> <span class="chatText">' + d + "</span>";
  756. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  757. chatList.appendChild(b)
  758. }
  759. }
  760. }
  761.  
  762. window.addEventListener("keyup", function(a) {
  763. a = a.keyCode ? a.keyCode : a.which;
  764. if (a === 190) {
  765. window.gotoRight()
  766. } else if (a === 188) {
  767. window.gotoLeft();
  768. }
  769.  
  770. });
  771.  
  772.  
  773. //Zoom
  774. var scroll = 0;
  775. mainCanvas.addEventListener ? (window.addEventListener("mousewheel", zoom, !1),
  776. mainCanvas.addEventListener("DOMMouseScroll", zoom, !1)) : window.attachEvent("onmousewheel", zoom);
  777. function zoom(a) {
  778. a = window.event || a;
  779. a.preventDefault();
  780. a.stopPropagation();
  781. scroll = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
  782. if (scroll == -1) { //zoom out
  783. if (maxScreenHeight < 10000) {
  784. (maxScreenHeight += 250, maxScreenWidth += 250, resize());
  785. scroll = 0
  786. }
  787. }
  788.  
  789. if (scroll == 1) { //zoom in
  790. if (maxScreenHeight > 1000) {
  791. (maxScreenHeight -= 250, maxScreenWidth -= 250, resize())
  792. scroll = 0
  793. }
  794. }
  795. }
  796.  
  797. mainCanvas.onkeydown = function(event) {
  798. var k = event.keyCode ? event.keyCode : event.which;
  799. if (k == 45) { // - to zoom out
  800. if (maxScreenHeight < 10000) {
  801. (maxScreenHeight += 250, maxScreenWidth += 250, resize());
  802. }
  803. }
  804. if (k == 61) {// = to zoom in
  805. if (maxScreenHeight > 1000) {
  806. (maxScreenHeight -= 250, maxScreenWidth -= 250, resize())
  807. }
  808.  
  809. }
  810.  
  811. {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);
  812. 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()))}
  813.  
  814. addEventListener("keydown", function(a) {
  815. if (a.keyCode == 77){
  816. for(i=0;i<users.length;++i){
  817. if(users[i].name.startsWith("[G]")&&users[i].name !== player.name){
  818. camX = users[i].x-player.x;
  819. camY = users[i].y-player.y;
  820. }
  821. }
  822. }
  823. });
  824.  
  825. window.UIList = window.UIList || [];
  826. window.initFuncs = window.initFuncs || [];
  827. window.statusItems = window.statusItems || [];
  828.  
  829. window.sendIndex = 0;
  830. window.loops = 0;
  831. window.hasSentTarget = false;
  832. window.usePatch = true;
  833. window.cache = [];
  834. window.cacheHeight = 0;
  835. window.cacheIndexes = 0;
  836. window.shift = false;
  837. window.sendFrequency = 1E3 / 15
  838. window.UIList.push({
  839. level: 0,
  840. x: 3,
  841. description: 'Zoom Patch',
  842. html: '<div id="patch" onclick=patch()>Zoom:Disabled</div>'
  843. });
  844.  
  845. window.statusItems.push({
  846. name: 'Zoom Patch',
  847. order: 2,
  848. value: function () {
  849. return usePatch ? 'On' : 'Off';
  850. }
  851. });
  852.  
  853. window.patch = function () {
  854. var el = document.getElementById('patch');
  855. if (usePatch) {
  856. usePatch = false
  857. socket.emit("2", Math.round(camX), Math.round(camY))
  858. el.textContent = 'Zoom:Enabled'
  859. } else {
  860. usePatch = true;
  861. el.textContent = 'Zoom:Disabled';
  862. populate();
  863. }
  864. window.statusBar();
  865. return usePatch;
  866. }
  867.  
  868.  
  869. function populate() {
  870. if (!usePatch) return;
  871. cacheHeight = Math.round(maxScreenHeight / 1080);
  872. cacheIndexes = cacheHeight * cacheHeight - 1;
  873. for (var i = cache.length; i < cacheIndexes; i++) {
  874. cache[i] = spiral(i);
  875. }
  876. }
  877. populate();
  878.  
  879. function zoom(a) {
  880. a = window.event || a;
  881. a.preventDefault();
  882. a.stopPropagation();
  883. scroll = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
  884. if (scroll == -1) { //zoom out
  885. if (maxScreenHeight < 30000) {
  886. (maxScreenHeight += 250, maxScreenWidth += 250, resize(true));
  887. cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
  888. scroll = 0
  889. populate()
  890. }
  891. }
  892.  
  893. if (scroll == 1) { //zoom in
  894. if (maxScreenHeight > 1080) {
  895. (maxScreenHeight -= 250, maxScreenWidth -= 250, resize(true))
  896. cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
  897. scroll = 0
  898. populate()
  899. }
  900. }
  901. }
  902. mainCanvas.addEventListener ? (window.addEventListener("mousewheel", zoom, !1),
  903. mainCanvas.addEventListener("DOMMouseScroll", zoom, !1)) : window.attachEvent("onmousewheel", zoom);
  904.  
  905. function spiral(n) {
  906. var r = Math.floor((Math.sqrt(n + 1) - 1) / 2) + 1;
  907. var p = (8 * r * (r - 1)) / 2;
  908. var en = r * 2;
  909. var a = (1 + n - p) % (r * 8);
  910. var pos = [0, 0, r];
  911. switch (Math.floor(a / (r * 2))) {
  912. case 0:
  913. pos[0] = a - r;
  914. pos[1] = -r;
  915. break;
  916. case 1:
  917. pos[0] = r;
  918. pos[1] = (a % en) - r;
  919. break;
  920. case 2:
  921. pos[0] = r - (a % en);
  922. pos[1] = r;
  923. break;
  924. case 3:
  925. pos[0] = -r;
  926. pos[1] = r - (a % en);
  927. break;
  928. }
  929. return pos;
  930. }
  931.  
  932. window.initFuncs.push(function () {
  933. var js = window.updateGameLoop.toString();
  934.  
  935. var ind = js.indexOf('if (gameState && mapBounds) {');
  936. if (ind === -1) ind = js.indexOf('if (gameState&&mapBounds) {');
  937. if (ind === -1) ind = js.indexOf('if(gameState&&mapBounds){');
  938.  
  939. var ind2 = js.indexOf('}', ind);
  940.  
  941. var n = js.substring(0, ind) + 'if(gameState&&mapBounds){if(camXS||camYS)camX+=camXS*cameraSpd*a,camY+=camYS*cameraSpd*a;player.x+camX<mapBounds[0]?camX=mapBounds[0]-player.x:player.x+camX>mapBounds[0]+mapBounds[2]&&(camX=mapBounds[0]+mapBounds[2]-player.x);player.y+camY<mapBounds[1]?camY=mapBounds[1]-player.y:player.y+camY>mapBounds[1]+mapBounds[3]&&(camY=mapBounds[1]+mapBounds[3]-player.y);if(currentTime-lastCamSend>=sendFrequency)if(lastCamSend=currentTime,usePatch&&cacheIndexes)if(lastCamX!=camX||lastCamY!=camY)lastCamX=camX,lastCamY=camY,loop=sendIndex=0;else{if(4>=loop){if(sendIndex%2)(sendIndex-1)%6?socket.emit("2",Math.round(camX),Math.round(camY)):socket.emit("2",0,0);else{var index=sendIndex/2;index>=cacheIndexes?(sendIndex=0,loop++):socket.emit("2",Math.round(camX+1920*cache[index][0]),Math.round(camY+1080*cache[index][1]))}hasSentTarget=!1;sendIndex++}}else lastCamX==camX&&lastCamY==camY&&hasSentTarget||(lastCamX=camX,hasSentTarget=!0,lastCamY=camY,loop=0,socket.emit("2",Math.round(camX),Math.round(camY)))}' +
  942. js.substr(ind2 + 1);
  943. n = n.substring(n.indexOf('{') + 1, n.lastIndexOf('}'));
  944. window.updateGameLoop = new Function('a', n)
  945.  
  946. });