DM colorization

Makes each person DMing you have a different color for organization sake

ของเมื่อวันที่ 28-03-2023 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         DM colorization
// @namespace    https://dreamychat.com/*
// @version      0.1
// @description  Makes each person DMing you have a different color for organization sake
// @author       You
// @match        https://dreamychat.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @require      http://code.jquery.com/jquery-latest.js
// @run-at   document-start
// @license MIT
// ==/UserScript==

var seed = 1;
function random() {
    var x = Math.sin(seed++) * 10000;
    return x - Math.floor(x);
}
let zzz = true;

function ChangeClr() {

    var rules = new Array();
    if (zzz) {
        zzz=false;
        for (let i = 0; i < document.styleSheets.length; i++) {

        //console.log("Here babe");
        if (document.styleSheets[i].cssRules) {
            rules = document.styleSheets[i].cssRules;
        }
        else if (document.styleSheets[i].rules) {
            rules = document.styleSheets[i].rules;
        }

        for(let j = 0; j < rules.length; j++) {
            if (String(rules[j].selectorText) == ".chat-invite.chat-self::after, .chat-invite.chat-to::after, .chat-whisper::after") {
                //document.styleSheets[0].deleteRule(rules[j]);
                rules[j].style = ".chat-invite.chat-self::after, .chat-invite.chat-to::after, .chat-whisper::after {border-width: 0 .25rem;}";
                document.styleSheets[i].cssRules[j] = rules[j];
            }
        }
    }
}
    var stuff = document.getElementsByClassName("chat-whisper");
    var bad = document.getElementsByClassName("chat-self");
    for (let i = 0; i < stuff.length; i++) {

        if (!Array.prototype.includes.call(bad, stuff[i])) {
            try {
                stuff[i].classList.remove("chat-mention");
            } catch {

            }

            var s = stuff[i].getElementsByClassName("name")[0];
            var aTags = s.getElementsByTagName("span");
            var t = aTags[0].textContent;

            //console.log(t);
            seed = t.charCodeAt(0)*t.charCodeAt(1);
            var r = random()*255;
            var g = random()*255;
            var b = random()*255;
            if (t == "RaeRae") {
                r = 189;
                g = 102;
                b = 231;
            }
            if (t == "cold_c4ssidy") {
                r = 255; g = 130; b = 201;
            }
            var color = "rgba("+r+","+g+","+b+",.35)";
            //console.log(color);
            stuff[i].style = "background: "+color+";border: solid "+color+";border-width: 0 0.25rem;";
            //stuff[i].style.display='none';
            //stuff[i].offsetHeight; // no need to store this anywhere, the reference is enough
            //stuff[i].style.display='';
        }
    }
};

var i = setInterval(ChangeClr,1000);

console.log("Dreamychat colored DMs loaded!");