Prevent flashbang on loading darkmode

This commit is contained in:
D. Rimron-Soutter
2025-12-30 16:52:12 +00:00
parent 8d925266e9
commit 37b5ff7165
2 changed files with 22 additions and 1 deletions

View File

@@ -87,6 +87,27 @@ class NextBestNetworkHooks {
*/ */
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
if( $skin->getSkinName() == 'nextbestnetwork' ) { if( $skin->getSkinName() == 'nextbestnetwork' ) {
$out->addHeadItem( 'nextbestnetwork-darkmode-init', '
<script>
(function() {
const getStoredTheme = () => localStorage.getItem("theme");
const getPreferredTheme = () => {
const storedTheme = getStoredTheme();
if (storedTheme) return storedTheme;
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
};
const setTheme = theme => {
if (theme === "auto") {
document.documentElement.setAttribute("data-bs-theme", window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
} else {
document.documentElement.setAttribute("data-bs-theme", theme);
}
};
setTheme(getPreferredTheme());
})();
</script>
' );
$config = \MediaWiki\MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'nextbestnetwork' ); $config = \MediaWiki\MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'nextbestnetwork' );
$styles = []; $styles = [];

View File

@@ -33,4 +33,4 @@
.dropdown-menu > li#tw-createaccount > a:focus { .dropdown-menu > li#tw-createaccount > a:focus {
color:#000; color:#000;
background-color:transparent; background-color:transparent;
} }