HitomiMosaic

Hitomi thumbnail mosaic

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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;
    }
`);