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 για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey 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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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