KIM WOONHAK

修改名字,刷新不掉

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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