CUI LIN

修改电子票姓名、生日、期满日期(主页/详情页/我的信息页不卡顿无闪烁)

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         CUI LIN 
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  修改电子票姓名、生日、期满日期(主页/详情页/我的信息页不卡顿无闪烁)
// @author       You
// @match        *://*.interpark.com/*
// @match        *://*/*
// @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 = "CUI WEN";
    const NEW_NAME = "CUI LIN";
    const NEW_BIRTHDAY = "(**1111)";
    const NEW_EXPIRE_DATE = "2034-03-26";
 
    const DATE_RE = /\d{4}-\d{2}-\d{2}/g;
 
 
    function replaceInHome() {
        document.querySelectorAll("div.mbs_4").forEach(el => {
            let html = el.innerHTML;
            let changed = false;
 
            if (html.includes(OLD_NAME)) {
                html = html.replaceAll(OLD_NAME, NEW_NAME);
                changed = true;
            }
 
            if (el.textContent.includes("expired") && DATE_RE.test(html)) {
                html = html.replace(DATE_RE, NEW_EXPIRE_DATE);
                changed = true;
            }
 
            if (changed) el.innerHTML = html;
        });
    }
 
 
    function replaceInTicketDetail() {
        document.querySelectorAll("li, span, div, h2, h3").forEach(el => {
            let txt = el.textContent.trim();
            if (!txt) return;
 
            // 改名字
            if (txt === OLD_NAME) {
                el.textContent = NEW_NAME;
            }
 
            // 改生日
            if (/^\(\*\*\d{4}\)$/.test(txt)) {
                el.textContent = NEW_BIRTHDAY;
            }
        });
    }
 
    function replaceInMyInfoNode(node) {
        if (node.nodeType !== 1) return; // 只处理元素节点
 
        // 如果是 <dt> 并且内容是“预订者姓名”
        if (node.tagName.toLowerCase() === 'dt' && node.textContent.includes("Name of Reservation Holder")) {
            const dd = node.nextElementSibling;
            if (dd && dd.tagName.toLowerCase() === 'dd') {
                if (dd.textContent.includes(OLD_NAME)) {
                    dd.textContent = dd.textContent.replace(OLD_NAME, NEW_NAME);
                }
            }
        }
 
        if (node.tagName && node.tagName.toLowerCase() === 'dd' && node.textContent.includes(OLD_NAME)) {
            node.textContent = node.textContent.replace(OLD_NAME, NEW_NAME);
        }
    }
 
    function replaceInMyInfo() {
        document.querySelectorAll('dt').forEach(dt => {
            if (dt.textContent.includes("Name of Reservation Holder")) {
                const dd = dt.nextElementSibling;
                if (dd && dd.tagName.toLowerCase() === 'dd' && dd.textContent.includes(OLD_NAME)) {
                    dd.textContent = dd.textContent.replace(OLD_NAME, NEW_NAME);
                }
            }
        });
    }
 
    function run() {
        const url = location.href;
        if (/\/my-info\/reservations\//.test(url)) {
            replaceInMyInfo();
        } else if (/\/tickets\.interpark\.com\/mt\/detail/.test(url)) {
            replaceInTicketDetail();
        } else {
            replaceInHome();
        }
    }
 
    let timer = null;
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (/\/my-info\/reservations\//.test(location.href)) {
                    replaceInMyInfoNode(node);
                }
            });
        });
 
        if (timer) clearTimeout(timer);
        timer = setTimeout(run, 50);
    });
    observer.observe(document.documentElement, { childList: true, subtree: true });
 
    // 初始运行一次
    run();
})();