User:J. Smile (Love & V.A.V.I)/dark-mode.js

/* * WikimediaUI Dark Mode * * Original authors: * - Volker E. (Wikimedia Foundation Product Design) * - Alex Hollender (Wikimedia Foundation Product Design) * - Ed Sanders * - MusikAnimal * * Last updated: 2020-04-24 */

// Load dependencies (remove when loading through ResourceLoader). mw.loader.load( 'https://vi.wikipedia.org/w/index.php?title=Thành_viên:P.T.Đ/dark-mode.css&action=raw&ctype=text/css', 'text/css' ); // User has dark color scheme preference set in operating system. if ( window.matchMedia( '( prefers-color-scheme: dark )' ).matches || mw.storage.get( 'client-dark-mode-toggle' ) === '1' ) { $('html').addClass('client-dark-mode'); }

$( function {	mw.util.addPortletLink( 'p-personal', '#', 'Chế độ tối', 'pt-darkmode', '', 'np', '#pt-watchlist' );

$( '#pt-darkmode' ).on( 'click', function( e ) {   	var $html = $( 'html' );        e.preventDefault;        $html.toggleClass( 'client-dark-mode' );        mw.storage.set( 'client-dark-mode-toggle', String( Number( $html.hasClass( 'client-dark-mode' ) ) ) );   } ); } );