CubeCraft appeal site improvements

Changes the date of the infraction to the local timezone and makes links clickable. Also adds a namemc link.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        CubeCraft appeal site improvements
// @namespace   Violentmonkey Scripts
// @match       https://appeals.cubecraft.net/find_appeals/*
// @grant       none
// @version     1.4.2
// @author      Caliditas
// @description Changes the date of the infraction to the local timezone and makes links clickable. Also adds a namemc link.
// ==/UserScript==

var infractions = document.getElementsByClassName("col-sm-8");
var amountOfInfractions = infractions[0].children.length;

for (var i = 0; i < amountOfInfractions; i++) {
  replaceDate(infractions[0].children[i].firstElementChild);
}

function replaceDate(element) {
  var contentString = element.innerHTML;
  dateStringOld = contentString.slice(contentString.indexOf(" at") + 3, contentString.indexOf(" for")) + " UTC";
  var dateOldMs = Date.parse(dateStringOld);
  var dateOld = new Date(dateOldMs);
  var contentStringChanged = contentString.slice(0, contentString.indexOf(" at ") + 4) + dateOld.toString().slice(4, 10) + "," + dateOld.toString().slice(10, 25) + initials(new Date().toString().match(/\(([A-Za-z\s].*)\)/)[1])
  contentStringChanged += contentString.slice(contentString.indexOf(" for"));
  if (contentStringChanged.includes("http")) {
    var evidenceLink = contentStringChanged.slice(contentStringChanged.indexOf("http"))
    // evidenceLink.slice
    var evidenceLinkShort = evidenceLink.slice(0, evidenceLink.indexOf("\t"));
    evidenceLinkShort = evidenceLinkShort.slice(0, evidenceLinkShort.indexOf(" "));
    // console.log(evidenceLinkShort)
    contentStringChanged = contentStringChanged.slice(0, contentStringChanged.indexOf("http")) + "<a target=\"_blank\" href=\"" + evidenceLinkShort + "\">" + evidenceLinkShort + "</a>" + contentStringChanged.slice(contentStringChanged.indexOf("http") + evidenceLinkShort.length) //evidenceLink.slice(evidenceLink.indexOf("\t"));
  }
  // console.log(contentStringChanged)
  element.innerHTML = contentStringChanged;
}

function initials(words) {
  if (words.includes(" ")) {
    var wordsArray = words.split(" ");
    var initials = "";
    for (var i = 0; i < wordsArray.length; i++) {
      initials += wordsArray[i][0];
    }
    return initials;
  } else {
    return words;
  }  
}

var nameElem = document.getElementsByClassName("col-sm-4")[0];
var uuid = nameElem.children[0].outerHTML.slice(nameElem.children[0].outerHTML.indexOf("user=") + 5, nameElem.children[0].outerHTML.indexOf("\" style"));
var outer = nameElem.outerHTML;
var newOuter = outer.slice(0, outer.indexOf(">")) + "onclick=\"window.open('https://namemc.com/profile/" + uuid + "');\" style=\"cursor: pointer;\"" + outer.slice(outer.indexOf(">"))
nameElem.outerHTML = newOuter;