by chatgpt

Adds a color picker to choose any brush color in Drawaria

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         by chatgpt
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a color picker to choose any brush color in Drawaria
// @author       belen
// @match        https://drawaria.online/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Wait for the page to load
    window.addEventListener('load', () => {
        // Create a color picker input
        const colorPicker = document.createElement('input');
        colorPicker.type = 'color';
        colorPicker.style.position = 'absolute';
        colorPicker.style.top = '10px';
        colorPicker.style.right = '10px';
        colorPicker.style.zIndex = 9999;
        colorPicker.title = 'Pick your custom brush color';

        // Add to the page
        document.body.appendChild(colorPicker);

        // Hook into the game's brush color logic
        colorPicker.addEventListener('input', () => {
            const brush = window?.canvasInstance?.brush;
            if (brush) {
                brush.color = colorPicker.value;
                console.log('[Drawaria] Custom brush color set to:', colorPicker.value);
            }
        });

        console.log('[Drawaria] Custom color picker loaded.');
    });
})();