Neon's Heav mod

A Mod for heav.io & hitbox.io. type /help for help.

当前为 2023-11-01 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Neon's Heav mod
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  A Mod for heav.io & hitbox.io. type /help for help.
// @author       iNeonz
// @match        https://heav.io/game.html
// @match        https://hitbox.io/game.html
// @match        https://heav.io/game2.html
// @match        https://hitbox.io/game2.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=heav.io
// @grant        none
// @run-at       document-idle
// ==/UserScript==

const emojis = {
    ":skull:":"💀",":omaga:":"😱",":smile:": "😃",":sob:":"😭",":darock:":"🤨",":flushed:":"😳",":cat:":"🐱",":globe:":"🌍",":ball:":"⚽",":balloon:":"🎈",":fest:":"🎉",":umbrella:":"☔",":nerd:":"🤓"
}

let bot = false;
let selPet = -1;
let selAcc = -1;

const letters = "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".split(" ");
const fonts = {
    bold: "𝐚 𝐛 𝐜 𝐝 𝐞 𝐟 𝐠 𝐡 𝐢 𝐣 𝐤 𝐥 𝐦 𝐧 𝐨 𝐩 𝐪 𝐫 𝐬 𝐭 𝐮 𝐯 𝐰 𝐱 𝐲 𝐳 𝟏 𝟐 𝟑 𝟒 𝟓 𝟔 𝟕 𝟖 𝟗 𝐀 𝐁 𝐂 𝐃 𝐄 𝐅 𝐆 𝐇 𝐈 𝐉 𝐊 𝐋 𝐌 𝐍 𝐎 𝐏 𝐐 𝐑 𝐒 𝐓 𝐔 𝐕 𝐖 𝐗 𝐘 𝐙".split(" "),
    italic: "𝘢 𝘣 𝘤 𝘥 𝘦 𝘧 𝘨 𝘩 𝘪 𝘫 𝘬 𝘭 𝘮 𝘯 𝘰 𝘱 𝘲 𝘳 𝘴 𝘵 𝘶 𝘷 𝘸 𝘹 𝘺 𝘻 1 2 3 4 5 6 7 8 9 𝘈 𝘉 𝘊 𝘋 𝘌 𝘍 𝘎 𝘏 𝘐 𝘑 𝘒 𝘓 𝘔 𝘕 𝘖 𝘗 𝘘 𝘙 𝘚 𝘛 𝘜 𝘝 𝘞 𝘟 𝘠 𝘡".split(" "),
}

const accessories = [
    'birb',
    'egg',
    'Fedora',
    'helmet',
    'hammer',
    'cta',
    'egg2',
    'gentleman',
    'headphone',
    'sus',
    'nerd',
    'bunny',
    'cape',
    'cheese',
    'new',
    'spicebox',
    'guns',
    'crown',
    'noob',
    'slimey',
    'potato',
    'niko',
    'default',
    'monke',
    'gaming',
    'isaac',
    'horn',
    'wings',
    'glasses',
    'chair'
];
const acessoryLink = {
    'birb': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846288388079806/birb.png',
    'egg': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846288652325016/egg.png',
    'noob': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846290015473786/noob.png',
    'nerd': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133847987995557918/nerd.png',
    'crown': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133847987521605662/crown.png',
    'cheese': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133847987232190504/cheese.png',
    'bunny': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846393891598356/bunny.png',
    'default': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133847987764867092/default.png',
    'Fedora': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846288857829537/Fedora.png',
    'cta': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133848562761994352/cta.png',
    'gentleman': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133848562992693449/gentleman.png',
    'helmet': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846289080139806/helmet.png',
    'monke': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846289310830612/monke.png',
    'new': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846289533112360/new.png',
    'niko': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846289776394290/niko.png',
    'hammer': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846508647755886/hammer.png',
    'guns': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846508396089364/guns.png',
    'sus': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846395732885635/sus.png',
    'potato': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846394944356443/potato.png',
    'slimey': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846395217002587/slimey.png',
    'spicebox': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846395460268042/spicebox.png',
    'headphone': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846394705293383/headphone.png',
    'egg2': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846394453639189/egg2.png',
    'cape': 'https://cdn.discordapp.com/attachments/1128508277827846206/1133846394143244318/cape.png',
    'gaming':'https://cdn.discordapp.com/attachments/1128508277827846206/1137513131774591016/gamer.png',
    'isaac':'https://cdn.discordapp.com/attachments/1128508277827846206/1137513132420513903/isaac.png',
    'horn':'https://cdn.discordapp.com/attachments/1128508277827846206/1137513132206587974/horns.png',
    'glasses':'https://cdn.discordapp.com/attachments/1128508277827846206/1137513133028671538/sunglasses.png',
    'chair':'https://cdn.discordapp.com/attachments/1128508277827846206/1137513132009463879/gaming.png',
    'wings':'https://cdn.discordapp.com/attachments/1128508277827846206/1137513133276151899/wings.png'
}
let zoom = 1;
const textures = [];
const petTextures = [];
const pets = [
    'Kitty',
    'chat-gpt',
    'chaz',
    'chad',
    'sus',
    'egg',
    'f',
    'cube',
    'rock',
    'isaac',
    'ghost'
]
let settings = {};

function newkeydiv(){
 let div = document.createElement('div');
 div.style="width:60px;font-size:40px;height:60px;border-radius:15px;background-color:rgba(0,255,0,0.5);position:absolute;left=30px;pointer-events:none;"
 return div;
}
let keyDivs = {
    Left:newkeydiv(),
    Right:newkeydiv(),
    Up:newkeydiv(),
    Down:newkeydiv(),
    "Force Push": newkeydiv(),
     Rocket: newkeydiv(),
    Bat: newkeydiv(),
    Grab: newkeydiv()
}
let inps = {
 Left: false,
 Right: false,
 Down: false,
 Up: false,
 "Force Push": false,
 Rocket: false,
 Bat: false,
 Grab: false
}

