去掉萌娘百科的背景喵~

去掉萌娘百科的背景

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         去掉萌娘百科的背景喵~
// @namespace    https://blockydeer.me/
// @version      2025-07-24
// @description  去掉萌娘百科的背景
// @author       BlockyDeer
// @match        *://zh.moegirl.org.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=moegirl.org.cn
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let attempts = 0;
    const max_attempts = 10;
    let counter = 0;

    let selector_to_delete = new Array();
    selector_to_delete.push("#moe-global-background");

    function delete_element() {
        selector_to_delete.forEach(function (item) {
            const element = document.querySelector(item);
            if (element) {
                element.remove();
                console.log(`Removed selector to ${item}`);
                counter++;
            }
        });
        return counter == selector_to_delete.length;
    }

    if (delete_element()) return;
    const observer = new MutationObserver(function() {
        attempts++;
        if (delete_element() || attempts >= max_attempts) {
            observer.disconnect();
            if (attempts >= max_attempts) {
                console.warn("Reaches attempting trying limitation. Dismatch elements.");
            }
        }
    });

    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    setTimeout(() => {
        observer.disconnect();
        console.warn("Observer timeout!");
    }, 10000);
})();