Prevent flashbang on loading darkmode
This commit is contained in:
@@ -87,6 +87,27 @@ class NextBestNetworkHooks {
|
||||
*/
|
||||
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
|
||||
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' );
|
||||
|
||||
$styles = [];
|
||||
|
||||
@@ -33,4 +33,4 @@
|
||||
.dropdown-menu > li#tw-createaccount > a:focus {
|
||||
color:#000;
|
||||
background-color:transparent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user