let arrows = {
 ARROWLEFT: 37,
 ARROWRIGHT: 39,
 ARROWUP: 38,
 ARROWDOWN: 40
}
function compareKey(key,table){
   for (let i in table){
      for (let x of table[i]) {
       if (key == (arrows[x]) || key == x.charCodeAt(0)) {
        return i;
       }
      }
   }
}

function getKeys(){
    let table = document.getElementsByClassName('controlsTable');
    if (!table[0] || !table[0].children[0]){
        for (let i of document.getElementsByClassName('item')) {
         if (i.textContent == 'Change Controls'){
          i.click();
          break;
         }
        }
        table = document.getElementsByClassName('controlsTable')[0];
        console.log('hi');
         for (let i of document.getElementsByClassName('leftButton')) {
         if (i.textContent == 'CANCEL'){
          i.click();
          break;
         }
        }
    }else{
        table = table[0];
    }
    let config = {};
    for (let i in table.children[0].children) {
        if (i > 0) {
        let t = table.children[0].children[i].children;
        let name = t[0].textContent;
        config[name] = [t[1].textContent,t[2].textContent,t[3].textContent];
        }
    }
    return config;
}
keyDivs.Left.textContent = '⬅';
keyDivs.Right.textContent = '➡';
keyDivs.Up.textContent = '⬆';
keyDivs.Down.textContent = '⬇';
keyDivs.Grab.textContent = '🧤';
keyDivs.Bat.textContent = '🏏';
keyDivs.Rocket.textContent = '🔫';
keyDivs['Force Push'].textContent = '✨';
keyDivs.Left.style.top = '70px';
keyDivs.Right.style.top = '70px';
keyDivs.Right.style.left = '132px';
keyDivs.Down.style.top = '70px';
keyDivs.Down.style.left = '70px';
keyDivs.Up.style.left = '70px';
keyDivs.Bat.style.top = '130px';
keyDivs.Bat.style.left = '70px';
keyDivs.Rocket.style.top = '130px';
keyDivs.Rocket.style.left = '132px';
keyDivs.Grab.style.top = '130px';
keyDivs['Force Push'].style.top = '192px';
keyDivs['Force Push'].style.left = '70px';
document.body.appendChild(keyDivs.Left);
document.body.appendChild(keyDivs.Down);
document.body.appendChild(keyDivs.Right);
document.body.appendChild(keyDivs.Up);
document.body.appendChild(keyDivs.Bat);
document.body.appendChild(keyDivs.Rocket);
document.body.appendChild(keyDivs.Grab);
document.body.appendChild(keyDivs['Force Push']);
const petSkins = {
    'Kitty':'https://cdn.discordapp.com/attachments/1128508277827846206/1138568531307409528/catpet.png',
    'f':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666785386381362/F.png',
    'egg':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666785025662976/egg2.png',
    'rock':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666784706899998/darock.jpg',
    'cube':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666784442663014/cube.png',
    'chaz':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666784174219304/chaz.png',
    'chad':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666783909982329/chad.jpg',
    'sus':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666786418171925/the_sussy_baka.jpg',
    'isaac':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666786099408967/isaac.png',
    'ghost':'https://cdn.discordapp.com/attachments/1128508277827846206/1139666785763868762/ghost.png',
    'chat-gpt':'https://cdn.discordapp.com/attachments/1128508277827846206/1139667562704162876/gpt.png'
}

for (let acessory of accessories){
    let texture = window.PIXI.Texture.from(acessoryLink[acessory]);
    texture.baseTexture.scaleMode = window.PIXI.SCALE_MODES.NEAREST;
    textures.push(texture);
}

for (let pet of pets){
    let texture = window.PIXI.Texture.from(petSkins[pet]);
    texture.baseTexture.scaleMode = window.PIXI.SCALE_MODES.NEAREST;
    petTextures.push(texture);
}

let myid = -1;
let quickplay = false;
let qpdelay = 0;
let hostId = -1;

let users = [];
let pollActive = false;
let pollTimer = 0;
let rektbot = false;
let pollOptions = [];
let pollVotes = {};
let modeConfig = {};
let modes = [
    {
        name:"Normal"
    },
    {
        name:"Tag",
        tick: function(dt){
            if (!modeConfig.isTAG){
                modeConfig = {
                    isTAG: true,
                    timer: 10,
                    player: 0
                }
            }
            for (let p of users){

            }
        },
        death: function(plr){

        }
    }
]
let currentMode = 0;

let abc = 'abcdefghijklmnopqrstuvwxyz';

const cmds = {
    "help":"The command list you see right now.",
    "qp":"Toggles qp",
    'encode':"Encodes the current game settings in a small text so you can share with others.",
    'decode':"Decodes the game settings inside a small text so you can play with them",
    "pets":"Pet list",
    "accs":"Hats list",
    'echo <USER>':'Sends the same message that the specified user has sent, or stop sending for the specified user.',
    'clearecho':'Clears the echolist',
    "poll [A,B,C,...]":"Creates a poll which lasts 30 seconds.",
    "stopPoll":"Ends the current active poll.",
    "rektbot":"toggles rekbot",
    'support':'Credits for the script.',
    'desync':'SANDBOX ONLY: for testing purposes, desync can be enabled ingame, desync will stop recieving and send any packet which means FPS will increase significantly high, you can only end the game after you toggle it again.',
    'ALT +':"Zooms in",
    'ALT -':"Zooms out",
    'ALT S':"Instantly start the game"
}

