KIM WOONHAK

修改名字,刷新不掉

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
})();