Greasy Fork is available in English.

Fuck live2d widget

屏蔽 live2d 看板娘

// ==UserScript==
// @name         Fuck live2d widget
// @namespace    https://chat.openai.com/?model=gpt-4
// @version      0.2
// @description  屏蔽 live2d 看板娘
// @author       GPT-4
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function showToast(message, duration) {
        const toast = document.createElement('div');
        toast.style.position = 'fixed';
        toast.style.bottom = '20px';
        toast.style.left = '50%';
        toast.style.transform = 'translateX(-50%)';
        toast.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
        toast.style.color = 'white';
        toast.style.padding = '10px 20px';
        toast.style.borderRadius = '5px';
        toast.style.zIndex = '9999';
        toast.style.fontFamily = 'sans-serif';
        toast.style.fontSize = '14px';
        toast.style.display = 'none';

        toast.textContent = message;
        document.body.appendChild(toast);

        toast.style.display = 'block';
        setTimeout(() => {
            toast.style.display = 'none';
            document.body.removeChild(toast);
        }, duration);
    }

    function blockLive2DWidget() {
        const elementIds = ['live2d-widget', 'player-container', 'L2dCanvas'];
        let blocked = false;

        for (const id of elementIds) {
            const element = document.getElementById(id);
            if (element) {
                element.style.display = 'none';
                blocked = true;
            }
        }

        if (blocked) {
            showToast('live2d widget killed.', 3000);
        }
    }

    // 屏蔽元素
    blockLive2DWidget();

    // 如果网站使用动态加载内容,可以使用 MutationObserver 检测新元素并屏蔽
    const observer = new MutationObserver(blockLive2DWidget);
    observer.observe(document.body, { childList: true, subtree: true });
})();