const sbxs = {
    "addbot":"adds a bot"
}

let echoList = [];

const admin = [
    'iNeonz'
]

let desyncEnabled = false;

function send(txt){
    if (WSS){
        WSS.send(`42[1,[28,"${txt}"]]`)
    }
}

function ask(question){
    let response = fetch('https://monke-bot.damcorruption.repl.co/chatbot/'+encodeURIComponent(question.replaceAll('monke','')))
    return response.then(r => r.json());
}

window.setPet = (pet) => {
    selPet = pet;
    if (pets[pet]){
        display("* selected pet: "+pets[pet]);
    }else{
        display("* Removed pet");
    }
    let pl = findUser(myid);
    if (pl){
        if (pl.pet){
            pl.pet.destroy();
            pl.pet = null;
        }
    }
}

window.setHat = (hat) => {
    selAcc= hat;
    if (accessories[hat]){
        display("* selected hat: "+accessories[hat]);
    }else{
        display("* Removed hat");
    }
    let pl = findUser(myid);
    if (pl){
        if (pl.acc){
            pl.acc.destroy();
            pl.acc = null;
        }
    }
}


function runCMD(command){
    command = command.replaceAll("\\*","[CODE[:ASTERK:]]");
    command = command.replaceAll("\\_","[CODE[:UNLINE:]]");
    command = command.replaceAll("\\~","[CODE[:DAS:]]");
    command = command.replaceAll("\\|","[CODE[:TE:]]");
    command = command.replaceAll("\\:glitch:","[CODE[:GLITCHY:]]");
    if (!command.match("https://") && !command.match("www.") && !command.match("http://")){
        var bold = /\*\*(.*?)\*\*/gm;
        let match;
        while ((match = bold.exec(command)) != null) {
            let t = '';
            for (let i = 0; i < match[0].length; i++){
                let l = match[0][i];
                let index = letters.indexOf(l);
                if (index != -1){
                    let n = fonts.bold[index] || l;
                    l = n;
                }
                t += l;
            }
            command =command.replace(match[0],t.slice(2,-2))
        }
        var strike = /\~\~(.*?)\~\~/gm;
        while ((match = strike.exec(command)) != null) {
            let t = '';
            for (let i = 0; i < match[0].length; i++){
                if (i > 1 && i < match[0].length-2){
                    t += "̶"+match[0][i];
                }
            }
            command = command.replace(match[0],t+"̶")
        }
        var underline = /\_\_(.*?)\_\_/gm;
        while ((match = underline.exec(command)) != null) {
            let t = '';
            for (let i = 0; i < match[0].length; i++){
                if (i > 1 && i < match[0].length-2){
                    t += match[0][i]+"͟";
                }
            }
            command = command.replace(match[0],"͟"+t)
        }
        var glitches = ["̵̨̤̥̝͉̼̘̜̣͙͍͕̙̜̄̀͐͗̊","̸̡̜̘̜̺̳̞̘̹̻́̈͌͝","̴̮͚͛̌̄","̴̧̗͕͎͎͎̗̮͚̱̜̹̜̦̦͚̙̫͉̬͙̯̣̉̈́̔̿̐̎͝","̸̨̮̲̬̗͉̼͕͚̦͚̺̗̲̦̰̹̣̭͓̮̈́̄̊̑̓͑͌","̵̤̥̄̀͐͗̊","̸̮̲̬̗͉̼͕͚̦͚̺̈́̄̊̑̓͑͌","̸̡̜̘́̈͌͝","̵̤̥̝͉̼̘̄̀͐͗̊"];
        var glitch = /\<g (.*?) g\>/gm;
        while ((match = glitch.exec(command)) != null) {
            let t = '';
            for (let i = 0; i < match[0].length; i++){
                if (i > 2 && i < match[0].length-3){
                    t += glitches[Math.floor(Math.random()*glitches.length)]+match[0][i];
                }
            }
            command = command.replace(match[0],t);
        }
        var italic = /\*(.*?)\*/gm;
        while ((match = italic.exec(command)) != null) {
            let t = '';
            for (let i = 0; i < match[0].length; i++){
                if (i > 0 && i < match[0].length-1){
                    let l = match[0][i];
                    let index = letters.indexOf(l);
                    if (index != -1){
                        let n = fonts.italic[index] || l;
                        l = n;
                    }
                    t += l;
                }
            }
            command = command.replace(match[0],t)
        }
        var forbidden = /\|\|(.*?)\|\|/gm;
        while ((match = forbidden.exec(command)) != null) {
            command = command.replace(match[0],"█".repeat((match[0].replaceAll("||","")).length));
        }
    }
    command = command.replaceAll("[CODE[:ASTERK:]]","*");
    command = command.replaceAll("[CODE[:UNLINE:]]","_");
    command = command.replaceAll("[CODE[:DAS:]]","~");
    command = command.replaceAll("[CODE[:TE:]]","|");
    command = command.replaceAll("[CODE[:GLITCHY:]]",":glitch:");
     if (command.startsWith('/eval ')){
         let code = command.split('/eval ')[1];
         eval(code);
         return ' ';
     }
    if (command == '/help'){
        display(`* NHM HELP COMMAND ----------|`)
        for (let i in cmds){
            display(`* ${i} | ${cmds[i]}`)
        }
        display(`* DEFAULT HELP COMMAND ----------|`)
        return '/help'
    }
    if (command == '/encode'){
        let t = '';
        for (let i in settings){
         t += i+":"+settings[i]+"|"
        }
        display(`* Your smol settings: ${t}`);
        return '/help'
    }
     if (command.startsWith('/bot')){
         bot = !bot;
         display('bot is now ' + bot);
     }
    if (command.startsWith('/decode ')){
        let setts = command.split('/decode ')[1];
        if (setts){
            let sett = {};
            let sects = setts.split('|');
            for (let o of sects){
                let pr = o.split(':');
                if (pr[1]){
                let v = JSON.parse(`[${pr[1]}]`)[0];
                sett[pr[0]] = v;
                }
            }
            WSS.onmessage({data: `42[63,${JSON.stringify(sett)}]`})
            WSS.send(`42[1,[62,${JSON.stringify(sett)}]]`)
            display("Successfully Changed the settings!");
        }else{
            display("* Please insert a valid smol settings.")
        }
        return ' '
    }
    if (command == '/pets'){
        display(`* None <a href='javascript:window.setPet(-1);'>[SELECT]</a>`,null,null,false);
        for (let i in pets){
            display(`* ${pets[i]} <a href='javascript:window.setPet(${i});'>[SELECT]</a>`,null,null,false);
        }
        return ' ';
    }
    if (command == '/accs'){
        display(`* None <a href='javascript:window.setHat(-1);'>[SELECT]</a>`,null,null,false);
        for (let i in accessories){
            display(`* ${accessories[i]} <a href='javascript:window.setHat(${i});'>[SELECT]</a>`,null,null,false);
        }
        return ' ';
    }
    if (command.startsWith('/echo')){
        let player = command.split('/echo ')[1];
        let pl = findUser(player);
        if (pl && pl.id != myid){
            if (echoList.includes(pl.name)){
                echoList.splice(echoList.indexOf(pl.name),1);
                display("* Stopped echo'in "+pl.name,'#03cafc','#03fc17')
            }else{
                display("* Now echo'in "+pl.name,'#fcad03','#03fc17')
                echoList.push(pl.name);
            }
        }else if (pl){
            display("* You can't echo yourself!",'#fc0303','#03fc17');
        }else{
            display("* You can't echo no one!",'#fc0303','#03fc17');
        }
        return ' '
    }
    if (command == '/clearecho'){
        if (echoList.length > 0){
            display("* Echo list cleared",'#fcad03','#03fc17');
            echoList = [];
        }else{
            display("* Echo list is empty.",'#fcad03','#03fc17');
        }
        return ' '
    }
    if (command == '/qp'){
        if (document.getElementsByClassName('mapsContainer')[0].getElementsByClassName('element').length > 0){
        if (myid == hostId){
            quickplay = !quickplay;
            display(`* qp is now ${quickplay}`);
            qpdelay = 1;
        }else{
            display(`* You are not the host! `)
        }
        }else{
         display(`* Please, open the map section first.`);
        }
        return ' '
    }
    if (command == '/support'){
        display(`Thanks iNeonz (tag: ineonz) for creating this amazing script.`);
        display(`Thanks Damian for being himself`);
        display(`Thanks killmah for`);
    }
    if (command == '/rektbot'){
        rektbot = !rektbot;
        display(`rektbot is now ${rektbot}`);
        return ' '
    }
    if (command.startsWith('/poll')){
        let options = command.split('/poll ')[1].split(',');
        pollOptions = options;
        let ptxt = '';
        for (let i in options){
            let p = options[i];
            let letter = abc[i%abc.length];
            ptxt += `${letter}) ${p.substring(0,8)}${" ".repeat(5-p.substring(0,4).length)}`
        }
        display(`A NEW POLL HAS STARTED, AND WILL END IN 30 SECONDS`);
        pollActive = true;
        pollTimer = 30;
        return `Type the letter to vote: ${ptxt}`
    }
    if (command == '/stopPoll'){
        if (pollActive){
            pollTimer = .01;
            return 'Ending the poll.';
        }else{
            display("There is no polls active.");
        }
        return '';
    }
    // SANDBOX
    if (sandboxroom){
        if (command == '/addbot'){
            bots++
            botids.push(bots);
            console.log(Date.now());
            console.log(window.multiplayerSession);
            WSS.onmessage({data: `42[8,["Bot ${bots}",true,1,"",${bots},-1,0,{"1":6372018},false],${Date.now()}]`})
            window.multiplayerSession.SE.ve[bots]._P = window.multiplayerSession.SE.ve[0]._P;
         return ' ';
        }
        if (command == '/desync') {
            desyncEnabled = !desyncEnabled;
            display('* Desync is now '+desyncEnabled+', Turn it off before ending the game.');
            return ' ';
        }
    }
    //SANDBOX
    if (command.length >= 2){
        return command;
    }
}


