MORE compact noobscript (no base transparent)

GREAT for Noobscript V4 Parte 3 users

目前為 2020-05-25 提交的版本,檢視 最新版本

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