Raid Card Filter UI

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

Устаревшая версия за 05.03.2025. Перейдите к последней версии.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

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