function globalCmds(plrID,txt){
    if (!bot) {return;}
    let pl = findUser(plrID);
    if (!pl){ return;}
    if (echoList.includes(pl.name)){
        send(txt);
    }
    if (txt.toLowerCase().includes("monke")){
        ask(txt)
            .then(r => {
            send('Monke > '+r.response);
        })
    }
    if (txt.length == 1){
        let ntxt = txt.toLowerCase();
        if (abc.includes(ntxt)){
            let option = pollOptions[abc.indexOf(ntxt)];
            let pl = findUser(plrID);
            if (option && pl){
                pollVotes[pl.name] = abc.indexOf(ntxt);
            }
        }
    }
    if (txt.startsWith("!info")){
        send("Hi, i, iNeonz created a funni script with damian's chatbot.");
    }
    if (txt.startsWith("!help")){
        send("|!roll 1-20|!gay");
    }
    if (txt.startsWith("!roll")){
        try {
            let num = parseInt(txt.split(' ')[1])
            send(`1d${Math.floor(Math.random()*num)}`)
        }catch(e){}
    }
    if (txt == '!track'){
        let alivey = 0;
        let p1;
        let p2;
        for (let i in alive){
            if (p1 && !p2){
                p2 = i;
            }else if (!p1){
                p1 = i;
            }
            alivey++;
        }
        console.log(alivey,p1,p2);
        if (alivey== 2 && p1 && p2){
            let pl1 = findUser(p1);
            let pl2 = findUser(p2);
            let arrows = {
                "1 0":'➡️',
                "1 1":'↘️',
                "0 1":'⬇️',
                "-1 1":'↙️',
                "-1 0":'⬅️',
                "-1 -1":'↖️',
                "0 -1":'⬆️',
                "1 -1":'↗️'
            }
            let p1c = gCoordinates(pl1.x,pl1.y);
            let p2c = gCoordinates(pl2.x,pl2.y);
            let dir = Math.atan2(p2c[1]-p1c[1],p2c[0]-p1c[0]);
            let c = [Math.cos(dir),Math.sin(dir)];
            let p3 = [c[0] > 0.4? 1 : (c[0] < -0.4? -1 : 0),c[1] > 0.4? 1 : (c[1] < -0.4? -1 : 0)];
            let t = p3[0]+' '+p3[1];
            console.log('p1',p1c,'p2',p2c,'dir',dir,'c',c,'p3',p3);
            let arr = arrows[t];
            let dist = Math.floor(Math.sqrt(((p1c[0]-p2c[0])**2)+((p1c[1]-p2c[1])**2)));
            send(`${pl2.name} is ${dist}ft away from ${pl1.name} (${arr})`);
        }else{
            send(`There must be 2 players alive, right now there is ${alivey}.`);
        }
    }
    if (txt.startsWith("!gay")){
        if (pl){
            let perc = Math.floor(Math.random()*10000)/100
            /*let txts = [
          'Sigma',
          'Hetéro',
          'Mei viado',
          'Beta',
          'Viado',
          'Boiola Mega'
          ]*/
            let txts = [
                'Sigma',
                'Straight',
                'Kinda gay',
                'Beta',
                'Gay',
                'Very Pretty Much A Gay'
            ]
            let part = Math.floor((Math.floor(perc)/100)*txts.length);
            //send(`${pl.name}, você é ${perc}% gay... Eu diria que você é... ${txts[part]}`);
            send(`${pl.name}, You are ${perc}% gay... I'd say you are... ${txts[part]}`);
        }
    }
}

