Jump to content

MediaWiki:Common.js: Difference between revisions

From The Commentary Community Wiki
No edit summary
Tag: Manual revert
No edit summary
Tag: Reverted
Line 2: Line 2:


if (document.querySelector(".force-vector-night")) {
if (document.querySelector(".force-vector-night")) {
     const url = new URL(window.location.href);
     const skin = mw.config.get("skin"); // current skin
    const nightModeEnabled = mw.config.get("wgVectorNightMode"); // true if user already has night mode


     url.searchParams.set("vectornightmode", "1");
     // If using Vector and night mode is OFF, switch to night mode
    if (skin === "vector" && !nightModeEnabled) {
        const url = new URL(window.location.href);
        url.searchParams.set("vectornightmode", "1"); // enable night mode


    if (window.location.href !== url.toString()) {
        if (window.location.href !== url.toString()) {
        window.location.replace(url.toString());
            window.location.replace(url.toString()); // reload page with dark mode
        }
     }
     }
}
}

Revision as of 02:34, 13 March 2026

/* Any JavaScript here will be loaded for all users on every page load. */

if (document.querySelector(".force-vector-night")) {
    const skin = mw.config.get("skin"); // current skin
    const nightModeEnabled = mw.config.get("wgVectorNightMode"); // true if user already has night mode

    // If using Vector and night mode is OFF, switch to night mode
    if (skin === "vector" && !nightModeEnabled) {
        const url = new URL(window.location.href);
        url.searchParams.set("vectornightmode", "1"); // enable night mode

        if (window.location.href !== url.toString()) {
            window.location.replace(url.toString()); // reload page with dark mode
        }
    }
}