KIM WOONHAK

修改名字,刷新不掉

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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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         KIM WOONHAK
// @namespace    http://tampermonkey.net/
// @version      4.0
// @description  修改名字,刷新不掉
// @author       You
// @match        *://*/*
// @match        *://*.nol.yanolja.com/*
// @match        *://nol.yanolja.com/*
// @match        *://*.interpark.com/*
// @match        *://*.interparkglobal.com/*
// @match        *://m.interpark.com/*
// @match        *://m.interparkglobal.com/*
// @match        *://*.nol.com/*
// @icon         https://interpark.com/favicon.ico
// @license      MIT
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    const OLD_NAME = "김운학";
    const NEW_NAME = "kim woonhak"; 

    function replaceNameInPage() {
        if (!document.body) return;
 
        const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
        let textNode;
        
        while ((textNode = walker.nextNode())) {
            if (textNode.nodeValue.includes(OLD_NAME)) {
                textNode.nodeValue = textNode.nodeValue.replaceAll(OLD_NAME, NEW_NAME);
            }
        }
    }

    /*** MutationObserver 防抖 + 无闪烁处理 ***/
    let timer = null;
    const observer = new MutationObserver(mutations => {
        if (timer) clearTimeout(timer);
        timer = setTimeout(() => {
            replaceNameInPage();
        }, 30); // 30ms 延迟,防抖动,避免页面卡顿
    });

    // 监听整个文档的变化,包括文本发生改变的情况
    observer.observe(document.documentElement, { 
        childList: true, 
        subtree: true,
        characterData: true // 这个属性确保即便数据是异步加载的,也能被捕捉到
    });

    // 网页初次加载时运行一次
    document.addEventListener("DOMContentLoaded", replaceNameInPage);
})();