Neon's Heav mod

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

当前为 2023-09-25 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴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      0.3
// @description  A Mod for heav.io. type /help for help.
// @author       iNeonz
// @match        https://heav.io/game.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:":"🤓"
}

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'
}
const textures = [];
const petTextures = [];
const pets = [
    'Kitty',
    'chat-gpt',
    'chaz',
    'chad',
    'sus',
    'egg',
    'f',
    'cube',
    'rock',
    'isaac',
    'ghost'
]
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",
    "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.'
}

const admin = [
 'iNeonz'
]

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());
}

function runCMD(command){
    if (command == '/help'){
        display(`* HELP COMMAND ----------|`)
        for (let i in cmds){
            display(`* /${i} | ${cmds[i]}`)
        }
        return ' '
    }
    if (command == '/qp'){
        if (myid == hostId){
        quickplay = !quickplay;
        display(`qp is now ${quickplay}`);
        qpdelay = 1;
        }else{
        display(`You are not the host! `)
        }
        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 '';
    }
}

function globalCmds(plrID,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[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")){
     let pl = findUser(plrID);
     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] = {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 lerp(a, b, x) {
    return a + x * (b - a);
}


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+" has died at X: "+Math.floor(c[0])+" Y: "+Math.floor(c[1]));
                     }
                    }
                    p.pet.destroy();
                    p.pet = null;
                    delete alive[i];
                }
            }else{
                p.x = alive[i].obj.x;
                p.y = alive[i].obj.y;
                let selPet = 0;
                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 = alive[i].obj.width/3;
                    p.pet.height = alive[i].obj.height/3;
                    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 = alive[i].obj.width/3;
                  p.pet.height = alive[i].obj.height/3;
                 }
                    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));
                }
            }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(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))
                    }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;
                    users = [];
                    quickplay = false;
                }
                originalClose.call(this,...args);
            }
            this.onmessage2 = this.onmessage;
            this.onmessage = function(event){
                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);

for (let c of inputs){
   if (c.parentElement.classList.contains('inGameChat') || c.parentElement.classList.contains('chatBox')){
   console.log(c);
   c.addEventListener('keydown',(event) => {
   if (event.keyCode == 13){
       let newMsg = runCMD(c.value);
       if (newMsg) {
           if (newMsg.length < 2) {c.value = '';}else{c.value = newMsg;}
       }
   }
  });
   }
}

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+'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;
     console.log(i.textContent);
     let matches = i.textContent.match(https);
     if (matches){
      console.log(matches);
     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)}</color></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 what 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();
        },10000);
       for (let i of chats){
        if (i.parentElement.classList.contains('chatBox')){
            i.appendChild(div);
            }else{
            i.appendChild(clone);
            }
       }
    }
}