Arras.io Rainbow Theme

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

当前为 2024-02-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
    };
})();