MediaWiki:Common.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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
}
}
}