const alive = {};

// Your code here...

const render = window.PIXI.Graphics.prototype.finishPoly
window.PIXI.Graphics.prototype.finishPoly = function(...args){
    render.call(this,...args)
    if (this.parent) {
        for (let i of this.parent.children) {
            if (i._text) {
                alive[i._text] = {orbj: this,obj: this.parent,frames: 8, txt: i};
                if (admin.includes(i._text)){
                    i.tint = 0xff11ff
                }
                break;
            }
        }
    }
}
/*for (let i in window.PIXI.Graphics.prototype) {
        let v = window.PIXI.Graphics.prototype[i];
        if (typeof(v) == 'function') {
            console.log(i," injected");
            let prot = window.PIXI.Graphics.prototype[i]
            window.PIXI.Graphics.prototype[i] = function(...args){
                let c = prot.call(this,...args);
                if (this.parent && this.parent.children) {
                 for (let p of this.parent.children) {
                     if (p._text) {
                      console.log(i,p._text);
                     }
                 }
                }
               if (this.children) {
                 for (let p of this.children) {
                     if (p._text) {
                      console.log(i,p._text);
                     }
                 }
                }
                return c
            }
        }
    }*/
let frames = 0;
let lc = Date.now();

function gCoordinates(x,y){
    let bg = document.getElementById('backgroundImage')
    if (bg){
        let w = bg.clientWidth;
        let h = bg.clientHeight;
        let scale = w/730;
        return [x/scale,y/scale];
    }
    return [0,0];
}

function fire(type,options,d = Gdocument){
    var event= document.createEvent("HTMLEvents");
    event.initEvent(type,true,false);
    for(var p in options){
        event[p]=options[p];
    }
    d.dispatchEvent(event);
};

function lerp(a, b, x) {
    return a + x * (b - a);
}

let laststate;

//SP.SE.ve[0].name
//SP.zE.eo[0];



