Jump to content

MediaWiki:Common.js

From The Final Nights
Revision as of 00:11, 16 April 2025 by Buffy (talk | contribs)

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.
mw.loader.using( 'jquery' ).then( function () {
  $( function() { // Document ready shorthand
      var classList = document.documentElement.classList;
      var appliedTheme = false; // Flag to track if we made changes

      // --- Force Dark Mode ---

      // Remove potentially conflicting light mode classes
      if (classList.contains('vector-theme-light')) {
          classList.remove('vector-theme-light');
          appliedTheme = true;
      }
      if (classList.contains('vector-feature-night-mode-disabled')) {
          classList.remove('vector-feature-night-mode-disabled');
          appliedTheme = true;
      }
      if (classList.contains('skin-theme-clientpref-day')) {
          classList.remove('skin-theme-clientpref-day');
          appliedTheme = true;
      }

      // Add required dark mode classes if not already present
      if (!classList.contains('vector-theme-dark')) {
          classList.add('vector-theme-dark');
          appliedTheme = true;
      }
      // Hypothesis: Need to add the 'enabled' and 'night' counterparts
      if (!classList.contains('vector-feature-night-mode-enabled')) {
          classList.add('vector-feature-night-mode-enabled');
          appliedTheme = true;
      }
      if (!classList.contains('skin-theme-clientpref-night')) {
          classList.add('skin-theme-clientpref-night');
          appliedTheme = true;
      }

      // --- End Force Dark Mode ---

      if (appliedTheme) {
         console.log( 'Attempted to force dark theme classes via Common.js' );
      } else {
         console.log( 'Dark theme classes may have already been present; no changes made by Common.js script.' );
      }

  } );
} );