XNXX - Hide Videos Button

Dodaje przycisk ukrywania filmów na miniaturkach

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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

})();