window.requestAnimationFrame = new Proxy( window.requestAnimationFrame, {
    apply( target, thisArgs, args ) {
        let T = Date.now();
        let dt = (T-lc)/1000;
        lc = T;
        frames++
        if (frames % 60 == 0){

        }
        if (pollActive){
            if (pollTimer > 0){
                pollTimer -= dt;
                if (pollTimer <= 0){
                    let votes = {};
                    let mostVoted = 0;
                    let mostVotes = 0;
                    for (let i in pollVotes){
                        let option = pollOptions[pollVotes[i]];
                        if (!votes[option]){votes[option] = 0;}
                        votes[option] += 1
                        if (votes[option] > mostVotes){mostVotes = votes[option]; mostVoted = pollVotes[i];}
                    }
                    let choosen = pollOptions[mostVoted];
                    if (choosen){
                        send(`POLL ENDED: ${choosen} has won the Poll with ${mostVotes} votes! (Which is ${Math.floor((mostVotes/users.length)*10000)/100}% of this room)`);
                    }
                    pollVotes = [];
                    pollOptions = [];
                    pollActive = false;
                }
            }
        }
        //matrix.hue(frames%300);
        for (let i in alive) {
            let unalive = (!alive[i].obj || !alive[i].obj.transform || !alive[i].obj.parent || !alive[i].txt || !alive[i].txt.visible || alive[i].txt.parent != alive[i].obj || !alive[i].obj.visible || alive[i].obj.alpha <= 0);
            let p = findUser(i);
            if (p){
                if (unalive){
                    alive[i].frames--
                    if (alive[i].frames <= 0){
                        console.log(i,' has died');
                        if (document.getElementsByClassName('lobbyContainer')[0].style.display == 'none'){
                            let c = gCoordinates(p.x,p.y);
                            if (rektbot){
                                send("[NHM Rekt Bot] > "+i+" L");
                            }
                        }
                        if (p.pet){
                            p.pet.destroy();
                            p.pet = null;
                        }
                        if (p.acc){
                            p.acc.destroy();
                            p.acc = null;
                        }
                        delete alive[i];
                    }
                }else{

                        let topElement = alive[i].obj;
                        while (topElement.parent && topElement.parent) {
                            topElement = topElement.parent
                        }
                    topElement.scale.x = zoom;
                    topElement.scale.y = zoom;
                    let bg = document.getElementById('pixiContainer')?.children[0];
                    if (bg){
                        let w = parseInt(bg.style.width);
                        let h = parseInt(bg.style.height);
                        topElement.position.x = w/2-((w/2)*zoom);
                        topElement.position.y = h/2-((h/2)*zoom);
                    }
                    p.x = alive[i].obj.x;
                    p.y = alive[i].obj.y;
                    if (textures[selAcc] && p.id == myid){
                        if (!p.acc){
                            p.acc = new window.PIXI.Sprite(textures[selAcc]);
                            p.acc.cacheAsBitMap = true;
                            p.acc.anchor.x = 0.5;
                            p.acc.anchor.y = 0.5;
                            p.acc.rotation = 0;
                            p.acc.width = .01;
                            p.acc.height = .01;
                            //p.acc.y = -alive[i].obj.height;
                            p.acc.angle = 0;
                            alive[i].obj.addChild(p.acc);
                        }else{
                            if (p.acc.parent != alive[i].obj){
                                alive[i].obj.addChild(p.acc);
                                p.acc.width = .01;
                                p.acc.height = .01;
                            }
                            for (let b of alive[i].obj.children){
                                if (!b._text && b._geometry && b._geometry.batchDirty == 0){
                                    p.acc.rotation = b.rotation;
                                    p.acc.angle = b.angle;
                                    p.acc.width = b.width*1.3;
                                    p.acc.height = b.width*1.3;
                                    break;
                                }
                            }
                        }
                    }else{
                        if (p.acc){
                            p.acc.destroy();
                            p.acc = null;
                        }
                    }
                    if (petTextures[selPet] && p.id == myid){
                        if (!p.pet){
                            p.pet = new window.PIXI.Sprite(petTextures[selPet]);
                            p.pet.cacheAsBitMap = true;
                            p.pet.anchor.x = 0.5;
                            p.pet.anchor.y = 0.5;
                            p.pet.rotation = 0;
                            p.pet.angle = 0;
                            p.pet.width = .01;
                            p.pet.height = .01;
                            for (let b of alive[i].obj.children){
                                if (b.rotation || b.angle){
                                    p.pet.rotation = b.rotation;
                                    p.pet.angle = b.angle;
                                    p.pet.width = b.width/1.3;
                                    p.pet.height = b.width/1.3;
                                    break;
                                }
                            }
                            alive[i].obj.parent.addChild(p.pet);
                            p.pet.x = p.x;
                            p.pet.y = p.y;
                        }else{
                            if (p.pet.parent != alive[i].obj.parent){
                                alive[i].obj.parent.addChild(p.pet);
                                p.pet.width = .01;
                                p.pet.height = .01;
                            }
                            let angle = Math.atan2(p.pet.y-p.y,p.pet.x-p.x)
                            p.pet.x = lerp(p.pet.x,p.x+Math.cos(angle)*alive[i].obj.width/3/2,1-(0.005**dt));
                            p.pet.y = lerp(p.pet.y,p.y+Math.sin(angle)* alive[i].obj.width/3,1-(0.005**dt));
                            p.pet.scale.x = (p.pet.x > p.x? Math.abs(p.pet.scale.x)*-1 : Math.abs(p.pet.scale.x));
                            for (let b of alive[i].obj.children){
                                if (!b._text && b._geometry && b._geometry.batchDirty == 0){
                                    p.pet.rotation = b.rotation;
                                    p.pet.angle = b.angle;
                                    p.pet.width = b.width/1.3;
                                    p.pet.height = b.width/1.3;
                                    break;
                                }
                            }
                        }
                    }else{
                        if (p.pet){
                            p.pet.destroy();
                            p.pet = null;
                        }
                    }
                }
            }else{
                delete alive[i];
            }
        }
        if (quickplay){
            if (document.getElementsByClassName('lobbyContainer')[0].style.display != 'none'){
                if (qpdelay > 0){
                    qpdelay -= dt;
                }
                if (qpdelay <= 0){
                    qpdelay = 5;
                    let maps = document.getElementsByClassName('mapsContainer')[0].getElementsByClassName('element');
                    let map = maps[Math.floor(Math.random()*maps.length)];
                    map.click();
                    setTimeout(() => {
                        document.getElementsByClassName("startButton")[0].click();
                    },100);
                }
            }
        }
        Reflect.apply(...arguments);
    }
})

const originalSend = window.WebSocket.prototype.send;
const excludewss = [];
let WSS = 0;

window.sendPacket = function(packet) {
    if (WSS) {
        console.log("SENT > ",packet);
    }else{
        console.log("Could not send: No wss connected.");
    }
}
/*

   */

