Raid Card Filter UI

Adds a UI to hide specific raid cards by name and difficulty.

Verze ze dne 05. 03. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Raid Card Filter UI
// @namespace    https://greasyfork.org/users/1159361
// @version      1.2
// @license MIT
// @description  Adds a UI to hide specific raid cards by name and difficulty.
// @author       Zaregoto_Gaming
// @match        https://play.dragonsofthevoid.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const raidNames = [
        "Lesser Tree Ent", "Superior Watcher", "Elven Rangers", "Greater Ent", "Sand Wyrm",
        "Corrupted Golem", "Naga Risaldar", "Galeohog", "Naga Karamati", "Jagar the Red",
        "Rotting Fen Lure", "Sentry Ghoul", "Fallen Naga Subedar", "Bone Dragon"
    ];
    const difficulties = ["easy", "hard", "legendary"];

    function loadSettings() {
        return JSON.parse(localStorage.getItem('raidFilterSettings')) || { enabled: true };
    }

    function saveSettings(settings) {
        localStorage.setItem('raidFilterSettings', JSON.stringify(settings));
    }

    function removeRaidCards() {
        const settings = loadSettings();
        if (!settings.enabled) return;
        document.querySelectorAll(".raid-card-container").forEach(card => {
            const header = card.querySelector(".raid-card-header");
            if (!header) return;
            const name = header.textContent.trim();
            const difficulty = header.className.match(/font-(\w+)/)?.[1];
            if (settings[name] && settings[name].length > 0 && settings[name].includes(difficulty)) {
                card.remove();
            }
        });
    }

    function createUI() {
        const settings = loadSettings();
        const ui = document.createElement("div");
        ui.style.position = "fixed";
        ui.style.top = "10px";
        ui.style.right = "10px";
        ui.style.background = "white";
        ui.style.padding = "10px";
        ui.style.border = "1px solid black";
        ui.style.zIndex = "1000";
        ui.style.maxHeight = "400px";
        ui.style.overflowY = "auto";

        ui.innerHTML = `<strong>Raid Filter</strong><br>`;

        const masterCheckbox = document.createElement("input");
        masterCheckbox.type = "checkbox";
        masterCheckbox.checked = settings.enabled !== false;
        masterCheckbox.onchange = () => {
            settings.enabled = masterCheckbox.checked;
            saveSettings(settings);
            removeRaidCards();
        };
        ui.appendChild(masterCheckbox);
        ui.appendChild(document.createTextNode(" Enable Filtering"));
        ui.appendChild(document.createElement("hr"));

        raidNames.forEach(name => {
            const nameLabel = document.createElement("div");
            nameLabel.textContent = name;
            nameLabel.style.fontWeight = "bold";
            ui.appendChild(nameLabel);

            difficulties.forEach(diff => {
                const checkbox = document.createElement("input");
                checkbox.type = "checkbox";
                checkbox.checked = settings[name]?.includes(diff) || false;
                checkbox.onchange = () => {
                    if (!settings[name]) settings[name] = [];
                    if (checkbox.checked) {
                        settings[name].push(diff);
                    } else {
                        settings[name] = settings[name].filter(d => d !== diff);
                    }
                    saveSettings(settings);
                    removeRaidCards();
                };
                ui.appendChild(checkbox);
                ui.appendChild(document.createTextNode(diff.charAt(0).toUpperCase() + diff.slice(1)));
                ui.appendChild(document.createElement("br"));
            });
            ui.appendChild(document.createElement("hr"));
        });

        document.body.appendChild(ui);
    }

    function addToggleButton() {
        const button = document.createElement("button");
        button.textContent = "⚙️ Raid Filter";
        button.style.position = "fixed";
        button.style.top = "10px";
        button.style.right = "120px";
        button.style.zIndex = "1001";
        button.onclick = () => {
            const ui = document.querySelector("div[style*='fixed'][style*='white']");
            if (ui) {
                ui.remove();
            } else {
                createUI();
            }
        };
        document.body.appendChild(button);
    }

    addToggleButton();
    removeRaidCards();

    const observer = new MutationObserver(removeRaidCards);
    observer.observe(document.body, { childList: true, subtree: true });
})();