Drawaria Add More Medals

Add more medals to your drawaria account.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Drawaria Add More Medals
// @namespace    http://tampermonkey.net/
// @version      2024-10-14
// @description  Add more medals to your drawaria account.
// @author       YouTubeDrawaria
// @match        https://drawaria.online/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=drawaria.online
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to change the numbers of the medals
    function changeMedalNumbers(medalIndex) {
        // Select the elements that contain the numbers of the medals
        const medalElements = document.querySelectorAll('td[colspan="2"] div[style*="display: flex; justify-content: space-evenly;"] span div');

        // Verify if the elements were found
        if (medalElements.length === 3) {
            // Change the number of the corresponding medal
            const newValue = prompt(`Enter the new value for the ${medalIndex === 0 ? 'gold' : medalIndex === 1 ? 'silver' : 'bronze'} medal:`);
            if (newValue !== null) {
                medalElements[medalIndex].textContent = newValue;
            }
        } else {
            console.error('Medal elements not found.');
        }
    }

    // Function to add buttons below the medal quantities
    function addButtons() {
        // Select the medal container
        const medalContainer = document.querySelector('td[colspan="2"] div[style*="display: flex; justify-content: space-evenly;"]');

        // Create the buttons
        const goldButton = document.createElement('button');
        goldButton.textContent = 'Change Gold';
        goldButton.style.marginRight = '10px';
        goldButton.style.padding = '5px 10px';
        goldButton.style.backgroundColor = '#FEE101';
        goldButton.style.color = '#000';
        goldButton.style.border = 'none';
        goldButton.style.borderRadius = '5px';
        goldButton.style.cursor = 'pointer';

        const silverButton = document.createElement('button');
        silverButton.textContent = 'Change Silver';
        silverButton.style.marginRight = '10px';
        silverButton.style.padding = '5px 10px';
        silverButton.style.backgroundColor = '#D7D7D7';
        silverButton.style.color = '#000';
        silverButton.style.border = 'none';
        silverButton.style.borderRadius = '5px';
        silverButton.style.cursor = 'pointer';

        const bronzeButton = document.createElement('button');
        bronzeButton.textContent = 'Change Bronze';
        bronzeButton.style.padding = '5px 10px';
        bronzeButton.style.backgroundColor = '#cd7f32';
        bronzeButton.style.color = '#000';
        bronzeButton.style.border = 'none';
        bronzeButton.style.borderRadius = '5px';
        bronzeButton.style.cursor = 'pointer';

        // Add the buttons below the medal quantities
        medalContainer.insertAdjacentElement('afterend', bronzeButton);
        medalContainer.insertAdjacentElement('afterend', silverButton);
        medalContainer.insertAdjacentElement('afterend', goldButton);


        // Add events to the buttons
        goldButton.addEventListener('click', () => changeMedalNumbers(0));
        silverButton.addEventListener('click', () => changeMedalNumbers(1));
        bronzeButton.addEventListener('click', () => changeMedalNumbers(2));
    }

    // Function to observe changes in the DOM and add the buttons when the medal container is available
    function observeDOM() {
        const observer = new MutationObserver((mutations) => {
            mutations.forEach((mutation) => {
                if (mutation.type === 'childList') {
                    const medalContainer = document.querySelector('td[colspan="2"] div[style*="display: flex; justify-content: space-evenly;"]');
                    if (medalContainer) {
                        addButtons();
                        observer.disconnect(); // Stop observing once the buttons have been added
                    }
                }
            });
        });

        observer.observe(document.body, { childList: true, subtree: true });
    }

    // Start observing the DOM
    observeDOM();
})();