Rainbow nickname MPP

Rainbow nickname bot

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Rainbow nickname MPP
// @namespace    https://greasyfork.org/
// @version      0.1
// @description  Rainbow nickname bot
// @author        You
// @include      *://multiplayerpiano.com/*
// @include      *://mpp.hyye.tk/*
// @include      *://mppclone.com/*
// @include      *://mpp.frostical.ga/*
// @icon         http://imageshack.com/a/img923/4396/i1Wmrm.png
// @grant        none
// ==/UserScript==

var count = 0;
var size = 100;
var rainbow = new Array(size);
 
for (var i = 0; i < size; i++) {
    var red = sin_to_hex(i, 0 * Math.PI * 2 / 3); // 0   deg
    var blue = sin_to_hex(i, 1 * Math.PI * 2 / 3); // 120 deg
    var green = sin_to_hex(i, 2 * Math.PI * 2 / 3); // 240 deg
 
    rainbow[i] = "#" + red + green + blue;
}
 
function sin_to_hex(i, phase) {
    var sin = Math.sin(Math.PI / size * 2 * i + phase);
    var int = Math.floor(sin * 127) + 128;
    var hex = int.toString(16);
 
    return hex.length === 1 ? "0" + hex : hex;
}
 
function rainbow1() {
    setTimeout(rainbow1, 500)
    if (count > rainbow.length) count = 0;
    count++;
    MPP.client.sendArray([{
        m: "userset",
        set: {
            color: `${rainbow[count]}`
        }
    }]);
}
 
setTimeout(rainbow1, 3000)