Force Replace main.css with mainblue.css

Replaces all references to /css/main.css with /css/mainblue.css

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Force Replace main.css with mainblue.css
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Replaces all references to /css/main.css with /css/mainblue.css
// @match        *://*/*
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // Intercept all requests for /css/main.css
    const observer = new MutationObserver(() => {
        document.querySelectorAll('link[rel="stylesheet"]').forEach(link => {
            if (link.href.includes("/css/main.css")) {
                link.href = link.href.replace("/css/main.css", "/css/mainblue.css");
            }
        });
    });

    // Watch DOM changes
    observer.observe(document.documentElement, { childList: true, subtree: true });

    // Also handle fetch() and XHR requests
    const origOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        if (url.includes("/css/main.css")) {
            url = url.replace("/css/main.css", "/css/mainblue.css");
        }
        return origOpen.apply(this, arguments);
    };

    // For fetch API
    const origFetch = window.fetch;
    window.fetch = function(input, init) {
        if (typeof input === "string" && input.includes("/css/main.css")) {
            input = input.replace("/css/main.css", "/css/mainblue.css");
        } else if (input.url && input.url.includes("/css/main.css")) {
            input = new Request(input.url.replace("/css/main.css", "/css/mainblue.css"), input);
        }
        return origFetch(input, init);
    };
})();