function findUser(id){
    for (let t in users) {
        let o = users[t];
        if (o.id == id || o.name == id){
            o.index = t;
            return o;
            break;
        }
    }
}

window.WebSocket.prototype.send = function(args) {
    if (desyncEnabled) {
        return;
    }
    if(this.url.includes("/socket.io/?EIO=3&transport=websocket&sid=")){
        if(typeof(args) == "string" && !excludewss.includes(this)){
            if (!WSS){
                WSS = this;
            }
            if (WSS == this){
                if (args.startsWith('42[1,[')) {
                    try{
                        let packet = JSON.parse(args.slice(5,-1))
                        if (packet[0] == 62){
                         settings = packet[1];
                        }
                        }catch(error){}
                }else if (args.startsWith('42[2,')) {
                    myid = 0;
                    hostId = 0;
                }
            }else{
                excludewss.push(this);
            }
            //console.log('SENT',args);
        }
        if (!this.injected){
            this.injected = true;
            const originalClose = this.onclose;
            this.onclose = (...args) => {
                if (WSS == this){
                    WSS = 0;
                    sandboxroom = false;
                    desyncEnabled = false;
                    users = [];
                    botids = [];
                    bots = 0;
                    quickplay = false;
                }
                originalClose.call(this,...args);
            }
            this.onmessage2 = this.onmessage;
            this.onmessage = function(event){
                if (desyncEnabled) {
                  return;
                }
                if(!excludewss.includes(this) && typeof(event.data) == 'string'){
                    if (event.data.startsWith('42[')){
                        let packet = JSON.parse(event.data.slice(2,event.data.length));
                        if (packet[0] == 7){
                            console.log("ID: ",packet[1][0])
                            myid = packet[1][0]
                            hostId = packet[1][1];
                            for (let i of packet[1][3]){
                                users.push({"name":i[0],"id":i[4],"lvl":i[6]});
                            }
                        }
                        if (packet[0] == 9){
                            hostId = packet[2];
                            let user = findUser(packet[1]);
                            if (user){
                                if (user.pet){
                                    user.pet.destroy();
                                    user.pet = null;
                                }
                                console.log(user.name,'left');
                                users.splice(user.index,1);
                            }
                        }
                        if (packet[0] == 45){
                            hostId = packet[1];
                            if (hostId != myid){
                                quickplay = false;
                            }
                        }
                        if (packet[0] == 29 && !packet[2].startsWith("Monke > ")){
                            globalCmds(packet[1],packet[2])
                        }
                        if (packet[0] == 8){
                            console.log("plr join")
                            users.push({"name":packet[1][0],"id":packet[1][4],"lvl":packet[1][6]});
                            setTimeout(() => {
                                WSS.send(`42[1,[28,"Hello! welcome, user "${packet[1][0]}" that entered with lvl ${packet[1][6]}"]]`)
                            },100);
                        }
                    }
                }
                this.onmessage2(event);
            }
        }
    }
    return originalSend.call(this, args);
}

let chats = document.getElementsByClassName('content');
let inputs = document.getElementsByClassName('input');
console.log(inputs.length);

let chatI = [];

for (let c of inputs){
    if (c.parentElement.classList.contains('inGameChat') || c.parentElement.classList.contains('chatBox')){
        chatI.push(c);
        c.addEventListener('keydown',(event) => {
            if (event.keyCode == 13){
                for (let emoji in emojis){
                    c.value = c.value.replaceAll(emoji,emojis[emoji]);
                }
                let newMsg = runCMD(c.value);
                if (newMsg) {
                    if (newMsg.length < 2) {c.value = '';}else{c.value = newMsg;}
                }
            }
        });
    }
}

function updateInps(){
for (let i in keyDivs) {
    let div = keyDivs[i];
    div.style.backgroundColor = inps[i]? 'rgba(255,0,0,1)' : 'rgba(0,255,0,0.5)';
}
}

window.addEventListener('keyup',(event) => {
    let plrKeys = getKeys();
    let action = compareKey(event.keyCode,plrKeys);
    if (action) {
        inps[action] = false;
        updateInps();
    }
});

window.addEventListener('keydown',(event) => {
        if (!event.repeat) {
    let plrKeys = getKeys();
    let action = compareKey(event.keyCode,plrKeys);
    if (action) {
         inps[action] = true;
         updateInps();
    }
}
   if (event.keyCode == 189 && event.altKey) {
       zoom /= 1.3;
 event.preventDefault();
   }
   if (event.keyCode == 187 && event.altKey) {
       zoom *= 1.3;
       event.preventDefault();
   }
    if (event.keyCode == 83 && event.altKey) {
      document.getElementsByClassName('editorButton')[0].click();
     for (let i of document.getElementsByClassName('item')) {
      if (i.textContent == 'Play') {
       i.click();
       break;
      }
     }
    for (let i of document.getElementsByClassName('item')) {
      if (i.textContent == 'Exit') {
       i.click();
       break;
      }
     }
    }
});

