Sprint Color Spectrum Sprint

shows colored usernames based on 40L Sprint time

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Sprint Color Spectrum Sprint
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  shows colored usernames based on 40L Sprint time
// @author       Oki
// @match        https://*.jstris.jezevec10.com/*
// @grant        none
// ==/UserScript==

/**************************
Sprint Color Spectrum Script       
**************************/

(function() {
    window.addEventListener('load', function(){

function colorize(limit){
    Game["links"] = document.getElementsByTagName('a')
	for (var o = 0; (o < Game["links"].length) && limit; o++) {
		var regexp = /(https:\/\/jstris\.jezevec10\.com\/u\/)([^\/]*)(.*)/g;
		var parts = regexp.exec(Game["links"][o].href);
		if(parts && parts[2] && !parts[3]){
            var execEval=`limit--;
			var url = "https://jstris.jezevec10.com/api/u/"+parts[2]+"/records/1?mode=1"
			var xhr = new XMLHttpRequest();
			xhr.onreadystatechange = function() {
			  if (this.readyState == 4 && this.status == 200) {
			  	var best = 25
			  	var worst = 100
                var a = [255,0,0] //best
				var b = [128,0,128] //medium
				var d = [0,255,255] //worst
			    var min = JSON.parse(this.responseText).min;
				(min!=0&&min<best)&&(min=best);min>worst&&(min=worst);
				var c=2*((min-best)/(worst-best));1<=c&&(--c,a=b,b=d);
				var e=[parseInt(0|a[0]+(b[0]-a[0])*c,10),parseInt(0|a[1]+(b[1]-a[1])*c,10),parseInt(0|a[2]+(b[2]-a[2])*c,10)];
				var color = "rgb("+e[0]+","+e[1]+","+e[2]+")"
				min||(color='rgb(75,75,75)')
			    Game["links"][`+o+`].style.color = color
			  }
			};
			xhr.open("GET", url, true);
			xhr.send();`
            eval(execEval)
		}
	}
}

Game["colorize"] = colorize;

if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}

var sendChatFunc = Live['prototype']['sendChat'].toString()
var params3 = getParams(sendChatFunc)


sendChatFunc = "if(chatInput.value.startsWith('/color')){amount=chatInput.value.split(' ')[1];Game['colorize'](+amount);chatInput.value='';msg=document.createElement('div');msg.className='chl srv';msg.innerHTML='Colorizing '+amount+' username(s)';ch1.appendChild(msg);return}" + trim(sendChatFunc)
Live['prototype']["sendChat"] = new Function(...params3, sendChatFunc);

});
})();