需下载油猴插件,网上有教程,之后点击“添加新脚本”,把代码复制进去,再按ctrl+s保存。

豆包写的,对浏览器和电脑没有伤害。

// ==UserScript==
// @name         隐藏小天智能助教
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  隐藏 https://xwjedu.cn/ 页面的小天智能助教悬浮组件
// @author       You
// @match        https://xwjedu.cn/*
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // 方式1:CSS 直接永久隐藏(页面加载前生效,最优)
    GM_addStyle(`
        section.xiaotian[data-xiaotian-root] {
            display: none !important;
            visibility: hidden !important;
            opacity: 0 !important;
            width: 0 !important;
            height: 0 !important;
            pointer-events: none !important;
        }
    `);

    // 方式2:动态删除DOM(应对页面异步延迟渲染的情况)
    function removeXiaotian() {
        const el = document.querySelector('section.xiaotian[data-xiaotian-root]');
        if (el) el.remove();
    }

    // 页面加载完成执行一次
    window.addEventListener('DOMContentLoaded', removeXiaotian);
    // 监听页面DOM变化,防止动态重新渲染出来
    const observer = new MutationObserver(() => {
        removeXiaotian();
    });
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

})();

3 条评论

  • 1