Hide Individual Thumbnails (Persistent)

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

Από την 04/12/2025. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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