5ch_thumb_view

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

目前為 2019-01-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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     0.4
// @require     http://code.jquery.com/jquery-3.2.1.min.js
// @grant       none
// @description 5ちゃんねるの画像をサムネイル表示する。
// ==/UserScript==

console.log("5ch_thumb_view start");


function main() {
    $("a").each( function() {
		var thiselem = $(this);

        var str = $(this).text();

        if ( $(this).attr("myloaded") === "done" ) {
            return;
        }
        $(this).attr("myloaded", "done");


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


		/* 二つhttps化したところで焼け石に水だった。ブラウザ上部をsecure状態にするにはコンテンツ全て100%のhttps化が必要。
		// https優先
		str = str.replace( /http:\/\/i\.imgur\.com\//, "https://i.imgur.com/");
		str = str.replace( /http:\/\/pbs\.twimg\.com\/media\//, "http://pbs.twimg.com/media/");
		*/
		//str = str.replace( /http:\/\//, "https:\/\/");


		var link2img = $("<a/>", {
			href: str,
			// 別タブか、同一タブかは好みが分かれるので、保留。
			// →別ドメインのリンクは別タブで開くのが普通なので、_blank化。
			target: '_blank',
			myloaded: 'done'
		});
		var elem_p = $("<p/>");
		var img = $("<img />", {
			src: str,
			border: '1px',
			width: '100px'
		});


		thiselem.after(elem_p);
		elem_p.after(link2img);
		link2img.append(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);