::Steam Search: Hide Games Under Minimum Price::

Hides games priced below $5.00 on Steam's search page by default. (Can be personalized)

// ==UserScript==
// @name         ::Steam Search: Hide Games Under Minimum Price::
// @namespace    masterofobzene-Hide Games Under Minimum Price
// @version      1.4
// @description  Hides games priced below $5.00 on Steam's search page by default. (Can be personalized)
// @author       masterofobzene
// @icon         https://store.steampowered.com/favicon.ico
// @match        https://store.steampowered.com/search*
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let minPrice = 5.00;
    let enablePriceFilter = true;
    let hideMixedNegative = false;
    let hideNoRating = false;

    function createToggleUI() {
        const insertAfter = document.querySelector('#narrow_category1');
        if (!insertAfter) {
            console.warn('Could not find #narrow_category1 to insert filters.');
            return;
        }

        const container = document.createElement('div');
        container.className = 'additional_filters_ctn';
        container.style.padding = '10px';
        container.style.marginTop = '10px';
        container.style.backgroundColor = '#2a475e';
        container.style.border = '1px solid #66c0f4';
        container.style.color = '#c6d4df';
        container.style.fontSize = '13px';

        container.innerHTML = `
            <div style="margin-bottom: 6px;"><strong>🧹 Custom Filter</strong></div>

            <label style="display: block; margin-bottom: 6px;">
                <input type="checkbox" id="enablePriceFilter" checked> Enable Price Filter
            </label>
            <label style="display: block; margin-bottom: 4px;">
                Min Price: $<span id="priceValue">${minPrice.toFixed(2)}</span><br>
                <input type="range" id="priceSlider" min="0" max="60" step="0.5" value="${minPrice}" style="width: 100%;">
            </label>

            <hr style="margin: 10px 0; border-color: #66c0f4;">

            <label style="display: block; margin-bottom: 4px;">
                <input type="checkbox" id="hideMixedNegative"> Hide Mixed/Negative
            </label>
            <label style="display: block;">
                <input type="checkbox" id="hideNoRating"> Hide No Rating
            </label>
        `;

        insertAfter.parentNode.insertBefore(container, insertAfter.nextSibling);

        document.getElementById('enablePriceFilter').addEventListener('change', e => {
            enablePriceFilter = e.target.checked;
            console.log('Enable Price Filter:', enablePriceFilter);
            hideLowPriceGames();
        });

        document.getElementById('priceSlider').addEventListener('input', e => {
            minPrice = parseFloat(e.target.value);
            document.getElementById('priceValue').textContent = minPrice.toFixed(2);
            hideLowPriceGames();
        });

        document.getElementById('hideMixedNegative').addEventListener('change', e => {
            hideMixedNegative = e.target.checked;
            console.log('Hide Mixed/Negative:', hideMixedNegative);
            hideLowPriceGames();
        });

        document.getElementById('hideNoRating').addEventListener('change', e => {
            hideNoRating = e.target.checked;
            console.log('Hide No Rating:', hideNoRating);
            hideLowPriceGames();
        });
    }

    function hideLowPriceGames() {
        const rows = document.querySelectorAll('.search_result_row');
        rows.forEach(row => {
            let shouldHide = false;

            const priceElement = row.querySelector('.discount_final_price');
            if (!priceElement) return;

            const priceText = priceElement.textContent.trim();
            if (/free/i.test(priceText)) {
                shouldHide = enablePriceFilter;
            } else {
                const priceMatch = priceText.match(/\$(\d+\.\d{2})/);
                if (priceMatch && enablePriceFilter) {
                    const price = parseFloat(priceMatch[1]);
                    if (price < minPrice) shouldHide = true;
                }
            }

            const reviewElement = row.querySelector('.search_review_summary');
            const hasRating = !!reviewElement;
            const ratingClass = reviewElement?.classList?.[1];

            if (hideNoRating && !hasRating) {
                shouldHide = true;
            }

            if (hideMixedNegative && (ratingClass === 'mixed' || ratingClass === 'negative')) {
                shouldHide = true;
            }

            row.style.display = shouldHide ? 'none' : '';
        });
    }

    function setupObserver() {
        const resultsContainer = document.getElementById('search_resultsRows');
        if (!resultsContainer) return;

        const observer = new MutationObserver(() => {
            hideLowPriceGames();
        });

        observer.observe(resultsContainer, {
            childList: true,
            subtree: true
        });
    }

    function waitForSidebarAndInit() {
        const checkInterval = setInterval(() => {
            const anchor = document.querySelector('#narrow_category1');
            if (anchor) {
                clearInterval(checkInterval);
                createToggleUI();
                hideLowPriceGames();
                setupObserver();
            }
        }, 300);
    }

    waitForSidebarAndInit();
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元