Torn Crime Scenario Filter with Level

Adds filters to show/hide whole crime scenario cards by level on Torn's faction crimes page with persistent settings and position

目前為 2025-02-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Torn Crime Scenario Filter with Level
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Adds filters to show/hide whole crime scenario cards by level on Torn's faction crimes page with persistent settings and position
// @match        https://www.torn.com/factions.php*
// @grant        none
// @license MIT
// ==/UserScript==

/* Previous code remains the same until the updateFilters function */

// Only showing the modified updateFilters function for clarity
function updateFilters() {
    const showCheckbox = document.getElementById('crimeFilterCheckbox');
    const levelInput = document.getElementById('minCrimeLevelInput');
    const shouldApplyFilter = showCheckbox.checked;
    const minLevel = parseInt(levelInput.value, 10) || 1;

    // Save filter settings
    saveSettings({
        show: shouldApplyFilter,
        level: minLevel
    });

    // Update status text
    const statusEl = document.getElementById('filterStatus');
    let visibleCount = 0;
    let totalCount = 0;

    document.querySelectorAll('.wrapper___U2Ap7').forEach(card => {
        const levelEl = card.querySelector('.level___sBl49');
        totalCount++;
        
        if (!shouldApplyFilter) {
            // Show all cards when filter is disabled
            card.style.display = '';
            visibleCount++;
        } else if (levelEl) {
            // Apply level filter only when filter is enabled
            const text = levelEl.textContent.trim();
            const parts = text.split('/');
            const level = parseInt(parts[0], 10) || 0;

            if (level >= minLevel) {
                card.style.display = '';
                visibleCount++;
            } else {
                card.style.display = 'none';
            }
        } else {
            // For cards without level info, show them when filter is enabled
            card.style.display = '';
            visibleCount++;
        }
    });

    // Update status text with more descriptive message
    if (!shouldApplyFilter) {
        statusEl.textContent = `Showing all ${totalCount} crimes (filter disabled)`;
    } else {
        statusEl.textContent = `Showing ${visibleCount} of ${totalCount} crimes (min level: ${minLevel})`;
    }
}

/* Rest of the code remains the same */

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址