XNXX - Hide Videos Button

Dodaje przycisk ukrywania filmów na miniaturkach

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         XNXX - Hide Videos Button
// @namespace    https://xnxx.com/
// @version      1.0
// @description  Dodaje przycisk ukrywania filmów na miniaturkach
// @match        https://www.xnxx.com/*
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';

    const STORAGE_KEY = 'xh-hidden-videos';

    // Wczytaj ukryte filmy
    const hiddenVideos = new Set(
        JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]')
    );

    // Style
    GM_addStyle(`
        .thumb-block {
            position: relative;
        }

        .xh-hide-btn {
            position: absolute;
            top: 6px;
            right: 6px;
            z-index: 9999;
            background: rgba(0,0,0,0.75);
            color: white;
            border: none;
            border-radius: 4px;
            padding: 4px 7px;
            cursor: pointer;
            font-size: 12px;
            line-height: 1;
            transition: 0.2s;
        }

        .xh-hide-btn:hover {
            background: rgba(255,0,0,0.9);
        }

        .xh-hidden {
            display: none !important;
        }
    `);

    function saveHiddenVideos() {
        localStorage.setItem(
            STORAGE_KEY,
            JSON.stringify([...hiddenVideos])
        );
    }

    function getVideoId(link) {
        try {
            return new URL(link.href).pathname;
        } catch {
            return link.href;
        }
    }

    function processThumbs() {
        document.querySelectorAll('.thumb-block').forEach(block => {

            if (block.querySelector('.xh-hide-btn')) return;

            const link = block.querySelector('.thumb a');
            if (!link) return;

            const videoId = getVideoId(link);

            // Ukryj jeśli już zapisany
            if (hiddenVideos.has(videoId)) {
                block.classList.add('xh-hidden');
            }

            const btn = document.createElement('button');
            btn.className = 'xh-hide-btn';
            btn.textContent = '✕';

            btn.addEventListener('click', (e) => {
                e.preventDefault();
                e.stopPropagation();

                hiddenVideos.add(videoId);
                saveHiddenVideos();

                block.classList.add('xh-hidden');
            });

            block.appendChild(btn);
        });
    }

    // Start
    processThumbs();

    // Obsługa dynamicznego ładowania
    const observer = new MutationObserver(() => {
        processThumbs();
    });

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

})();