Raid Card Filter UI

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

Verzia zo dňa 05.03.2025. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==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 });
})();