Hide Individual Thumbnails (Persistent)

Dodaje przycisk przy każdej miniaturce, żeby ją ukryć i zapamiętuje stan między odświeżeniami

Verze ze dne 04. 12. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Hide Individual Thumbnails (Persistent)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Dodaje przycisk przy każdej miniaturce, żeby ją ukryć i zapamiętuje stan między odświeżeniami
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const STORAGE_KEY = 'hiddenThumbs';

    // Pobranie listy ukrytych miniatur z localStorage
    let hiddenThumbs = JSON.parse(localStorage.getItem(STORAGE_KEY) || '{}');

    // Funkcja dodająca przycisk do miniaturki
    const addHideButton = (thumb) => {
        // Pobranie unikalnego ID dla miniaturki (jeśli nie ma, dodajemy)
        if (!thumb.dataset.thumbId) {
            thumb.dataset.thumbId = 'thumb-' + Math.random().toString(36).substr(2, 9);
        }
        const thumbId = thumb.dataset.thumbId;

        // Tworzymy przycisk
        const button = document.createElement('button');
        button.textContent = hiddenThumbs[thumbId] ? 'Pokaż' : 'Ukryj';
        button.style.position = 'absolute';
        button.style.top = '0';
        button.style.right = '0';
        button.style.zIndex = 1000;
        button.style.padding = '5px 10px';
        button.style.backgroundColor = '#000';
        button.style.color = '#fff';
        button.style.border = 'none';
        button.style.borderRadius = '3px';
        button.style.cursor = 'pointer';
        button.style.fontSize = '13px';

        // Dodajemy przycisk do miniaturki
        thumb.style.position = 'relative';
        thumb.appendChild(button);

        // Ustaw stan ukrycia
        if (hiddenThumbs[thumbId]) {
            thumb.style.display = 'none';
        }

        // Obsługa kliknięcia
        button.addEventListener('click', (e) => {
            e.stopPropagation();
            if (thumb.style.display === 'none') {
                thumb.style.display = '';
                button.textContent = 'Ukryj';
                delete hiddenThumbs[thumbId];
            } else {
                thumb.style.display = 'none';
                button.textContent = 'Pokaż';
                hiddenThumbs[thumbId] = true;
            }
            localStorage.setItem(STORAGE_KEY, JSON.stringify(hiddenThumbs));
        });
    };

    // Dodaj przyciski do wszystkich istniejących miniatur
    document.querySelectorAll('.mozaique .thumb-block').forEach(addHideButton);

    // Obsługa dynamicznie dodawanych miniatur (np. lazy load)
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.nodeType === 1 && node.matches('.mozaique .thumb-block')) {
                    addHideButton(node);
                }
            });
        });
    });

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