Greasy Fork

Greasy Fork is available in English.

5ch_thumb_view

5ちゃんねるの画像をサムネイル表示する。

当前为 2019-03-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        5ch_thumb_view
// @namespace   http://catherine.v0cyc1pp.com/5ch_thumb_view.user.js
// @include     http://*.5ch.net/*
// @include     https://*.5ch.net/*
// @include     http://*.bbspink.com/*
// @include     https://*.bbspink.com/*
// @author      greg10
// @run-at      document-end
// @license     GPL 3.0
// @version     2.0
// @grant       none
// @description 5ちゃんねるの画像をサムネイル表示する。
// ==/UserScript==
console.log("5ch_thumb_view start");


function main() {
    document.querySelectorAll("a").forEach(function(elem) {
        var thiselem = elem;

        var str = elem.innerText;

        if (elem.getAttribute("myloaded_5tv") == "done") {
            return;
        }
        elem.setAttribute("myloaded_5tv", "done");


        var result = str.match(/(\/\/.*(.jpg|.jpeg|.png|.gif|.bmp|.webp|.jpg:orig))$/i);
        if (result == null) {
            return;
        }
        console.log("image matched, str=" + str);

        var link2img = document.createElement("a");
        link2img.href = str;
        link2img.target = "_blank";
        link2img.myloaded_5tv = "done";
        var elem_p = document.createElement("p");
        var img = document.createElement("img");
        img.src = str;
        img.border = "1px";
        img.width = "100";


        thiselem.parentNode.insertBefore(elem_p, thiselem.nextElementSibling);
        elem_p.parentNode.insertBefore(link2img, elem_p.nextElementSibling);
        link2img.appendChild(img);


    });
}

main();

var observer = new MutationObserver(function(mutations) {
    observer.disconnect();
    main();
    observer.observe(document, config);
});

var config = {
    attributes: false,
    childList: true,
    characterData: false,
    subtree: true
};

observer.observe(document, config);