F95Zone Hide Low Rated Games

Hide low-rated games on F95Zone.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         F95Zone Hide Low Rated Games
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  Hide low-rated games on F95Zone.
// @author       mty
// @match        https://f95zone.to/*
// @grant        none
// @run-at       document-idle
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let ratingThreshold = 3.5;

    function updateGameVisibility() {
        document.querySelectorAll('.resource-tile').forEach(tile => {
            const ratingElem = tile.querySelector('.resource-tile_info-meta_rating');
            if (ratingElem) {
                const rating = parseFloat(ratingElem.textContent.trim());
                tile.style.display = (!isNaN(rating) && rating < ratingThreshold) ? 'none' : '';
            }
        });
    }

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

    function insertRatingThresholdBlock() {
        if (document.getElementById('filter-block_rating-threshold')) return;
        const dateSlider = document.getElementById('filter-block_date-filter');
        if (!dateSlider) return;

        const block = document.createElement('div');
        block.id = 'filter-block_rating-threshold';
        block.className = 'range-slider_wrap filter-block';
        block.innerHTML = `
            <h4 class="filter-block_title">Rating Threshold</h4>
            <div id="filter-rating_value" class="range-slider_value">${ratingThreshold.toFixed(1)}</div>
            <div id="filter-rating" class="range-slider_bar noUi-target noUi-horizontal"></div>
        `;
        dateSlider.insertAdjacentElement('afterend', block);

        initRatingSlider();
    }

    function initRatingSlider() {
        const sliderElem = document.getElementById('filter-rating');
        if (!sliderElem || sliderElem.noUiSlider || typeof window.noUiSlider === 'undefined') return;

        window.noUiSlider.create(sliderElem, {
            start: [ratingThreshold],
            connect: [true, false],
            range: { min: 0, max: 5 },
            step: 0.1,
            format: {
                to: value => parseFloat(value).toFixed(1),
                from: value => parseFloat(value)
            }
        });

        sliderElem.noUiSlider.on('update', values => {
            ratingThreshold = parseFloat(values[0]);
            document.getElementById('filter-rating_value').textContent = ratingThreshold.toFixed(1);
            updateGameVisibility();
        });
    }

    function initScript() {
        insertRatingThresholdBlock();
        updateGameVisibility();
    }

    setInterval(initScript, 100);

})();