XNXX - Hide Videos Button

Dodaje przycisk ukrywania filmów na miniaturkach

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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

})();