Fandom: Cut the Crap

Zero distractions. Pure wiki.

// ==UserScript==
// @name         Fandom: Cut the Crap
// @version      1.2.1
// @description  Zero distractions. Pure wiki.
// @author       samerop
// @match        *://*.fandom.com/*
// @grant        none
// @license      MIT
// @run-at       document-start
// @namespace https://gf.qytechs.cn/users/1426714
// ==/UserScript==

(function() {
    'use strict';

    const selectorsToRemove = [
        "#age-gate",
        "body > div.main-container > div.resizable-container > div.page.has-right-rail > aside",
        "#global-explore-navigation",
        "body > div.main-container > footer",
        "#global-top-navigation",
        "body > div.notifications-placeholder",
        "#WikiaBar",
        "body > div.main-container > div.resizable-container > div.page.has-right-rail > main > div.page-side-tools__wrapper",
        "body > div.main-container > div.resizable-container > div.community-header-wrapper > header > div > div.page-counter",
        "body > div.main-container > div.resizable-container > div.community-header-wrapper > header > div > div.wiki-tools.wds-button-group",
        "body > div.main-container > div.resizable-container > div.page.has-right-rail > main > div.page-footer > div.license-description",
        "body > div.main-container > div.top-ads-container",
        "body > div.main-container > div.resizable-container > div.bottom-ads-container",
        "#top_boxad",
        "#p-views",
        "#mw-data-after-content",
        "body > div.main-container > div.resizable-container > div.page > main > div.page-side-tools__wrapper > div"
    ];

    function removeClutter() {
        selectorsToRemove.forEach(selector => {
            const elements = document.querySelectorAll(selector);
            elements.forEach(el => {
                if (el && el.parentNode) {
                    el.remove();
                }
            });
        });
    }

    const observer = new MutationObserver((mutationsList) => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                removeClutter();
                return;
            }
        }
    });

    const css = selectorsToRemove.join(',\n') + ' { display: none !important; }';
    const style = document.createElement('style');
    style.type = 'text/css';
    style.id = 'fandom-cleaner-styles-minimal';
    style.textContent = css;
    (document.head || document.documentElement).appendChild(style);

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', removeClutter, { once: true });
    } else {
        removeClutter();
    }

    const config = { childList: true, subtree: true };

    const startObserving = () => {
        if (document.body) {
            observer.observe(document.body, config);
        } else {
             window.addEventListener('DOMContentLoaded', () => {
                 if(document.body) observer.observe(document.body, config);
             }, { once: true });
        }
    };

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', startObserving, { once: true });
    } else {
        startObserving();
    }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址