防覆盖

避免 content-wrapper 被覆盖

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         防覆盖
// @namespace    https://yffjglcms.com/
// @version      1.0
// @description  避免 content-wrapper 被覆盖
// @match        https://doc.iocoder.cn/*
// @grant        none
// @run-at       document-start
// @run-at       document-body
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 保存原始的 jQuery.html 方法
    const originalHtml = $.fn.html;

    // 重写 jQuery.html 方法
    $.fn.html = function(content) {
        if (this.hasClass("content-wrapper")) {
            console.log("拦截了对 .content-wrapper 的修改:", content);
            return this; // 阻止修改
        }
        return originalHtml.apply(this, arguments);
    };

    // 拦截 setTimeout,阻止指定的代码执行
    const originalSetTimeout = setTimeout;
    window.setTimeout = function(callback, delay) {
        const callbackStr = callback.toString();
        if (callbackStr.includes('$(".content-wrapper").html')) {
            console.log("拦截了 setTimeout 中的修改操作:", callbackStr);
            return; // 阻止执行
        }
        return originalSetTimeout(callback, delay);
    };
})();