// ==UserScript==
// @name         CivitAI Auto Show NSFW (for Mantine button span)
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Automatically clicks "Show" buttons on CivitAI NSFW content
// @match        https://civitai.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function clickShowButtons() {
        const showSpans = document.querySelectorAll('span.mantine-Button-label');

        showSpans.forEach(span => {
            if (span.textContent.trim().toLowerCase() === "show") {
                const button = span.closest('button');
                if (button) {
                    button.click();
                }
            }
        });
    }

    // 初回ロード時に一度実行
    clickShowButtons();

    // 動的読み込みに対応するために MutationObserver を使用
    const observer = new MutationObserver(() => {
        clickShowButtons();
    });

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