Arras.io Rainbow Theme

This script make your team rainbow, you can change the colors too!

目前為 2024-02-19 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Arras.io Rainbow Theme
// @version     1.0.1
// @author      theo
// @namespace   Rainbowify your game
// @description This script make your team rainbow, you can change the colors too!
// @match       *://arras.io/
// @match       *://arras.cx/
// @run-at document-load
// @grant none
// ==/UserScript==

const SIZE = 150;
const SAME = false;

(async () => {
    while (!window.Arras() || !window.Arras().themeColor || !window.Arras().themeColor.table) {
        await new Promise(r => setTimeout(r, 40));
    }
    const script = document.createElement("script");
    script.src = "https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.7/chroma.min.js";
    document.head.append(script);

    script.onload = () => {
        const scale = chroma.scale(["red","orange",yellow,green,blue,purple]).colors(SIZE);
        const teamColors = [10, 11, 12,15]; // blue, green, red, purple
        let index = 0;

        function updateColors() {
            const colors = window.Arras().themeColor.table;

            for (let color = 0; color < colors.length; color++) {
                if (teamColors.indexOf(color) < 0) continue;

                if (color === 11) {
                    colors[color] = chroma.scale(["green", "yellow"]).colors(SIZE)[index % SIZE];
                } else if (color === 12) {
                    colors[color] = chroma.scale(["red","black"]).colors(SIZE)[index % SIZE];
                                    } else if (color === 15) {
                    colors[color] = chroma.scale(["purple","blue"]).colors(SIZE)[index % SIZE];


                } else {
                    if (!SAME) {
                        colors[color] = scale[(index + (teamColors.indexOf(color) * SIZE / 4)) % SIZE];
                    } else {
                        colors[color] = scale[index % SIZE];
                    }
                }
            }
            index++;
            index = index % SIZE;
        }

        setInterval(updateColors);
    };
})();