Shunga Thumbnail Unmask

Like general illusts unhides shunga thumbnails on Niconico Seiga search results.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

/**
 * @license
 * Copyright (C) 2024 nonoji fukushima.
 * https://greasyfork.org/users/305181-nonoji-fukushima
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at https://mozilla.org/MPL/2.0/.
 */

// ==UserScript==
// @name Shunga Thumbnail Unmask
// @name:ja Shunga Thumbnail Unmask「春画のサムネイルを隠さず表示」
// @namespace https://greasyfork.org/users/305181-nonoji-fukushima
// @version 0.2.2+20241002
// @description Like general illusts unhides shunga thumbnails on Niconico Seiga search results.
// @description:ja ニコニコ静画の検索結果で春画を一般イラスト同様に中身の見えるサムネイルにします。
// @author nonoji fukushima
// @license Mozilla Public License 2.0
// @contributionURL bitcoin:1EirWMuwt4PQwCYxsTafRFGJG5DxQt6cCV
// @contributionAmount 0.0001 BTC
// @grant none
// @match *://seiga.nicovideo.jp/seiga/*
// @match *://seiga.nicovideo.jp/tag/*?*target=illust_all*
// @match *://seiga.nicovideo.jp/user/illust/*?*target=illust_all*
// @run-at document-end
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    "use strict";

    {
        const illustListElem = document.querySelector(".illust_list");
        if (!illustListElem) {
            return;
        }
        [].forEach.call(illustListElem.children, replaceThumbs);
        // handle autopagers
        new MutationObserver(mutations => mutations.forEach(mut =>
            mut.addedNodes.forEach(replaceThumbs)
        )).observe(illustListElem, { childList: true });
    }
    return;

    function replaceThumbs(/** @type {!Element} */ elem) {
        elem.querySelectorAll(".thum img").forEach(imgElem => {
            if (imgElem.naturalWidth === imgElem.naturalHeight) {
                imgElem.src = imgElem.src.replace(/(\/thumb\/[0-9]+[a-z])z/, "$1");
            }
        });
    }
})();