Chirrox / GMChatExtended

// ==UserScript==
// @name         GMChatExtended
// @author       GM
// @namespace    com.heroesofnewerth.gm
// @description  Add a simple gui for easier copying of chat logs.
// @match     *://rap.heroesofnewerth.com/chat.php*
// @version 1.2.5
// @require  http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_openInTab
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAGytJREFUeNrkWwmUVOWV/mrp6q5eqnrfm31fG1QQRUAlEgIGMJho5sxAookkJ0YTc2ZGT040kzGTycSIHLM6J5CgWVSgUQEBZVEQZZEdmk3ole6ml6ru6tqr3nz3vqJDQwMNiSY58ziPqq76673/bt/97v3/ZzEMA/+fD8snpQCLxTKNL/3On4NHjus3/6F/h91mxzsVy7B14+sybEtiuLye4dzO/MMqgAKLoHMT59SSkhKkpCQjEAiiqKwfdr+/Xce9ursVrZVbsHXdUrz88ptIsifB4L9gMChfVyWUUcF5Vnwc87T/lYXOTAj86MCBA8d+fv58TJs2Dc60VOx4bwd2796NmpoqjL75TsQ5yMrTc7YKlnA1PjUpB3/6kwXOVCeKS0sxbMhguFyuvmfr6xd8+OHeBby2VxTBczGVse/vSgEJwR+1222PPvSVr7q//Z3vYMCAAYhFo2jztOHokcMI+P1obGpEbU0t3LmH8fyyFYARgy1YBZexH9bgScRiEVo+hDCtH6Sn9OnTB6NGjcQ98+bhXHOze/36DQu2bd8uytjK+z1FRWz5m4cAJ0PB7U899thj7icefxwut7vru6ozp7F8+e+wcmUF9u77s9GSkqz48dOLkJ4cQEqsFk6jGq+/fRq/XRvuGlNYWIiJN92I2++4E7m52QhHIgiHQmhra8P6DRvxzjvvIh6PiyIW/iVYcd0KSMT4si9+8f6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9gtJDDAQDvdstahhGr04hEK6MdKMgN9dwZ2QY5aNHG796Y5exrtowlm6pNX70/HJjxs3jDIfudvh4TpfTbtw7Y7wx9btrjV/ujhtL3z5pfPfp/zGsQiMTYyzmewn88t7IZe2tBTh4YXuH77ctBBXZMOUqGoxRN96IT5dBFzuSk4IYPXEAwh/jM1jtgSiOp9yGx740Ew/eQMil1fuVpuG+eydfMM/4NW2WvqZHZkQJQinbPN4FwrMr9xxCozsDvrqDSMcpTBwe/VgEd6am6VpEmFxk+o3D0XS8EkuPMjO0HoI7egLDSrvWAa55u/w1PzOUUMKWYwfeXTx7xjh3a4MPmdFqpMePoYbx+OdWlIOUNwv5+fna4zt54hRk51lvjowMcoiyMm2WSGdZttMqwWL8N53ajuFlcdhj7ciIn0GGcQK1VZqSr+uBiet6aEoYlShh16Y/LJsxuWBqkqUOEX8NfrL0z3t3Mln13Xzzzcoi80mlJd7CRPGjlZWoq6sjuwvC3xnQRojL5VYyNaD/AAwbMUz3J52pqta01tTUpDtVGxrOop0KrKmpxpgBAQwpiSMFtag6Xe1duqrxk31k5sIjy2V9tDDH/lTlmYj7gstqHy4nJ1sVMJ5ZYuSI4VRKttJVqfutiZ6jw5HMGiNZkVyaL9KdPnXqFN58c70+GHXsxDGEAiGt5qSvJ69hYk5JnrS6o1trm4y/zUNTF2+slvohcbqdKanKGKVstcrOicS+cll06dOnDCWlpSgsyIfblamrNtL6aiZpqWYVeoweIq052ZMsDFC2R1iMeGK7XtTcWGG6+9/HY3M9KGKuqQjLWLUqawRZY5ACSZfREu2seLx7W8tiLuIl9g2a+41C4RDzeVD5fALg/uoPTn5ij85KO0qarCKcjUWKkBXjoi2uupTG+cgSWqJ5+bE/Ovs3e3g6cV58bLng9R/74el/lOP/BBgA1Bm0A5zs89YAAAAASUVORK5CYII=
// @updateURL https://openuserjs.org/meta/Chirrox/GMChatExtended.meta.js
// @downloadURL https://openuserjs.org/install/Chirrox/GMChatExtended.user.js
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // For preloading
    var hammer1F = new Image();
    hammer1F.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerOne1.png";
    var hammer2F = new Image();
    hammer2F.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerOne2.png";
    var hammer3F = new Image();
    hammer3F.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerOne3.png";

    var hammer1A = new Image();
    hammer1A.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerTwo1.png";
    var hammer2A = new Image();
    hammer2A.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerTwo2.png";
    var hammer3A = new Image();
    hammer3A.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerTwo3.png";

    var hammer1I = new Image();
    hammer1I.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerThree1.png";
    var hammer2I = new Image();
    hammer2I.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerThree2.png";
    var hammer3I = new Image();
    hammer3I.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerThree3.png";

    var hammer1C = new Image();
    hammer1C.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerFour1.png";
    var hammer2C = new Image();
    hammer2C.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerFour2.png";
    var hammer3C = new Image();
    hammer3C.src = "https://hongm.fra1.digitaloceanspaces.com/Hammers/HammerFour3.png";


    var acceptVerdict = new Image();
    acceptVerdict.src = "";



    var GUILTY_FEEDING = "Bad Nickname: <suspect>";
    var GUILTY_AFK = "<suspect> is verbally abusive and additionally calls out allied positions.";
    var GUILTY_ITEMABUSE = "Please refrain from being verbally abusive.";
    var GUILTY_CHATABUSE = "<suspect> is verbally abusive</span>.";


    // Default called method to obtain variables and set parameters.
    RepaintReformat();

    var countLines = 0;

    function hammerSet(divId, loc){

        var hammerUrl = "";

        switch (Number(divId.substr(3))){
            case 13:
                switch(loc){
                    case 1:
                        hammerUrl = hammer1F;
                        break;
                    case 2:
                        hammerUrl = hammer2F;
                        break;
                    case 3:
                        hammerUrl = hammer3F;
                        break;
                }
                break;
            case 14:
                switch(loc){
                    case 1:
                        hammerUrl = hammer1A;
                        break;
                    case 2:
                        hammerUrl = hammer2A;
                        break;
                    case 3:
                        hammerUrl = hammer3A;
                        break;
                }
                break;
            case 15:
                switch(loc){
                    case 1:
                        hammerUrl = hammer1I;
                        break;
                    case 2:
                        hammerUrl = hammer2I;
                        break;
                    case 3:
                        hammerUrl = hammer3I;
                        break;
                }
                break;
            case 25:
                switch(loc){
                    case 1:
                        hammerUrl = hammer1C;
                        break;
                    case 2:
                        hammerUrl = hammer2C;
                        break;
                    case 3:
                        hammerUrl = hammer3C;
                        break;
                }
                break;
        }
        $('#' + divId).css("background-image", 'url(' + hammerUrl.src + ')');
    }

    function hammerSmack(divId){


        // mid-way
        setTimeout(function() {
            hammerSet(divId, 2);

            // bottom
            setTimeout(function() {
                hammerSet(divId, 1);

                // back to top
                setTimeout(function() {
                    hammerSet(divId, 3);
                }, 500);
            }, 200);
        }, 200);
    }

    var suspectHtml;


    function RepaintReformat() {

        // Variables defining which page we are on since we now match two different pages.
        var GM_QUICKVIEW = 0;
        var GM_CHAT = 0;

        if (window.location.href.indexOf("gm_quickview.php") > -1) {
            GM_QUICKVIEW = 1;
        }
        if (window.location.href.indexOf("chat.php") > -1) {
            GM_CHAT = 1;
        }

        var chatLineTemp = "";

        var greaterThanSymbol = "&gt;";

        var colorGreen = "#00ff00";
        var colorRed = "#ff0000";


        if (GM_CHAT){


            // initialize classes for dynamic jquery css
            $("<style type='text/css'>" +
              "article{margin-right:620px;}" +
              ".chatAdd{ cursor:pointer;}" +
              ".chatAddColor{ color:#00ff00; cursor:pointer;}" +
              ".chatRemove{ color:#ff0000; cursor:pointer;}" +
              ".chatRemoveColor{ color:#ff0000; cursor:pointer;}" +
              ".fixedLog{ position:fixed; top:70px; right:20px; width:600px; height:300px; background-color:#000000; border:3px solid #663399; color:white; text-align:left; display:block; overflow:auto;}" +
              ".fixedHelp{ position:fixed; top:385px; right:240px; width:380px; height:20px; background-color:#000000; color:#9999FF; text-align:left;}" +
              ".fixedClear{ position:fixed; cursor:crosshair; top:385px; right:150px; width:100px; height:20px; background-color:#000000; color:#9999FF; text-align:center; }" +
              ".fixedCountSpan{ position:fixed; top:385px; right:20px; width:130px; height:20px; background-color:#000000; color:#9999FF; text-align:center; }" +
              ".fixedSuspectName{ position:fixed; cursor:pointer; top:405px; right:140px; width:380px; height:20px; background-color:#000000; color:#ff0000; text-align:center;}" +
              ".fixedReporterName{ position:fixed; cursor:pointer; top:425px; right:140px; width:380px; height:20px; background-color:#000000; color:#00ff00; text-align:center;}" +
              //".fixedCopyButton{ position:fixed; cursor:pointer; top:455px; right:140px; width:380px; height:20px; background-color:#000000; color:#00ff00; text-align:center;}" +
              ".underlineRed{ cursor:pointer; border-bottom-color: #ff0000; border-bottom-style: solid; border-bottom-width: 2px;}" +
              ".underlineGreen{ cursor:pointer; border-bottom-color: #00ff00; border-bottom-style: solid; border-bottom-width: 2px;}" +
              ".playerCopied{cursor:pointer;}" +
              ".widthAdjust{position:fixed; cursor:pointer; top:405px; right:20px; width:40px; height:40px;}" +


              ".templateArea{display:none; width:417px; height:50px; overflow:auto; position:fixed; top:640px; right:170px; padding:3px; font-size:16px; border-width:2px; border-style:solid; color:#663399; border-color:#7f51ad; background-color:#d3b7f0; border-radius:3px; box-shadow: 0px 0px 5px 0px rgba(174,120,227,.75);}" +


              ".blackMark{cursor:pointer; height:20px; width:20px; position:fixed; right:585px; background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABeklEQVR42q3UP4rCQBQG8JxAizRWBlQwCmoRrbxBOq3sTSnYpBG8gmfxAILEIoV2YmGRELRSYmEKFQSTb3kDu/5JVifZfTCBEObHN28mIwiCEPzzYA/EHZIkYTweo9frvX6LDxaLRazXa3zXcDhMDqbTacxmMwRBgMfq9/vxwWw2y7ButwvTNJ/A6XQaD5RlGYfDgU2+XC7odDoMpaSO46BarfKDlGyz2cD3fQYScj6foWkaQ+v1On8P8/k8VqtVqGdU8/kcoijy73Iul/tJ9ViEe56HSqUSNS8apGVSsqja7XZoNBq/rSoMlkol1rOoZdq2jXK5/K7nzyAlo92MwqhqtdqnE3EHC4UClstlJETJOLA7mMlksN1uQ8nofb/ff1pmGFRVFa1WC6fT6Qk8Ho+v54wPnEwmMAwDuq4zlJJZlvX4B/CDqVQK1+uVIYS22224rsvbszCoKApGoxFutxsWiwUD6VAnuScZOBgM0Gw22cYkRP52wb4bX8bhrlMEinj2AAAAAElFTkSuQmCC');}" +
              "#blackAccept{display:none; cursor:pointer; height:32px; width:32px; position:fixed; right:124px; top:665px; background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFJUlEQVR42rVXeyiebxj+mJnDhGaakrQcmsS2tJxSlOTQKIcoC1vNJrU/NhJ/jKQkpyWyYfyB/UM5lFNYRHIaQkkUCjmNLcfhufdcz6/v+33fj/fDj++px/d5v/d9nuu97+u67vuRyWQypjy1tLSYlZUVi4uLY4WFhay1tZWNj4+zpaUltr6+zjY2Ntjq6ipbWFhg09PTrKuri1VUVLDExET29OlT8fx/17xgij+EqaOjQ2lpacQXp9+/f9PJyQldZjDG6M+fP/Tz508aGhoib29vkq95iSlj2tra9OHDB1pZWaGbGAD0/ft38vHxuRiAs7Mza25uJk2N6Oho9QAaGhrYZUP9fwbnDFlbW0sDAKlIw+PTp0/SABYXFzUOoLS0VBrA58+f2enpqcY2//XrFzk4OEgDcHd3Zz9+/CBNgAC33r17Rx4eHtIAysvL2f379+njx490cHBwY5tzk6Lnz5/Ts2fPqLq6WhoADxErKysjMzMzsrS0JA6IZmdnaW9vT+j5Ktrf2tqikZER4q5I+vr69OjRI5qYmKDGxkb1APDwzMwMBQcH061bt8jExITs7OwoJiaGuM3S5OSkAHR0dCQcD5+I1ubmJvX29lJubi75+/sTt3Cx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K3OOw+uDBg+sBuOpEsQLQsbEx4sf1C+//C8uqJ25qDCKRAAAAAElFTkSuQmCC');}" +


              ".decision13{ position:fixed; top:461px; right:200px; width:380px; height:20px; background-color:#000000; color:#990000; text-align:left;}" +
              '.decide13{position:fixed; background-size: contain; cursor:pointer; top:454px; right:130px; width:32px; height:32px; }' +
              "#blackMark13{ top:458px}" +

              ".decision14{ position:fixed; top:501px; right:200px; width:380px; height:20px; background-color:#000000; color:#990000; text-align:left;}" +
              '.decide14{position:fixed; background-size: contain; cursor:pointer; top:497px; right:130px; width:32px; height:32px; }' +
              "#blackMark14{ top:498px}" +

              ".decision15{ position:fixed; top:545px; right:200px; width:380px; height:20px; background-color:#000000; color:#990000; text-align:left;}" +
              '.decide15{position:fixed; background-size: contain; cursor:pointer; top:539px; right:130px; width:32px; height:32px; }' +
              "#blackMark15{ top:542px}" +

              ".decision25{ position:fixed; top:588px; right:200px; width:380px; height:20px; background-color:#000000; color:#990000; text-align:left;}" +
              '.decide25{position:fixed; background-size: contain; cursor:pointer; top:581px; right:130px; width:32px; height:32px;}' +
              "#blackMark25{ top:585px}" +
              "button#copyLogText{position: fixed;top: 625px;right: 200px;width: 380px;color: #990000;}" +

              "</style>").appendTo("head");

            $('article').append("<span id='outputLog' class='fixedLog'/>");
            $('article').append("<div id='helpLog' class='fixedHelp'>Click the <span style='color:#00ff00'>></span><span style='color:#663399'>/</span><span style='color:#ff0000'>></span> or the <span style='color:white'>white chat</span> to append/remove</div>");
            $('article').append("<div id='clearLog' class='fixedClear'>Clear log</div>");
            $('article').append("<div id='countLog' class='fixedCountSpan'></div>");
            $('article').append("<div id='suspectName' class='fixedSuspectName'></div>");
            $('article').append("<div id='reporterName' class='fixedReporterName'></div>");
            //$('article').append("<div id='copyLog' class='fixedCopyButton rainbow'>" +
            //                                "<font color=#ff0000>C</font><font color=#e74417>O</font><font color=#d0842e>P</font><font color=#b9ba45>Y</font> <font color=#8bf973>R</font><font color=#73fe8b>E</font><font color=#5cf0a2>S</font><font color=#45d0b9>U</font><font color=#2ea1d0>L</font><font color=#1766e7>T</font></a>" +
            //                                "</div>");
            $('article').append("<div id='decreaser' class='widthAdjust'></div>");
            $('#decreaser').html("<img src='https://xjrwaq-bn1306.files.1drv.com/y3mcJPOzUjaTLLY8az24NlWTQX-ezixiYDIeTVgxWzGHkRFWTOt4iNvgfzgBvHkwu5x2m_3x4cw6jxw0KKrDs5Nc0SiXltvx9jd1VArtddRpsmvxIpkNwSMBy1ecCpcy8IqC-2d8LTOf7-mNXrnX_rYM0ueioC4_eTEDvI-nU4XFRg?width=200&height=200&cropmode=none' width='40px' height='40px'/>");

            $('article').append("<div id='blackMark13' class='blackMark'></div>");
            $('article').append("<div id='blackMark14' class='blackMark'></div>");
            $('article').append("<div id='blackMark15' class='blackMark'></div>");
            $('article').append("<div id='blackMark25' class='blackMark'></div>");

            $('article').append("<textarea id='setTemplateArea' class='templateArea'/>");
            $('article').append("<div id='blackAccept'></div>");

            // checkbox APM and ITEMS will always be checked because we will always bring them from the server.
            $('#apm').prop('checked', true).hide();
            $('#apm').next().addClass("underlineRed").attr("id","ViewAPM").attr("for", "");
            $('#items').prop('checked', true).hide();
            $('#items').next().addClass("underlineRed").attr("id","ViewItems").attr("for", "");
            $('#hideothers').hide();
            $('#hideothers').next().hide();
            $('#info').hide();
            $('#info').next().hide();


            var lineCounter = 1;
            $('article > span > span').each(function(){

                // Both cases will never match for any user input
                if ($(this).html().indexOf(greaterThanSymbol) === 0){
                    // Take all chat except ">"
                    chatLineTemp = $(this).html().substr(greaterThanSymbol.length);

                    // Re-add child spans of the relevant components (to avoid user input starting with > confusing the next each iteration)
                    $(this).html("<span class='chatAdd chatAddColor'>" + greaterThanSymbol + "</span>"+
                                 "<span class='chatAdd' style='color: rgb(255,255,255);'>" + chatLineTemp + "</span>");
                    $(this).attr("id","chatLine" + lineCounter);
                    $('#outputLog').append("<div id='logLine" + lineCounter++ + "'></div>");
                }

                if ($(this).html().indexOf(")" + greaterThanSymbol) === 0){
                    // Take all chat except ")>"
                    chatLineTemp = $(this).html().substr((")" + greaterThanSymbol).length);

                    // Re-add child spans of the relevant components.
                    $(this).html("<span style='color: rgb(255,255,255);'>)</span>"+
                                 "<span class='chatAdd chatAddColor'>" + greaterThanSymbol + "</span>"+
                                 "<span class='chatAdd' style='color: rgb(255,255,255);'>" + chatLineTemp + "</span>");
                    $(this).attr("id","chatLine" + lineCounter);
                    if ($(this).next('span').length > 0){
                        $(this).next('span').next('span').next('span').addClass("playerCopied");

                    }
                    $('#outputLog').append("<div id='logLine" + lineCounter++ + "'></div>");
                }
            });

            var suspectSlot;
            $('article > span').each(function(){
                if ($(this).css('background-color')==="rgb(51, 0, 0)"){
                    suspectSlot = $(' > span > a', this).attr("onclick").substr($(' > span > a', this).attr("onclick").indexOf("(") + 1, $(' > span > a', this).attr("onclick").indexOf(")") - $(' > span > a', this).attr("onclick").indexOf("(") - 1);
                    suspectHtml = $(' > span > a', this).html();
                    if (suspectHtml.indexOf("]") > 0){
                        suspectHtml = suspectHtml.substr(0, suspectHtml.indexOf("[")) + suspectHtml.substr(suspectHtml.indexOf("]") + 1);
                    }
                    $('#suspectName').html("Suspect: " + suspectHtml).attr("onclick","toggleSlot(" + suspectSlot + ")");
                    return false;
                }
            });

            var reporterSlot;
            var reporterHtml;
            $('article > span').each(function(){
                if ($(this).css('background-color')==="rgb(0, 51, 0)"){
                    reporterSlot = $(' > span > a', this).attr("onclick").substr($(' > span > a', this).attr("onclick").indexOf("(") + 1, $(' > span > a', this).attr("onclick").indexOf(")") - $(' > span > a', this).attr("onclick").indexOf("(") - 1);
                    reporterHtml = $(' > span > a', this).html();
                    if (reporterHtml.indexOf("]") > 0){
                        reporterHtml = reporterHtml.substr(0, reporterHtml.indexOf("[")) + reporterHtml.substr(reporterHtml.indexOf("]") + 1);
                    }

                    $('#reporterName').html("Reporter: " + reporterHtml).attr("onclick","toggleSlot(" + reporterSlot + ")");
                    return false;
                }
            });


            $('article').append("<div id='decis13' class='decision13'/>");
            $('article').append("<div id='dec13' class='decide13'/>");
            $('article').append("<div id='decis14' class='decision14'/>");
            $('article').append("<div id='dec14' class='decide14'/>");
            $('article').append("<div id='decis15' class='decision15'/>");
            $('article').append("<div id='dec15' class='decide15'/>");
            $('article').append("<div id='decis25' class='decision25'/>");
            $('article').append("<div id='dec25' class='decide25'/>");
            $('article').append("<button id='copyLogText'>Copy Text for Translation</button>");


            updateVerdicts();


            hammerSet("dec13", 3);
            hammerSet("dec14", 3);
            hammerSet("dec15", 3);
            hammerSet("dec25", 3);

            var origtoggleSlot = toggleSlot;
            toggleSlot = function(slotId) {
                if ((!$('#player_'+slotId).length) && ($("span.slot_" + slotId).length))
                {
                    $('.slot_' + slotId).fadeOut();
                    $('#PlayerFilterBox').append("<span id='player_" + slotId + "'><a style='text-decoration: none;' href='javascript:void(0);' onClick=toggleSlot(" + slotId + ")>" + playerList[slotId] + "</a> </span>");
                }
                else
                {
                    if (($('#ViewItems').hasClass('underlineRed')) &&  ($('#ViewAPM').hasClass('underlineRed')))
                        $('.slot_' + slotId + ':not(.Item_info):not(.APM_info)').fadeIn();
                    else
                        if ($('#ViewItems').hasClass('underlineRed'))
                            $('.slot_' + slotId + ':not(.Item_info)').fadeIn();
                    else
                        if ($('#ViewAPM').hasClass('underlineRed'))
                            $('.slot_' + slotId + ':not(.APM_info)').fadeIn();
                    else
                        $('.slot_' + slotId).fadeIn();

                    $('#player_'+slotId).remove();
                }
            };

            for (var j = 0; j < 22; ++j){
                //$('span:has(".slot_' + j + '")').each(function(){
                $('.slot_' + j).each(function(){

                    if ($(this).find('span[style*="color: rgb(142,255,142)"]').length){

                        $(this).addClass('All_info');

                        if ($(this).find('span:contains(" a ")').length)
                            $(this).addClass('Item_info');

                        if ($(this).find('span:contains("has upgraded their ability")').length){
                            $(this).addClass('Skill_info');
                        }

                        //if ($(this).find('span:contains("has picked")').length){
                        //                        $(this).addClass('Picks_info');
                        //                    }
                        if ($(this).find('span:contains(") in the last")').length){
                            $(this).addClass('APM_info');
                        }
                    }
                });
            }
            $('.APM_info').hide();
            $('.Item_info').hide();

            for (var i = 0; i < 22; ++i){
                if (i != suspectSlot)
                    //setTimeout(toggleSlot(i),i*4500 + 4500);
                    toggleSlot(i);
            }

        }

        if (GM_QUICKVIEW){
            $(document).on('click', "a:contains('Chat Log')",function(){
                if (($(this).attr("href").indexOf("&items=on&apm=on") < 0 )){
                    $(this).attr('href', $(this).attr('href') + "&items=on&apm=on");
                }
            });

            $('a[href="/getOpenTicket.php"]').on("click", function() {

                GM_setValue("decisionNumber", "");
                GM_setValue("matchID", "");
                ticketVerification();
            });


            $("#matchid_display").change(function() {
                ticketVerification();
            });

            $("#type_dropdown").change(function() {
                ticketVerification();
            });

            $("textarea[name=reason]").on('paste', function() {

                if (($('.open_ticket_link').attr("onclick").substr(0,4) !== "/**/"))
                    $('.open_ticket_link').each(function(){
                        var temp = "/**/" + $(this).attr("onclick");
                        //$(this).prop('onclick',null).off('click');
                        $(this).on("click", function() {
                            ticketVerification();
                        });
                    });

                ticketVerification();
            });


        }
    }

    function ticketVerification(){
        var decisionNumber = GM_getValue("decisionNumber", "");
        var matchID = GM_getValue("matchID", "");

        var questionMarkUrl = "https://pn19uw-bn1306.files.1drv.com/y3m0PpLug756lY-i5pb7uNXNHJMQXcPp6wTWmd1OhodCFpn7Zi1q-IZkSq3NiLoUOG1JivXduIKGai-i7dJ94DulLiKnHUWN_mwaZ4ijOAY4k6nP7e2my16Wcc0CmF-kPEeYX0p52HqqzRz0FephMkKJWnpa709HEvYaLvKnDIqAvY?width=128&height=128&cropmode=none";
        var checkMarkUrl = "https://pn0yya-bn1306.files.1drv.com/y3mdMXnV_kX_UYAPABsa5hfl8jN4OfiJR-prexnrDEdnsMqqpEFWvsd1ZWn0nHj5CDnkezg5Ts1ezXZk9-ISglCUFAuyrj9kVtOxbwKObvNZBQ2jeh1xPFRvYnBZNWq7oPZJ5MIgLcICwyX3Qj39w4Ec5rghvj66lxESTNQFU8vRmE?width=128&height=128&cropmode=none";
        var deniedMarkUrl = "https://y9ublg-bn1306.files.1drv.com/y3mn9NMo7fJfkD1uBT2QHSHzqLXKOj3mWAPtZWn1HaLOJf5wUrGR8k8Lj3fM0hciONApvsYoEM5EHjvB6O_41XT2Vv3APMKRyWsM94KjovfaE34oihrqjafByFQgnyv4l9tm9o0vwrkbFl528J_yxg-fENnLgwBCaPrYKr1YWOQUNc?width=128&height=128&cropmode=none";

        if ($('#matchIDIcon').length === 0) {
            $('#matchid_display').parent().after("<div id='matchIDIcon' style='margin-left:5px; width:21px; height:21px; background-size: contain; float:left;'/>");
        }

        if ($('#typeIcon').length === 0) {
            $('#type_dropdown').css("float", "left");
            $('#type_dropdown').after("<div id='typeIcon' style='margin-left:5px; width:21px; height:21px; background-size: contain; float:left;'/>");
        }

        if (matchID === "") // put ?
            $('#matchIDIcon').css("background-image", 'url(' + questionMarkUrl + ')');
        else
            if (matchID === $('#matchid_display').val()) // put v
                $('#matchIDIcon').css("background-image", 'url(' + checkMarkUrl + ')');
        else // put x
            $('#matchIDIcon').css("background-image", 'url(' + deniedMarkUrl + ')');


        if (decisionNumber === "") // put ?
            $('#typeIcon').css("background-image", 'url(' + questionMarkUrl + ')');
        else
            if (decisionNumber === $('#type_dropdown').val()) // put v
                $('#typeIcon').css("background-image", 'url(' + checkMarkUrl + ')');
        else // put x
            $('#typeIcon').css("background-image", 'url(' + deniedMarkUrl + ')');

        //GM_setValue("decisionNumber", "");
        //GM_setValue("matchID", "");
    }


    var currentlySetting = 0;

    $(document).on('click', ".blackMark", function(){
        currentlySetting = Number($(this).attr('id').substr(9));
        $('#setTemplateArea').toggle();
        $('#blackAccept').toggle();

        var verdictFormat = GM_getValue("verdictFormat" + currentlySetting, "");
        if (verdictFormat === "")
            $('#setTemplateArea').val("<suspect> is eating rice on his pizza!");
        else
            $('#setTemplateArea').val(verdictFormat);
    });


    $(document).on('click', "#blackAccept", function(){
        GM_setValue("verdictFormat" + currentlySetting, $('#setTemplateArea').val());
        setVerdictString(currentlySetting, $('#setTemplateArea').val());
        $('#setTemplateArea').toggle();
        $('#blackAccept').toggle();
    });

    function updateVerdicts(){

        // sets either the default verdicts or the templates predefined
        var verdictFormat = GM_getValue("verdictFormat13", "");
        if (verdictFormat === "")
            setVerdictString(13, GUILTY_FEEDING);
        else
            setVerdictString(13, verdictFormat);


        verdictFormat = GM_getValue("verdictFormat14", "");
        if (verdictFormat === "")
            setVerdictString(14, GUILTY_AFK);
        else
            setVerdictString(14, verdictFormat);

        verdictFormat = GM_getValue("verdictFormat15", "");
        if (verdictFormat === "")
            setVerdictString(15, GUILTY_ITEMABUSE);
        else
            setVerdictString(15, verdictFormat);

        verdictFormat = GM_getValue("verdictFormat25", "");
        if (verdictFormat === "")
            setVerdictString(25, GUILTY_CHATABUSE);
        else
            setVerdictString(25, verdictFormat);

    }

    function setVerdictString(verdictNumber, verdictString){
        var newVerdictString = verdictString.replace(/<suspect>/g, suspectHtml);
        $('#decis' + verdictNumber).html(newVerdictString);
    }

    function checkIfSlotVisibile($object){

        for (var i = 0; i < 22; ++i){
            if ($object.hasClass("slot_" + i)){
                return ($(".slot_" + i).is(':visible'));
            }
        }
    }

    $(document).on('click', "#decreaser", function(){
        $('#helpLog').hide();
        var currentWidth = Number($("#outputLog").css('width').replace('px',''));
        var currentMargin = Number($('article').css('margin-right').replace('px',''));

        if (currentWidth < 400){
            return;
        }else{

            $("#outputLog").css('width', currentWidth - 250 + 'px');
            $('article').css('margin-right', currentMargin - 250 + 'px');
        }
    });

    $(document).on('click', "#ViewAPM", function() {
        if ($(this).hasClass("underlineRed")){
            $(this).removeClass("underlineRed");
            $(this).addClass("underlineGreen");

            $('.APM_info').each(function (){
                for (var i = 0; i < 22; ++i){
                    if ($(this).hasClass("slot_" + i)){
                        if (!($('#player_' + i).length))
                            $(this).show();
                    }
                }
            });
        }else{
            $(this).removeClass("underlineGreen");
            $(this).addClass("underlineRed");
            $('.APM_info').hide();
        }
    });

    $(document).on('click', "#ViewItems", function() {
        if ($(this).hasClass("underlineRed")){
            $(this).removeClass("underlineRed");
            $(this).addClass("underlineGreen");

            $('.Item_info').each(function (){
                for (var i = 0; i < 22; ++i){
                    if ($(this).hasClass("slot_" + i)){
                        if (!($('#player_' + i).length))
                            $(this).show();
                    }
                }
            });

        }else{
            $(this).removeClass("underlineGreen");
            $(this).addClass("underlineRed");
            $('.Item_info').hide();
        }
    });

    $(document).on('click', ".playerCopied", function() {
        $(this).prev().prev().prev().find('span').each(function () {
            if (($(this).hasClass("chatRemove")) || ($(this).hasClass("chatAdd"))){
                $(this).click();
                return false;
            }
        });
    });


    $(document).on('click', ".chatAdd", function() {
        var chatLineNum;
        var added = false;
        chatLineNum = $(this).parent().attr('id').substr(8);
        $('#chatLine' + chatLineNum).children('span').each(function () {
            if ($(this).hasClass("chatAdd"))
                added = true;
            $(this).removeClass("chatAdd");
            $(this).addClass("chatRemove");
            if ($(this).hasClass("chatAddColor")){
                $(this).removeClass("chatAddColor");
                $(this).addClass("chatRemoveColor");
            }
        });
        if (added)
            addLineCount();
        $('#logLine' + chatLineNum).html($(this).parent().parent().html());
    });

    $(document).on('click', ".chatRemove", function() {
        var chatLineNum;
        var removed = false;
        chatLineNum = $(this).parent().attr('id').substr(8);
        $('#chatLine' + chatLineNum).children('span').each(function () {
            if ($(this).hasClass("chatRemove"))
                removed = true;
            $(this).removeClass("chatRemove");
            $(this).addClass("chatAdd");
            if ($(this).hasClass("chatRemoveColor")){
                $(this).removeClass("chatRemoveColor");
                $(this).addClass("chatAddColor");
            }
        });
        if (removed)
            removeLineCount();
        $('#logLine' + chatLineNum).html("");
    });

    $(document).on('click', "#dec13, #dec14, #dec15, #dec25",function(){

        var resultingOutput = "";


        var decisionNumber = $(this).attr('id').substr(3);
        var matchID = $("input[name=match_id]").val();
        GM_setValue("decisionNumber", decisionNumber);
        GM_setValue("matchID", matchID);

        resultingOutput = $('#decis' + decisionNumber).text() + "\n\n";

        $('#outputLog > div').each(function (){
            if ($(this).text().length > 0)
                resultingOutput += $(this).text() + "\n";
        });
        GM_setClipboard(resultingOutput);
        //$event.preventDefault();

        hammerSmack($(this).attr('id'));
    });

    // Copy functionality for text only
    $(document).on('click', '#copyLogText', function() {
        var textToCopy = '';
        $('#outputLog > div').each(function() {
            if ($(this).text().length > 0) {
                textToCopy += $(this).text().split('> ')[1] + "\n";
            }
        });
        GM_setClipboard(textToCopy);
    })

    $(document).on('click', "#clearLog", function() {
        clearOutput();
    });

    function addLineCount() {
        countLines = countLines + 1;
        $('#countLog').html("Lines count: " + countLines);
    }

    function removeLineCount() {
        countLines = countLines - 1;
        $('#countLog').html("Lines count: " + countLines);
    }

    function clearOutput(){
        $('.chatRemoveColor').each(function(){
            $(this).click();
        });
    }

})();