Homestuck Fix Chatlogs

replaces leet speak with letters

Versão de: 11/03/2019. Veja: a última versão.

// ==UserScript==
// @name         Homestuck Fix Chatlogs
// @namespace    kmcgurty.com
// @version      1.1
// @description  replaces leet speak with letters
// @author       Kmcgurty
// @match        https://www.homestuck.com/story/*
// @grant        GM_addStyle
// ==/UserScript==

var equivalent = ["", "I", "s", "E", "A"];

function fix(){
    var messages = document.querySelectorAll(".o_chat-log span");

    messages.forEach(function(span){
        var split = span.innerText.split("");

        for(var i = 0; i < split.length; i++){
            var currentValue = parseInt(split[i]);
            if(!isNaN(currentValue) && currentValue < equivalent.length){
                split[i] = equivalent[currentValue];
            }
        }

        span.innerText = split.join("");

        span.innerText = span.innerText.replace(/ii/g, "i");
    });
}

var showLogButton = document.querySelector(".o_chat-log-btn");
var fixButton = document.createElement("button");
fixButton.innerText = "Fix Log";
fixButton.onclick = fix;
fixButton.className = "fix_chatlogs";
document.querySelector(".o_chat-container").insertBefore(fixButton, showLogButton);

GM_addStyle(`
.fix_chatlogs{
    right: 180px;
   position: absolute;
}
`)