Color Changer

Hurawatch script

// ==UserScript==
// @name         Color Changer
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Hurawatch script
// @author       mcfajr on discord
// @match        *://hurawatch.cc/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=hurawatch.cc
// @grant        none
// @license mit
// ==/UserScript==

(function() {
    'use strict';

    const colorChangerPopup = document.createElement('div');
    colorChangerPopup.style.position = 'fixed';
    colorChangerPopup.style.top = '10px';
    colorChangerPopup.style.right = '10px';
    colorChangerPopup.style.padding = '10px';
    colorChangerPopup.style.backgroundColor = '#fff';
    colorChangerPopup.style.border = '1px solid #ccc';
    colorChangerPopup.style.zIndex = '9999';

    const minimizeButton = document.createElement('button');
    minimizeButton.textContent = '-';
    minimizeButton.style.position = 'absolute';
    minimizeButton.style.top = '0';
    minimizeButton.style.right = '0';
    minimizeButton.style.padding = '2px 6px';
    minimizeButton.style.fontSize = '16px';
    minimizeButton.style.fontWeight = 'bold';
    minimizeButton.style.border = 'none';
    minimizeButton.style.background = 'none';
    minimizeButton.style.cursor = 'pointer';

    const contentContainer = document.createElement('div');
    contentContainer.style.display = localStorage.getItem('userScriptMinimized') === 'true' ? 'none' : 'block';

    const bgColorLabel = document.createElement('div');
    bgColorLabel.textContent = 'Background Color:';
    bgColorLabel.style.marginBottom = '5px';

    const bgColorInput = document.createElement('input');
    bgColorInput.type = 'color';
    bgColorInput.style.marginBottom = '10px';

    const textColorLabel = document.createElement('div');
    textColorLabel.textContent = 'Text Color:';
    textColorLabel.style.marginBottom = '5px';

    const textColorInput = document.createElement('input');
    textColorInput.type = 'color';

    const savedBgColor = localStorage.getItem('userScriptBgColor');
    const savedTextColor = localStorage.getItem('userScriptTextColor');
    if (savedBgColor) {
        bgColorInput.value = savedBgColor;
        applyBackgroundColor(savedBgColor);
    }
    if (savedTextColor) {
        textColorInput.value = savedTextColor;
        applyTextColor(savedTextColor);
    }

    const applyButton = document.createElement('button');
    applyButton.textContent = 'Apply';
    applyButton.addEventListener('click', function() {
        const bgColor = bgColorInput.value;
        const textColor = textColorInput.value;

        localStorage.setItem('userScriptBgColor', bgColor);
        localStorage.setItem('userScriptTextColor', textColor);

        applyBackgroundColor(bgColor);
        applyTextColor(textColor);
    });

    minimizeButton.addEventListener('click', function() {
        if (contentContainer.style.display === 'none') {
            contentContainer.style.display = 'block';
            minimizeButton.textContent = '-';
            localStorage.setItem('userScriptMinimized', 'false');
        } else {
            contentContainer.style.display = 'none';
            minimizeButton.textContent = '+';
            localStorage.setItem('userScriptMinimized', 'true');
        }
    });

    colorChangerPopup.appendChild(minimizeButton);
    contentContainer.appendChild(bgColorLabel);
    contentContainer.appendChild(bgColorInput);
    contentContainer.appendChild(textColorLabel);
    contentContainer.appendChild(textColorInput);
    contentContainer.appendChild(applyButton);
    colorChangerPopup.appendChild(contentContainer);

    document.body.appendChild(colorChangerPopup);

    function applyBackgroundColor(color) {
        document.body.style.backgroundColor = color;

        const header = document.querySelector('#header');
        if (header) {
            header.style.backgroundColor = color;
        }

        const footerTop = document.querySelector('#footer .top');
        if (footerTop) {
            footerTop.style.backgroundColor = color;
        }
    }

    function applyTextColor(color) {
        const elements = document.querySelectorAll('body *:not(button)');
        elements.forEach((element) => {
            element.style.color = color;
        });

    }
})();