Ahab / chat comp

// ==UserScript==
// @name chat comp
// @description basic chat giveaways
// @namespace torn.com
// @include *torn.com/*
// @author Ahab [1735214]
// @version 0.07
// @updateURL https://openuserjs.org/meta/Ahab/chat_comp.meta.js
// @require https://gist.githubusercontent.com/banksean/300494/raw/ecfd3ee68aeebc8894bf825854218df1d8369c72/mersenne-twister.js
// @license MIT
// ==/UserScript==

var startWord = "";
var drawWord = "";
var channel = ""; //Global, Trade, Faction:id
var banned = []; //ID
var draw = 0;
var secret = $('script[src*="chats.js"]').attr('secret');
var uid = $('script[src*="chats.js"]').attr("uid");
let socket = new WebSocket("wss://ws-chat.torn.com/chat/ws?uid="+uid+"&secret="+secret);
var joins = {};
var compstatus = 0;
var m = new MersenneTwister();
var randomNumber = m.random();

socket.onmessage = function(event) {
      if(typeof event.data === 'string'){
          var jsonObject = JSON.parse(event.data);
          if(jsonObject['data'][0]['roomId'] === channel && jsonObject['data'][0].hasOwnProperty("messageText")){
              var message = jsonObject['data'][0]['messageText'];
              var splt = message.split(" ");
              if(jsonObject['data'][0]['roomId'] === channel && jsonObject['data'][0]['senderId'] == uid && splt[0] == startWord && compstatus === 0){
                  draw = parseInt(splt[1]);
                  joins = {};
                  alert("Giveaway start");
                  compstatus = 1;
              }
              else if(jsonObject['data'][0]['roomId'] === channel && jsonObject['data'][0]['senderId'] != uid && compstatus === 1){
                  joins[jsonObject['data'][0]['senderId']] = jsonObject['data'][0]['senderId'];
                  for(var i = 0; i < banned.length; i++){
                      if(banned[i]===parseInt(jsonObject['data'][0]['senderId'])){
                          delete joins[banned[i]];
                      }
                  }
              }
              else if(jsonObject['data'][0]['roomId'] === channel && jsonObject['data'][0]['senderId'] == uid && splt[0] == drawWord && compstatus === 1 || jsonObject['data'][0]['roomId'] === channel && jsonObject['data'][0]['senderId'] == uid && splt[0] == drawWord && compstatus === 2){
                  compstatus = 2;
                  var winners = [];
                  for(var g = 0; g < draw; g++){
                    var keys = Object.keys(joins);
                    var winner = keys[Math.floor(randomNumber * keys.length)];
                    if(winner !== undefined){
                        winners.push(winner);
                        delete joins[winner];
                    }
                  }
                  alert('Giveaway Winner = '+winners);
                  compstatus = 0;
              }
          }
      }
};