HitomiMosaic

Hitomi thumbnail mosaic

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        HitomiMosaic
// @namespace   HitomiMosaic
// @license     Apache 2.0
// @match       *://hitomi.la/*
// @exclude     *://hitomi.la/reader/*
// @version     1.1.0
// @author      ombe1229
// @description Hitomi thumbnail mosaic
// @run-at      document-end
// @require     https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_addStyle
// ==/UserScript==


initConfigBtn();
(new MutationObserver(mosaic).observe(document, { childList: true, subtree: true }));


function mosaic(changes, observer) {
    let containerList;
    if ((containerList = document.querySelectorAll("div.gallery-content > .manga, .acg, .dj, .cg")).length > 0) {
        observer.disconnect();

        let tagList = GM_config.get("tagList").split(/,\s+|,/)
        containerList.forEach(function (element) {
            let tagContainer = element.querySelector(".relatedtags");
            let tags = [...tagContainer.querySelectorAll("li")].map(tag => tag.innerText);
            if (tags.some(tag => tagList.includes(tag.toLowerCase().replace(/\s(♀|♂)/g, "")))) {
                element.querySelector(".dj-img-cont").remove();
            }
        });
    }
};

function initConfigBtn() {
    GM_config.init({
        "id": "HitomiMosaicConfig",
        "title": "Hitomi Mosaic Config",
        "fields":
        {
            "tagList":
            {
                "label": "Tag list to block",
                "type": "textarea",
                "default": "scat, guro, amputee, snuff, yaoi, males only, pig, insect, toddler",
            },
        },
    });

    const configNode = document.createElement("div");
    configNode.innerHTML = "<button id='configBtn' type='button'>HitomiMosaic Config</button>";
    document.body.appendChild(configNode);
}


document.getElementById("configBtn").addEventListener(
    "click", () => {
        GM_config.open();
    }, false
);


GM_addStyle(`
    #configBtn {
        position: fixed;
        top: 1rem;
        left: 1rem;
    }
`);