うんはらバスター

おんjで画像を表示するか逐一確認!

// ==UserScript==
// @name         うんはらバスター
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  おんjで画像を表示するか逐一確認!
// @author       icchi
// @match        *://hayabusa.open2ch.net/test/read.cgi/livejupiter/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function checkImages() {
        document.querySelectorAll('img').forEach(img => {
            if (img.src.includes("imgur.com") && !img.dataset.checked) { // imgur画像で未処理のもの
                img.dataset.checked = "true"; // 重複処理防止
                img.style.display = "none"; // 画像を非表示
                let btn = document.createElement("button");
                btn.textContent = "画像を表示する";
                btn.style.margin = "5px";
                btn.onclick = function() {
                    img.style.display = "block"; // 画像を表示
                    btn.remove(); // ボタン削除
                };
                img.insertAdjacentElement("beforebegin", btn);
            }
        });
    }

    // 初回実行
    checkImages();

    // ページの変更を監視(新しく読み込まれた画像にも対応)
    let observer = new MutationObserver(checkImages);
    observer.observe(document.body, { childList: true, subtree: true });
})();