window.hescape = (s) => {
    let lookup = {'$':'&#36;','%':'&#37;','.':'&#46;','+':'&#43;','-':'&#45;','&':"&amp;",'"': "&quot;",'\'': "&apos;",'<': "&lt;",'*':'&#42;','=':'&#61;','>': "&gt;",'#':'&#35;',':':'&#58;',';':'&#59;','`':'&#96;'};
    return s.replace( /[\*=%#\-+&"'<>]/g, c => lookup[c] );
}

let itemDesc = document.createElement('div');
itemDesc.style.whiteSpace = 'pre-wrap';
itemDesc.style.position = 'absolute';
itemDesc.style.opacity = '0.7';
itemDesc.style.color = 'white';
itemDesc.style.fontWeight = '500';
itemDesc.style.width = 'fit-content';
itemDesc.style.height = 'fit-content';
itemDesc.style.textAlign = 'center';
itemDesc.style.pointerEvents = 'none';
itemDesc.style.background = 'black';
itemDesc.style.borderRadius = '10px';
itemDesc.style.left = '500px';
itemDesc.style.top = '500px';
itemDesc.style.index = 99999999999999999999;
itemDesc.textContent = 'hi';
itemDesc.style.visibility = 'hidden';
document.body.appendChild(itemDesc);

var lastMousePos = {x: 0,y: 0};

window.addEventListener("mousemove",(e) => {
    e = e || window.event;
    let pos1 = lastMousePos.x || e.clientX;
    let pos2 = lastMousePos.y || e.clientY;
    lastMousePos = {x: e.clientX,y: e.clientY};
    if (document.activeElement && document.activeElement.dataset.dragable){
        e.preventDefault();
        document.activeElement.style.top = (document.activeElement.offsetTop + (e.clientY-pos2)) + "px";
        document.activeElement.style.left = (document.activeElement.offsetLeft + (e.clientX-pos1)) + "px";
    }
});

window.setDescTXT = (text,description) => {
    if (text && text.length > 0){
        itemDesc.innerHTML = hescape(text)+"\n<font size=1>"+(hescape(description) || '')+"</font>";
        itemDesc.style.left = lastMousePos.x+'px';
        itemDesc.style.top = (lastMousePos.y+50)+'px';
        itemDesc.style.visibility = 'visible';
        itemDesc.style.zIndex = 9999999999999999999999999999999999999999999;
    }else{
        itemDesc.style.visibility = 'hidden';
    }
}


for (let i of chats){
    i.addEventListener('DOMNodeInserted',(event) => {
        let args = event.target;
        for (let i of args.children){
            if (i.textContent){
                let https = /(((https?:\/\/)|(www\.))[^\s]+)|(((http?:\/\/)|(www\.))[^\s]+)/g;
                let matches = i.textContent.match(https);
                if (matches){
                    i.style.pointerEvents = 'all';
                    for (let m of matches){
                        i.innerHTML = i.innerHTML.replace(m,`<a href='${m}' target='_blank' style='text-decoration-color: #f59342;'><font color='#f59342'>${hescape(m)}</font></a>`)
                    }
                }
            }
        }
        let oDate = new Date();
        let time = (Date.now()/1000)-(oDate.getTimezoneOffset()*60)
        let mlTime = Math.floor(((time/60)/60))%24+":"+Math.floor(time/60)%60;
        let child = args.children[1] || args.children[0];
        child.onmouseover = () => {window.setDescTXT(mlTime+" UTC"+(oDate.getTimezoneOffset() < 0? "+" : "")+(-Math.floor(oDate.getTimezoneOffset()/60)),"time at which this message was sent at.");}
        child.onmouseout = () => {window.setDescTXT('');}
    })
}


function display(text,ingamecolor,lobbycolor,sanitize){
    if (WSS){
        let div = document.createElement('div');
        div.classList.add('statusContainer');
        let span = document.createElement('span');
        span.classList.add('status');
        span.style.color = lobbycolor || "#ffffff";
        if (sanitize != false){
            span.textContent = text;
        }else{
            span.innerHTML = text;
        }
        span.style.backgroundColor = 'rgba(37, 38, 42, 0.768627451)';
        div.style.borderRadius = '7px';
        div.appendChild(span);
        let clone = div.cloneNode(true);
        clone.children[0].style.color = ingamecolor || '#ffffff';
        setTimeout(() => {
            clone.remove();
        },11500);
        for (let i of chats){
            if (i.parentElement.classList.contains('chatBox')){
                i.appendChild(div);
                i.scrollTop = Number.MAX_SAFE_INTEGER;
            }else{
                i.appendChild(clone);
            }
        }
    }
}

let b = document.getElementsByClassName('bigButton training')[0];
let helpbutton = b.cloneNode(true);
b.parentNode.appendChild(helpbutton);
helpbutton.style.display = 'block';
helpbutton.style.top = '470px';
helpbutton.style.position = 'absolute';
helpbutton.children[1].children[0].textContent = 'NHM';
helpbutton.children[1].children[1].textContent = 'Help';
helpbutton.children[1].children[3].remove();
helpbutton.children[1].children[2].remove();

let nhmHelp = document.createElement('div');
document.body.appendChild(nhmHelp);
nhmHelp.innerHTML = `<div class="updateNews" style="zoom: 0.628571;">
<div class="topBar" style="opacity: 1;">NHM Help</div>
<div class="crossButton" onclick="this.parentNode.parentNode.style.display = 'none';"></div>
<div class="dateLabel" style="opacity: 1;">Yo fellas</div>
<div class="textContent" style="opacity: 1;">
<ul>I heard you're seeking for help, HAHA I'M NOT GONNA TEACH YOU! jk jk
<li>Get started with the command list: /help</li>
With nhm, you can do some stuff. like, annoy people!!!
Disable or enable ! commads with /bot, it is disabled by default.</ul>
</div>
<div class="button leftButton disabled" style="opacity: 1;">PREVIOUS</div>
<div class="button rightButton disabled" style="opacity: 1;">NEXT</div></div>`
nhmHelp.style.display = 'none';
helpbutton.onclick = () => {
 console.log('clicc')
 nhmHelp.style.display = 'block';
}

const createbutton = document.getElementsByClassName('bottomButton left')[0];
let sandboxroom = false;
let botids = [];
let bots = 0;