Some colourful javascript injection

Always thought that every user having the same colour is boring?

Then I have the solution for you!


I also adjusted them to be more readable on light theme, but I don't like it as much there, the colours don't really pop out:


Here’s the custom javascript that one can inject that will give every user their own random colour (within a range) based on their player number.

I’ve also added a part where you can pick a specific colour for yourself (or anybody in particular), see the commented part in the code about halfway:

setInterval(function() {
	
	var list = document.getElementsByClassName("Player");
	
	for (var i=0; i < list.length; i++) {
		
		var v = parseInt(list[i].getAttribute("data-player-id"));
		var o1,p1,o2,p2,o3,p3;
		
		if (document.body.classList.contains("dark") || document.body.classList.contains("accessible")) {
			o1 = 175;
			p1 = 35;
			o2 = 51;
			p2 = 49;
			o3 = 70;
			p3 = 23;
			if (list[i].classList.contains("moderator")) {
				o1 = 245;
				p1 = 71;
				o3 = 60;
				p3 = 13;
			} else if (list[i].classList.contains("aga")) {
				o1 = -10;
				p1 = 30;
				p2 = 23;
				o3 = 55;
			} else if (list[i].classList.contains("supporter")) {
				o1 = 40;
				p1 = 19;
				o2 = 75;
				p2 = 23;
				o3 = 55;
			} else if (list[i].classList.contains("professional")) {
				o1 = 80;
				p1 = 60;
				o3 = 40;
				p3 = 37;
			} else if (list[i].classList.contains("bot")) {
				o1 = -10;
				p1 = 45;
				o2 = 0;
				p2 = 15;
				o3 = 45;
			}
		} else {
			o1 = 175;
			p1 = 35;
			o2 = 51;
			p2 = 49;
			o3 = 15;
			p3 = 23;
			if (list[i].classList.contains("moderator")) {
				o1 = 245;
				p1 = 71;
				o3 = 35;
				p3 = 13;
			} else if (list[i].classList.contains("aga")) {
				o1 = -10;
				p1 = 30;
				p2 = 23;
				o3 = 35;
			} else if (list[i].classList.contains("supporter")) {
				o1 = 35;
				p1 = 19;
				o2 = 75;
				p2 = 23;
				o3 = 35;
				p3 = 15;
			} else if (list[i].classList.contains("professional")) {
				o1 = 80;
				p1 = 60;
				o3 = 20;
				p3 = 37;
			} else if (list[i].classList.contains("bot")) {
				o1 = -10;
				p1 = 45;
				o2 = 0;
				p2 = 15;
				o3 = 65;
			}
		}
		
		// If you want to give yourself a particular colour, 
		// replace "0" by your player id in the line below:
		if ( v == 0) {
			o1 =  10; // hue (0 to 255)
			o2 = 100; // saturation (0 to 100)
			o3 =  50; // luminance (0 to 100)
			p1 = 1;
			p2 = 1;
			p3 = 1;
		}
		
		if (v<0) {
			
			list[i].setAttribute('style', "color:hsl(0,0%,50%)!important");
		} else {
			list[i].setAttribute('style', "color:hsl("+(o1+v%p1)+","+(o2+v%p2)+"%,"+(o3+v%p3)+"%)!important");
		}
	}
	
},50)
6 Likes

We could also have a gradient color change depending on the ranks of the players (with bots and pro account having a distinct color).

2 Likes

from Imgflip Meme Generator

6 Likes