MORE compact noobscript

GREAT for Noobscript V4 Parte 3 users

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