- // ==UserScript==
- // @name MORE compact noobscript
- // @namespace http://tampermonkey.net/
- // @version 1.1
- // @description GREAT for Noobscript V4 Parte 3 users
- // @author barely heard of 5O5
- // @match http://bloble.io/*
- // @grant none
- // ==/UserScript==
-
- //base transparente :)
- window.renderPlayer = function(a, d, c, b, g) {
- b.save();
- if (a.skin && 0 < a.skin && a.skin <= playerSkins && !skinSprites[a.skin]) {
- var e = new Image;
- e.onload = function() {
- this.readyToDraw = !0;
- this.onload = null;
- g == currentSkin && changeSkin(0);
- };
- e.src = ".././img/skins/skin_" + (a.skin - 1) + ".png";
- skinSprites[a.skin] = e;
- }
- 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));
- b.restore();
- };
-
- //Auto Upgrade microgen/powerplant
- window.UIList = window.UIList || [];
- window.initFuncs = window.initFuncs || [];
- window.statusItems = window.statusItems || [];
- window.autoDefense = false;
- window.UIList.push({
- level: 3,
- x: 4,
- html: '<div id=auto onclick=autodefense()>Auto Upgrade micro/powerplant:Disabled</div>'
- });
- window.autodefense = function () {
- var elaa = document.getElementById('auto');
- if (autoDefense) {
- autoDefense = false
- elaa.textContent = 'Auto Upgrade micro/powerplant:Disabled'
- clearInterval(teste)
- } else {
- autoDefense = true;
- elaa.textContent = 'Auto Upgrade micro/powerplant:Enabled';
- window.teste = setInterval(autodefesa,2000)
- function autodefesa() {
- 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)
- }
- }
- window.statusBar();
- return autoDefense()
- };
-
- //Troop selecting
- window.addEventListener("keyup", function(a) {
- a = a.keyCode ? a.keyCode : a.which;
-
- if (a === 81) { // All troops except commander
- selUnits = [];
- units.forEach((unit) => {
- if (unit.owner === player.sid && unit.type === 1) {
- if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
- unit.info.name !== 'Commander' && selUnits.push(unit)
- }
- });
- selUnitType = "Unit";
- } else if (a === 69) { // All troops
- selUnits = [];
- units.forEach((unit) => {
- if (unit.owner === player.sid && unit.type === 1) {
- if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
- selUnits.push(unit)
- }
- });
- selUnitType = "Unit";
- } else if (a === 67) { // Commander only
- selUnits = [];
- units.every((unit) => {
- if (unit.owner === player.sid && unit.type === 1) {
- if (!unit.info) unit.info = getUnitFromPath(unit.uPath);
- if (unit.info.name === 'Commander') {
- selUnits.push(unit)
- return false;
- }
- }
- return true;
- });
- selUnitType = "Unit";
- }
- });
-
- //Zoom
- var scroll=0;
- mainCanvas["addEventListener"]?(window["addEventListener"]("mousewheel",zoom,!1),mainCanvas["addEventListener"]("DOMMouseScroll",zoom,!1)):window["attachEvent"]("onmousewheel",zoom);function zoom(a)
- {
- a= window["event"]|| a;a["preventDefault"]();a["stopPropagation"]();scroll= Math["max"](-1,Math["min"](1,a["wheelDelta"]|| -a["detail"]));if(scroll== -1)
- {
- if(maxScreenHeight< 10000)
- {
- (maxScreenHeight+= 250,maxScreenWidth+= 250,resize());scroll= 0
- }
- }
- if(scroll== 1)
- {
- if(maxScreenHeight> 1000)
- {
- (maxScreenHeight-= 250,maxScreenWidth-= 250,resize());scroll= 0
- }
- }
- }
- mainCanvas["onkeydown"]= function(event)
- {
- var k=event["keyCode"]?event["keyCode"]:event["which"];
- if(k== 70)
- {
- if(maxScreenHeight< 10000)
- {
- (maxScreenHeight+= 250,maxScreenWidth+= 250,resize())
- }
- }
- if(k== 67)
- {
- if(maxScreenHeight> 1000)
- {
- (maxScreenHeight-= 250,maxScreenWidth-= 250,resize())
- }
- }
- {
- 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"]);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()))
- }
-
- //Dark theme :DDDDDD
- window.UIList = window.UIList || [];
- window.initFuncs = window.initFuncs || [];
- window.statusItems = window.statusItems || [];
- window.useTheme = true;
- window.UIList.push({
- level: 0,
- x: 0,
- html: '<div id="Theme" onclick=theme()>White Theme</div>'
- });
- window.theme = function () {
- var el = document.getElementById('Theme');
- if (useTheme) {
- useTheme = false
- backgroundColor = "#ebebeb",
- outerColor="#d6d6d6"
- indicatorColor =
- "rgba(0,0,0,0.08)",
- turretColor = "#A8A8A8",
- bulletColor = "#A8A8A8",
- redColor = "rgba(255, 0, 0, 0.1)",
- el.textContent = 'White Theme'
- } else {
- useTheme = true;
- backgroundColor = "#0c0d15",//000000
- outerColor = "#05060b",//00000a
- indicatorColor = "#878787",//f2d00c
- "rgba(255, 0, 0, 0.1)",//rgba(169,168,168)
- turretColor = "#A8A8A8",
- bulletColor = "#A8A8A8",
- redColor = "rgba(255, 0, 0, 0.5)",
- el.textContent = 'Ðårk †hêmê';
- populate();
- }
- window.statusBar();
- return useTheme;
- }
-
- //One-click upgrade/sell
- window.UIList = window.UIList || [];
- window.initFuncs = window.initFuncs || [];
- window.statusItems = window.statusItems || [];
- window.UIList.push({
- level: 0,
- x: 0,
- html: '<div onclick=buildGenerators()>Build Generators</div>'
- }, {
- level: 0,
- x: 1,
- html: '<div onclick=walls()>Build Walls</div>'
- }, {
- level: 1,
- x: 0,
- html: '<div onclick=boulders()>Upgrade Boulders</div>'
- }, {
- level: 1,
- x: 1,
- html: '<div onclick=spikes()>Upgrade Spikes</div>'
- }, {
- level: 1,
- x: 2,
- html: '<div onclick=microGenerators()>Mico-Generators</div>'
- }, {
- level: 1,
- x: 3,
- html: '<div onclick=powerPlants()>Upgrade Power Plants</div>'
- }, {
- level: 2,
- x: 0,
- html: '<div onclick=sellGenerators()>Sell Generators</div>'
- }, {
- level: 2,
- x: 4,
- html: '<div onclick=greaterBarracks()>Upgrade Greater Barracks</div>'
- }, {
- level: 0,
- x: 2,
- html: '<div onclick=sellHouse()>Sell House</div>'
- }, {
- level: 2,
- x: 1,
- html: '<div onclick=sellall()>Sell all</div>'
- },{
- level: 0,
- x: 0,
- html: '<div onclick=sellw()>Sell Inner Walls</div>'
- });
-
- function emit2() {
- socket.emit.apply(socket, arguments);
- }
-
- window.sellw = function () {
- 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);
- socket.emit("3", a)
- }
- window.walls = function () {
- for (i = -3.14; i < 3.14; i += .108) emit2("1", i, 1e3, 1)
- }
- window.sellGenerators = window.sellGenerators || function () {
- for (var a = [], d = 0; d < units.length; ++d) {
- if (units[d].type === 0 && units[d].owner == player.sid) {
- var name = getUnitFromPath(units[d].uPath).name;
- (name === 'Generator' || name === 'Power Plant') && a.push(units[d].id)
- }
- }
- socket.emit("3", a)
- }
- window.sellHouse = function () {
- 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);
- socket.emit("3", a)
- }
- window.sellwalls = function () {
- 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);
- socket.emit("3", a)
- }
- window.sellinner = function () {
- for (var a = [], d = 0; d < units.length; ++d) {
- if (units[d].type === 0 && units[d].owner == player.sid) {
- a.push(units[d].id)
- }
- }
- socket.emit("3", a)
- }
- window.sellall = function () {
- 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);
- socket.emit("3", a)
- }
- window.boulders = window.boulders || function () {
- 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)
- }
- window.greaterBarracks = window.greaterBarracks || function () {
- 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)
- }
- window.microGenerators = window.microGenerators || function () {
- 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)
- }
- window.spikes = window.spikes || function () {
- 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)
- }
- window.powerPlants = window.powerPlants || function () {
- 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)
- }
- window.rapid = window.rapid || function () {
- 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)
- }
- window.ranged = window.ranged || function () {
- 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)
- }
- window.antiTank = window.antiTank || function () {
- 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)
- }
- window.semiAuto = window.semiAuto || function () {
- 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)
- }
- window.gatlins = window.gatlins || function () {
- 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)
- }
- window.spotter = window.spotter || function () {
- 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)
- };
-
- window.makeUI = function () {
- if (window.hasMadeUI) return;
- window.hasMadeUI = true;
- window.statusItems.sort(function (a, b) {
- return a.order - b.order;
- })
- var levels = [];
- window.UIList.forEach((item) => {
- if (!levels[item.level]) levels[item.level] = [];
- levels[item.level].push(item)
- })
-
- levels = levels.filter((a) => {
- if (a) {
- a.sort(function (a, b) {
- return a.x - b.x;
- })
- return true;
- } else {
- return false;
- }
- })
-
- var headAppend = document.getElementsByTagName("head")[0],
- style = document.createElement("div");
-
- var toast = document.createElement('div');
- toast.id = "snackbar";
- var css = document.createElement('div');
-
- css.innerHTML = '<style>\n\
- #snackbar {\n\
- visibility: hidden;\n\
- min-width: 250px;\n\
- margin-left: -125px;\n\
- background-color: rgba(40, 40, 40, 0.5);\n\
- color: #fff;\n\
- text-align: center;\n\
- border-radius: 4px;\n\
- padding: 10px;\n\
- font-family: "regularF";\n\
- font-size: 20px;\n\
- position: fixed;\n\
- z-index: 100;\n\
- left: 50%;\n\
- top: 30px;\n\
- }\n\
- #snackbar.show {\n\
- visibility: visible;\n\
- -webkit-animation: fadein 0.5s;\n\
- animation: fadein 0.5s;\n\
- }\n\
- #snackbar.hide {\n\
- visibility: visible;\n\
- -webkit-animation: fadeout 0.5s;\n\
- animation: fadeout 0.5s;\n\
- }\n\
- @-webkit-keyframes fadein {\n\
- from {top: 0; opacity: 0;}\n\
- to {top: 30px; opacity: 1;}\n\
- }\n\
- @keyframes fadein {\n\
- from {top: 0; opacity: 0;}\n\
- to {top: 30px; opacity: 1;}\n\
- }\n\
- @-webkit-keyframes fadeout {\n\
- from {top: 30px; opacity: 1;}\n\
- to {top: 0; opacity: 0;}\n\
- }\n\
- @keyframes fadeout {\n\
- from {top: 30px; opacity: 1;}\n\
- to {top: 0; opacity: 0;}\n\
- }\n\
- </style>'
- var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
- style.innerHTML = "<style>\n\
- #noobscriptUI, #noobscriptUI > div > div {\n\
- background-color:rgba(40,40,40,.5);\n\
- margin-left: 3px;\n\
- border-radius:4px;\n\
- pointer-events:all\n\
- }\n\
- #noobscriptUI {\n\
- top: -" + (height + 12) + "px;\n\
- transition: 1s;\n\
- margin-left:10px;\n\
- position:absolute;\n\
- padding-left:24px;\n\
- margin-top:9px;\n\
- padding-top:15px;\n\
- width:580px;\n\
- height: " + height + "px;\n\
- font-family:arial;\n\
- left:25%\n\
- }\n\
- #noobscriptUI:hover{\n\
- top:0px\n\
- }\n\
- #noobscriptUI > div > div {\n\
- color:#fff;\n\
- padding:7px;\n\
- height:19px;\n\
- display:inline-block;\n\
- cursor:pointer;\n\
- font-size:15px\n\
- }\n\
- </style>"
-
- headAppend.appendChild(style);
- headAppend.appendChild(css);
-
-
- var contAppend = document.getElementById("gameUiContainer"),
- menuA = document.createElement("div");
-
- var code = ['<div id="noobscriptUI">\n'];
-
- levels.forEach((items, i) => {
- code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
- items.forEach((el) => {
- code.push(' ' + el.html + '\n');
- })
- code.push(' </div>\n');
- })
- code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
- code.push('</div>');
-
- menuA.innerHTML = code.join("");
- contAppend.insertBefore(menuA, contAppend.firstChild)
- contAppend.appendChild(toast)
- var toastTimeout = false;
- window.showToast = function (msg) {
- toast.textContent = msg;
-
- if (toastTimeout) clearTimeout(toastTimeout);
- else toast.className = "show";
- toastTimeout = setTimeout(function () {
- toast.className = 'hide'
- setTimeout(function () {
- toast.className = '';
- }, 400);
- toastTimeout = false;
- }, 3000);
- }
- window.statusBar = function () {
- var el = document.getElementById('confinfo');
- var text = [];
-
- window.statusItems.forEach((item, i) => {
- if (i !== 0) text.push(' ');
- if (item.name) text.push(item.name + ': ');
- text.push(item.value());
- })
-
- el.textContent = text.join('');
- }
- window.statusBar();
-
- window.initFuncs.forEach((func) => {
- func();
- })
- }
- setTimeout(() => {
- window.makeUI();
- }, 1000)
-
- //InstaFind
- var gotoUsers = [];
- var gotoIndex = 0;
- window.overrideSocketEvents = window.overrideSocketEvents || [];
- window.chatCommands = window.chatCommands || {};
-
- window.chatCommands.find = function(split) {
- var name = split.slice(1).join(' ');
- if (name == '') {
- addChat('Please specify a username', 'Client')
- return;
- }
- window.goto(name)
- }
- window.overrideSocketEvents.push({
- name: "l",
- description: "Leaderboard Insta Find override",
- func: function(a) {
- var d = "",
- c = 1,
- b = 0;
- for (; b < a.length;) {
- 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;
- }
- leaderboardList.innerHTML = d;
- }
- })
- leaderboardList.style.pointerEvents = 'auto';
- chatListWrapper.style.pointerEvents = 'auto';
-
- window.goto = function(username) {
- gotoUsers = users.filter((user) => {
- return user.name === username
- });
- gotoIndex = 0;
- if (gotoUsers[0]) {
- camX = gotoUsers[0].x - player.x;
- camY = gotoUsers[0].y - player.y;
- }
- addChat(gotoUsers.length + ' users found with the name ' + username, 'Client');
- return gotoUsers.length;
- }
- window.goto2 = function(id, go) {
- gotoUsers = users.filter((user) => {
- return user.sid === id;
- });
- gotoIndex = 0;
- if (!go && gotoUsers[0]) {
- camX = gotoUsers[0].x - player.x;
- camY = gotoUsers[0].y - player.y;
- }
- return gotoUsers.length;
- }
-
- window.gotoLeft = function() {
- if (!gotoUsers.length) return;
-
- if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
- if (gotoIndex <= 0) gotoIndex = gotoUsers.length;
- gotoIndex--;
- }
- camX = gotoUsers[gotoIndex].x - player.x;
- camY = gotoUsers[gotoIndex].y - player.y;
- }
-
- window.gotoRight = function() {
- if (!gotoUsers.length) return;
-
- if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
- if (gotoIndex >= gotoUsers.length - 1) gotoIndex = -1;
- gotoIndex++;
- }
- camX = gotoUsers[gotoIndex].x - player.x;
- camY = gotoUsers[gotoIndex].y - player.y;
- }
-
- window.addChat = function(msg, from, color) {
- color = color || "#fff";
- var b = document.createElement("li");
- b.className = "chatother";
- b.innerHTML = '<span style="color:' + color + '">[' + from + ']</span> <span class="chatText">' + msg + "</span>";
- 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
- chatList.appendChild(b)
- }
-
- window.resetCamera = function() { // Override
- camX = camXS = camY = camYS = 0;
- cameraKeys = {
- l: 0,
- r: 0,
- u: 0,
- d: 0
- }
-
- if (socket && window.overrideSocketEvents && window.overrideSocketEvents.length) {
- window.overrideSocketEvents.forEach((item) => {
- socket.removeAllListeners(item.name)
- socket.on(item.name, item.func);
-
- });
-
- }
- }
-
- window.addChatLine = function(a, d, c) {
- if (player) {
- var b = getUserBySID(a);
- if (c || 0 <= b) {
- var g = c ? "SERVER" : users[b].name;
- c = c ? "#fff" : playerColors[users[b].color] ? playerColors[users[b].color] : playerColors[0];
- player.sid == a && (c = "#fff");
- b = document.createElement("li");
- b.className = player.sid == a ? "chatme" : "chatother";
-
- b.innerHTML = '<span style="color:' + c + '" onclick=goto2(' + a + ');>[' + g + ']</span> <span class="chatText">' + d + "</span>";
- 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
- chatList.appendChild(b)
- }
- }
- }
-
- window.addEventListener("keyup", function(a) {
- a = a.keyCode ? a.keyCode : a.which;
- if (a === 190) {
- window.gotoRight()
- } else if (a === 188) {
- window.gotoLeft();
- }
-
- });
-
-
- //Zoom
- var scroll = 0;
- mainCanvas.addEventListener ? (window.addEventListener("mousewheel", zoom, !1),
- mainCanvas.addEventListener("DOMMouseScroll", zoom, !1)) : window.attachEvent("onmousewheel", zoom);
- function zoom(a) {
- a = window.event || a;
- a.preventDefault();
- a.stopPropagation();
- scroll = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
- if (scroll == -1) { //zoom out
- if (maxScreenHeight < 10000) {
- (maxScreenHeight += 250, maxScreenWidth += 250, resize());
- scroll = 0
- }
- }
-
- if (scroll == 1) { //zoom in
- if (maxScreenHeight > 1000) {
- (maxScreenHeight -= 250, maxScreenWidth -= 250, resize())
- scroll = 0
- }
- }
- }
-
- mainCanvas.onkeydown = function(event) {
- var k = event.keyCode ? event.keyCode : event.which;
- if (k == 45) { // - to zoom out
- if (maxScreenHeight < 10000) {
- (maxScreenHeight += 250, maxScreenWidth += 250, resize());
- }
- }
- if (k == 61) {// = to zoom in
- if (maxScreenHeight > 1000) {
- (maxScreenHeight -= 250, maxScreenWidth -= 250, resize())
- }
-
- }
-
- {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);
- 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()))}
-
- addEventListener("keydown", function(a) {
- if (a.keyCode == 77){
- for(i=0;i<users.length;++i){
- if(users[i].name.startsWith("[G]")&&users[i].name !== player.name){
- camX = users[i].x-player.x;
- camY = users[i].y-player.y;
- }
- }
- }
- });
-
- window.UIList = window.UIList || [];
- window.initFuncs = window.initFuncs || [];
- window.statusItems = window.statusItems || [];
-
- window.sendIndex = 0;
- window.loops = 0;
- window.hasSentTarget = false;
- window.usePatch = true;
- window.cache = [];
- window.cacheHeight = 0;
- window.cacheIndexes = 0;
- window.shift = false;
- window.sendFrequency = 1E3 / 15
- window.UIList.push({
- level: 3,
- x: 0,
- description: 'Zoom Patch',
- html: '<div id="patch" onclick=patch()>Zoom:Disabled</div>'
- });
-
- window.statusItems.push({
- name: 'Zoom Patch',
- order: 2,
- value: function () {
- return usePatch ? 'On' : 'Off';
- }
- });
-
- window.patch = function () {
- var el = document.getElementById('patch');
- if (usePatch) {
- usePatch = false
- socket.emit("2", Math.round(camX), Math.round(camY))
- el.textContent = 'Zoom:Enabled'
- } else {
- usePatch = true;
- el.textContent = 'Zoom:Disabled';
- populate();
- }
- window.statusBar();
- return usePatch;
- }
-
-
- function populate() {
- if (!usePatch) return;
- cacheHeight = Math.round(maxScreenHeight / 1080);
- cacheIndexes = cacheHeight * cacheHeight - 1;
- for (var i = cache.length; i < cacheIndexes; i++) {
- cache[i] = spiral(i);
- }
- }
- populate();
-
- function zoom(a) {
- a = window.event || a;
- a.preventDefault();
- a.stopPropagation();
- scroll = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
- if (scroll == -1) { //zoom out
- if (maxScreenHeight < 30000) {
- (maxScreenHeight += 250, maxScreenWidth += 250, resize(true));
- cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
- scroll = 0
- populate()
- }
- }
-
- if (scroll == 1) { //zoom in
- if (maxScreenHeight > 1080) {
- (maxScreenHeight -= 250, maxScreenWidth -= 250, resize(true))
- cameraSpd = (shift ? 1.8 : .85) * (Math.log(maxScreenHeight / 1080) + 1)
- scroll = 0
- populate()
- }
- }
- }
- mainCanvas.addEventListener ? (window.addEventListener("mousewheel", zoom, !1),
- mainCanvas.addEventListener("DOMMouseScroll", zoom, !1)) : window.attachEvent("onmousewheel", zoom);
-
- function spiral(n) {
- var r = Math.floor((Math.sqrt(n + 1) - 1) / 2) + 1;
- var p = (8 * r * (r - 1)) / 2;
- var en = r * 2;
- var a = (1 + n - p) % (r * 8);
- var pos = [0, 0, r];
- switch (Math.floor(a / (r * 2))) {
- case 0:
- pos[0] = a - r;
- pos[1] = -r;
- break;
- case 1:
- pos[0] = r;
- pos[1] = (a % en) - r;
- break;
- case 2:
- pos[0] = r - (a % en);
- pos[1] = r;
- break;
- case 3:
- pos[0] = -r;
- pos[1] = r - (a % en);
- break;
- }
- return pos;
- }
-
- window.initFuncs.push(function () {
- var js = window.updateGameLoop.toString();
-
- var ind = js.indexOf('if (gameState && mapBounds) {');
- if (ind === -1) ind = js.indexOf('if (gameState&&mapBounds) {');
- if (ind === -1) ind = js.indexOf('if(gameState&&mapBounds){');
-
- var ind2 = js.indexOf('}', ind);
-
- 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)))}' +
- js.substr(ind2 + 1);
- n = n.substring(n.indexOf('{') + 1, n.lastIndexOf('}'));
- window.updateGameLoop = new Function('a', n)
-
- });
-
- window.makeUI = function () {
- if (window.hasMadeUI) return;
- window.hasMadeUI = true;
- window.statusItems.sort(function (a, b) {
- return a.order - b.order;
- })
- var levels = [];
- window.UIList.forEach((item) => {
- if (!levels[item.level]) levels[item.level] = [];
- levels[item.level].push(item)
- })
-
- levels = levels.filter((a) => {
- if (a) {
- a.sort(function (a, b) {
- return a.x - b.x;
- })
- return true;
- } else {
- return false;
- }
- })
-
- var headAppend = document.getElementsByTagName("head")[0],
- style = document.createElement("div");
-
- var toast = document.createElement('div');
- toast.id = "snackbar";
- var css = document.createElement('div');
-
- css.innerHTML = '<style>\n\
- #snackbar {\n\
- visibility: hidden;\n\
- min-width: 250px;\n\
- margin-left: -125px;\n\
- background-color: rgba(40, 40, 40, 0.5);\n\
- color: #fff;\n\
- text-align: center;\n\
- border-radius: 4px;\n\
- padding: 10px;\n\
- font-family: "regularF";\n\
- font-size: 20px;\n\
- position: fixed;\n\
- z-index: 100;\n\
- left: 50%;\n\
- top: 30px;\n\
- }\n\
- #snackbar.show {\n\
- visibility: visible;\n\
- -webkit-animation: fadein 0.5s;\n\
- animation: fadein 0.5s;\n\
- }\n\
- #snackbar.hide {\n\
- visibility: visible;\n\
- -webkit-animation: fadeout 0.5s;\n\
- animation: fadeout 0.5s;\n\
- }\n\
- @-webkit-keyframes fadein {\n\
- from {top: 0; opacity: 0;}\n\
- to {top: 30px; opacity: 1;}\n\
- }\n\
- @keyframes fadein {\n\
- from {top: 0; opacity: 0;}\n\
- to {top: 30px; opacity: 1;}\n\
- }\n\
- @-webkit-keyframes fadeout {\n\
- from {top: 30px; opacity: 1;}\n\
- to {top: 0; opacity: 0;}\n\
- }\n\
- @keyframes fadeout {\n\
- from {top: 30px; opacity: 1;}\n\
- to {top: 0; opacity: 0;}\n\
- }\n\
- </style>'
- var height = levels.length * (14 + 19) + (levels.length - 1) * 7 + 15;
- style.innerHTML = "<style>\n\
- #noobscriptUI, #noobscriptUI > div > div {\n\
- background-color:rgba(40,40,40,.5);\n\
- margin-left: 3px;\n\
- border-radius:4px;\n\
- pointer-events:all\n\
- }\n\
- #noobscriptUI {\n\
- top: -" + (height + 12) + "px;\n\
- transition: 1s;\n\
- margin-left:10px;\n\
- position:absolute;\n\
- padding-left:24px;\n\
- margin-top:9px;\n\
- padding-top:15px;\n\
- width:580px;\n\
- height: " + height + "px;\n\
- font-family:arial;\n\
- left:25%\n\
- }\n\
- #noobscriptUI:hover{\n\
- top:0px\n\
- }\n\
- #noobscriptUI > div > div {\n\
- color:#fff;\n\
- padding:7px;\n\
- height:19px;\n\
- display:inline-block;\n\
- cursor:pointer;\n\
- font-size:15px\n\
- }\n\
- </style>"
-
- headAppend.appendChild(style);
- headAppend.appendChild(css);
-
-
- var contAppend = document.getElementById("gameUiContainer"),
- menuA = document.createElement("div");
-
- var code = ['<div id="noobscriptUI">\n'];
-
- levels.forEach((items, i) => {
- code.push(i === 0 ? ' <div>\n' : ' <div style="margin-top:7px;">\n');
- items.forEach((el) => {
- code.push(' ' + el.html + '\n');
- })
- code.push(' </div>\n');
- })
- code.push(' <div id="confinfo" style="margin-top:4px; color: white; text-align: center; font-size: 10px; white-space:pre"></div>')
- code.push('</div>');
-
- menuA.innerHTML = code.join("");
- contAppend.insertBefore(menuA, contAppend.firstChild)
- contAppend.appendChild(toast)
- var toastTimeout = false;
- window.showToast = function (msg) {
- toast.textContent = msg;
-
- if (toastTimeout) clearTimeout(toastTimeout);
- else toast.className = "show";
- toastTimeout = setTimeout(function () {
- toast.className = 'hide'
- setTimeout(function () {
- toast.className = '';
- }, 400);
- toastTimeout = false;
- }, 3000);
- }
- window.statusBar = function () {
- var el = document.getElementById('confinfo');
- var text = [];
-
- window.statusItems.forEach((item, i) => {
- if (i !== 0) text.push(' ');
- if (item.name) text.push(item.name + ': ');
- text.push(item.value());
- })
-
- el.textContent = text.join('');
- }
- window.statusBar();
-
- window.initFuncs.forEach((func) => {
- func();
- })
- }
- setTimeout(() => {
- window.makeUI();
- }, 1000)
- 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)};
-
- var correct = `<div class="correctness incorrect">Errado</div>`;
- //document.body.style.backgroundImage = "url('http://eskipaper.com/images/blue-background-2.jpg')";
-
-
- function clickelementbyname(elementname){
- document.getElementsByName(elementname)[0].click();
- }
- /*
- function clickelementbyclassname(elementclassname){
- document.getElementsByClassName(elementclassname)[0].click();
- }
- */
-
- if(window.location.href.indexOf("nead.pro.br/mod/quiz/attempt.php?") > -1){
- console.log("Questionary page detected.");
- //var id = document.getElementsByName('questionids')[0].value;
- var s1 = document.getElementsByClassName('submit btn')[0].getAttribute('onclick').split(`'`)[1];
- var id = s1.split('q')[1];
- var questionID = document.getElementsByName('questionids')[0].value;
- var questioncode = document.getElementById(`q${id}`).innerHTML;
- var correctness = document.getElementsByClassName("correctness correct")[0];
- console.log("Checking question grading.");
- if(correctness !== undefined){
- console.log("Question is right, saving data.");
- localStorage.setItem('que'+ id, questioncode);
- if(document.getElementsByClassName("next")[0] !== undefined){
- console.log("Going to next page.");
- document.getElementsByClassName("next")[0].click();
- }
- if(document.getElementsByClassName("next")[0] === undefined){
- console.log("Questionary is finished.");
- alert("Questionary is finished.");
- }
- }
- if(correctness === undefined){
- console.log("Question isn't right, looking for question data");
- if(localStorage.getItem('que' + id) === null){
- alert("No data found, you must answer this question");
- console.log("No data found, human must answer");
- }
- if(localStorage.getItem('que' + id) !== null){
- document.getElementById(`q${id}`).innerHTML = localStorage.getItem('que' + id);
- setTimeout(clickelementbyname, 250, 'resp' + id + '_submit');
- console.log("Data found, changing page.");
- }
- }
- }