MRM Content Blocker

Blocks content in MyReadingManga

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MRM Content Blocker
// @namespace    r.arvie
// @version      1.5
// @description  Blocks content in MyReadingManga
// @match        https://myreadingmanga.info/*
// @grant        GM_getValue
// @grant        GM_setValue
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let blockedClasses = GM_getValue('blockedClasses', []);
if (!blockedClasses.includes('tag-ai-generate')) {
    blockedClasses.push('tag-ai-generate');
    GM_setValue('blockedClasses', blockedClasses);
}
    function hideArticles() {
        document.querySelectorAll('article').forEach(article => {
            const articleClasses = article.className.split(/\s+/);
            if (articleClasses.some(cls => blockedClasses.includes(cls))) {
                article.style.display = 'none';
            } else {
                article.style.display = '';
            }
        });
    }

    hideArticles();

    const classSet = {
        tag: new Set(),
        lang: new Set(),
        genre: new Set(),
        artist: new Set()
    };

    document.querySelectorAll('article').forEach(article => {
        article.className.split(/\s+/).forEach(cls => {
            if (cls.startsWith('tag-')) classSet.tag.add(cls);
            else if (cls.startsWith('lang-')) classSet.lang.add(cls);
            else if (cls.startsWith('genre-')) classSet.genre.add(cls);
            else if (cls.startsWith('artist-')) classSet.artist.add(cls);
        });
    });


    const mergedTags = Array.from(new Set([...classSet.tag, ...blockedClasses.filter(c => c.startsWith('tag-'))])).sort();
    const mergedLangs = Array.from(new Set([...classSet.lang, ...blockedClasses.filter(c => c.startsWith('lang-'))])).sort();
    const mergedGenres = Array.from(new Set([...classSet.genre, ...blockedClasses.filter(c => c.startsWith('genre-'))])).sort();
    const mergedArtists = Array.from(new Set([...classSet.artist, ...blockedClasses.filter(c => c.startsWith('artist-'))])).sort();

    const footerText = Array.from(document.body.querySelectorAll('p, div'))
        .find(el => el.textContent.includes("MyReadingManga is free"));

    if (footerText) {
        const container = document.createElement('div');
        container.style.marginTop = "10px";
        container.style.fontSize = "12px";
        container.style.background = "#333";
        container.style.color = "#fff";
        container.style.padding = "8px";
        container.style.borderRadius = "5px";

        function createCategory(name, items) {
            const wrapper = document.createElement('div');
            wrapper.style.marginBottom = "5px";

            const header = document.createElement('b');
            header.style.cursor = "pointer";
            header.style.display = "flex";
            header.style.alignItems = "center";
            header.style.userSelect = "none";
            header.style.color = "#4da6ff";

            const icon = document.createElement('span');
            icon.textContent = "▶";
            icon.style.marginRight = "5px";
            header.appendChild(icon);
            header.appendChild(document.createTextNode(name));

            const list = document.createElement('div');
            list.style.marginTop = "3px";
            list.style.display = "none";

            items.forEach(item => {
                const label = document.createElement('label');
                label.style.display = "block";
                label.style.color = "#fff";
                const checkbox = document.createElement('input');
                checkbox.type = "checkbox";
                checkbox.value = item;
                if (blockedClasses.includes(item)) checkbox.checked = true;

                checkbox.onchange = () => {
                    if (checkbox.checked) {
                        if (!blockedClasses.includes(item)) blockedClasses.push(item);
                    } else {
                        blockedClasses = blockedClasses.filter(cls => cls !== item);
                    }
                    GM_setValue('blockedClasses', blockedClasses);
                    hideArticles();
                };

                label.appendChild(checkbox);
                label.appendChild(document.createTextNode(' ' + item));
                list.appendChild(label);
            });

            header.onclick = () => {
                if (list.style.display === "none") {
                    list.style.display = "block";
                    icon.textContent = "▼";
                } else {
                    list.style.display = "none";
                    icon.textContent = "▶";
                }
            };

            wrapper.appendChild(header);
            wrapper.appendChild(list);
            return wrapper;
        }

        const title = document.createElement('div');
        title.textContent = "MRM Content Blocker";
        title.style.fontWeight = "bold";
        title.style.fontSize = "14px";
        title.style.marginBottom = "8px";
        title.style.textAlign = "center";
        title.style.color = "#4da6ff";
        container.appendChild(title);

        container.appendChild(createCategory("Genres", mergedGenres));
        container.appendChild(createCategory("Languages", mergedLangs));
        container.appendChild(createCategory("Tags", mergedTags));
        container.appendChild(createCategory("Artists", mergedArtists));

        footerText.appendChild(container);
    }

})();