MediaWiki:Gadget-DarkModeVector2010.js: различия между версиями
Перейти к навигации
Перейти к поиску
Ланселот (обсуждение | вклад) Нет описания правки |
Ланселот (обсуждение | вклад) Нет описания правки |
||
| Строка 51: | Строка 51: | ||
function injectStyles() { | function injectStyles() { | ||
var css = [ | var css = [ | ||
'/* ==== Свежие правки: легенда ==== */', | |||
'body.darkmode-vector2010 .mw-changeslist-legend,', | |||
'body.darkmode-vector2010 .mw-specialpage-legend,', | |||
'body.darkmode-vector2010 .mw-changeslist-legend-inner,', | |||
'body.darkmode-vector2010 .rclistfrom,', | |||
'body.darkmode-vector2010 #mw-indicator,', | |||
'body.darkmode-vector2010 .mw-indicators {', | |||
' background: #222 !important;', | |||
' color: #d0d0d0 !important;', | |||
' border-color: #444 !important;', | |||
'}', | |||
'body.darkmode-vector2010 .mw-changeslist-legend a,', | |||
'body.darkmode-vector2010 .mw-specialpage-legend a {', | |||
' color: #6cb6ff !important;', | |||
'}', | |||
'/* Плашка «Свежие правки за последние X дней» и фильтры */', | |||
'body.darkmode-vector2010 .mw-specialpage-summary,', | |||
'body.darkmode-vector2010 .mw-recentchanges-filters,', | |||
'body.darkmode-vector2010 .rcoptions,', | |||
'body.darkmode-vector2010 fieldset {', | |||
' background: #222 !important;', | |||
' color: #d0d0d0 !important;', | |||
' border-color: #444 !important;', | |||
'}', | |||
'body.darkmode-vector2010 legend {', | |||
' color: #e0e0e0 !important;', | |||
'}', | |||
'/* Строки списка правок */', | |||
'body.darkmode-vector2010 .mw-changeslist-line,', | |||
'body.darkmode-vector2010 .mw-changeslist-line-inner,', | |||
'body.darkmode-vector2010 .special li,', | |||
'body.darkmode-vector2010 .mw-recentchanges-list li {', | |||
' background: #1a1a1a !important;', | |||
' border-color: #333 !important;', | |||
'}', | |||
'/* Подсветка «свежих» и «моих» правок */', | |||
'body.darkmode-vector2010 .mw-changeslist-line-watched,', | |||
'body.darkmode-vector2010 .mw-changeslist-line-not-watched {', | |||
' background: #1a1a1a !important;', | |||
'}', | |||
'body.darkmode-vector2010 .mw-plusminus-pos { color: #7bd88f !important; }', | |||
'body.darkmode-vector2010 .mw-plusminus-neg { color: #ff7b7b !important; }', | |||
'body.darkmode-vector2010 .mw-plusminus-null { color: #b0b0b0 !important; }', | |||
'/* ==== Ночная тема Vector 2010 ==== */', | '/* ==== Ночная тема Vector 2010 ==== */', | ||
'body.darkmode-vector2010 {', | 'body.darkmode-vector2010 {', | ||
Версия от 16:07, 16 октября 2026
/* Гаджет: Ночная тема для Vector 2010 */
( function ( mw, $ ) {
'use strict';
var STORAGE_KEY = 'gadget-darkmode-vector2010';
var CLASS_NAME = 'darkmode-vector2010';
function isEnabled() {
return mw.storage.get( STORAGE_KEY ) === '1';
}
function applyTheme( enable ) {
var $body = $( document.body );
if ( enable ) {
$body.addClass( CLASS_NAME );
mw.storage.set( STORAGE_KEY, '1' );
} else {
$body.removeClass( CLASS_NAME );
mw.storage.set( STORAGE_KEY, '0' );
}
updateButton( enable );
}
function updateButton( enabled ) {
var $btn = $( '#dm-toggle' );
if ( !$btn.length ) return;
$btn.text( enabled ? '☀️ День' : '🌙 Ночь' )
.attr( 'title', enabled ? 'Включить светлую тему' : 'Включить тёмную тему' );
}
function createButton() {
var $portlet = $( '#p-personal ul' );
if ( !$portlet.length ) return;
var $li = $( '<li>' ).attr( 'id', 'pt-darkmode' );
var $link = $( '<a>' )
.attr( 'href', '#' )
.attr( 'id', 'dm-toggle' )
.text( '🌙 Ночь' )
.on( 'click', function ( e ) {
e.preventDefault();
applyTheme( !isEnabled() );
} );
$li.append( $link );
$portlet.append( $li );
}
function injectStyles() {
var css = [
'/* ==== Свежие правки: легенда ==== */',
'body.darkmode-vector2010 .mw-changeslist-legend,',
'body.darkmode-vector2010 .mw-specialpage-legend,',
'body.darkmode-vector2010 .mw-changeslist-legend-inner,',
'body.darkmode-vector2010 .rclistfrom,',
'body.darkmode-vector2010 #mw-indicator,',
'body.darkmode-vector2010 .mw-indicators {',
' background: #222 !important;',
' color: #d0d0d0 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .mw-changeslist-legend a,',
'body.darkmode-vector2010 .mw-specialpage-legend a {',
' color: #6cb6ff !important;',
'}',
'/* Плашка «Свежие правки за последние X дней» и фильтры */',
'body.darkmode-vector2010 .mw-specialpage-summary,',
'body.darkmode-vector2010 .mw-recentchanges-filters,',
'body.darkmode-vector2010 .rcoptions,',
'body.darkmode-vector2010 fieldset {',
' background: #222 !important;',
' color: #d0d0d0 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 legend {',
' color: #e0e0e0 !important;',
'}',
'/* Строки списка правок */',
'body.darkmode-vector2010 .mw-changeslist-line,',
'body.darkmode-vector2010 .mw-changeslist-line-inner,',
'body.darkmode-vector2010 .special li,',
'body.darkmode-vector2010 .mw-recentchanges-list li {',
' background: #1a1a1a !important;',
' border-color: #333 !important;',
'}',
'/* Подсветка «свежих» и «моих» правок */',
'body.darkmode-vector2010 .mw-changeslist-line-watched,',
'body.darkmode-vector2010 .mw-changeslist-line-not-watched {',
' background: #1a1a1a !important;',
'}',
'body.darkmode-vector2010 .mw-plusminus-pos { color: #7bd88f !important; }',
'body.darkmode-vector2010 .mw-plusminus-neg { color: #ff7b7b !important; }',
'body.darkmode-vector2010 .mw-plusminus-null { color: #b0b0b0 !important; }',
'/* ==== Ночная тема Vector 2010 ==== */',
'body.darkmode-vector2010 {',
' background: #1a1a1a !important;',
' color: #d0d0d0 !important;',
'}',
'body.darkmode-vector2010 #content,',
'body.darkmode-vector2010 #mw-page-base,',
'body.darkmode-vector2010 #mw-head-base {',
' background: #1a1a1a !important;',
' background-image: none !important;',
' color: #d0d0d0 !important;',
'}',
'body.darkmode-vector2010 a { color: #6cb6ff !important; }',
'body.darkmode-vector2010 a:visited { color: #b48cff !important; }',
'body.darkmode-vector2010 a.new { color: #ff7b7b !important; }',
'body.darkmode-vector2010 h1,',
'body.darkmode-vector2010 h2,',
'body.darkmode-vector2010 h3,',
'body.darkmode-vector2010 h4,',
'body.darkmode-vector2010 h5,',
'body.darkmode-vector2010 h6 {',
' color: #ffffff !important;',
' border-bottom-color: #444 !important;',
'}',
'body.darkmode-vector2010 hr { border-color: #444 !important; }',
'body.darkmode-vector2010 table,',
'body.darkmode-vector2010 th,',
'body.darkmode-vector2010 td {',
' background: #222 !important;',
' color: #d0d0d0 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .wikitable > * > tr > th {',
' background: #2d2d2d !important;',
'}',
'body.darkmode-vector2010 code,',
'body.darkmode-vector2010 pre,',
'body.darkmode-vector2010 .mw-code {',
' background: #111 !important;',
' color: #e0e0e0 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 blockquote {',
' background: #222 !important;',
' border-left-color: #555 !important;',
'}',
'body.darkmode-vector2010 #toc,',
'body.darkmode-vector2010 .toc {',
' background: #222 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 #toc a,',
'body.darkmode-vector2010 .toc a { color: #6cb6ff !important; }',
'body.darkmode-vector2010 #p-personal a,',
'body.darkmode-vector2010 #p-navigation a,',
'body.darkmode-vector2010 #p-tb a,',
'body.darkmode-vector2010 #p-search a { color: #6cb6ff !important; }',
'body.darkmode-vector2010 #left-navigation,',
'body.darkmode-vector2010 #right-navigation {',
' background: #1a1a1a !important;',
'}',
'body.darkmode-vector2010 #simpleSearch input {',
' background: #2a2a2a !important;',
' color: #d0d0d0 !important;',
' border-color: #555 !important;',
'}',
'body.darkmode-vector2010 .thumbinner,',
'body.darkmode-vector2010 .thumb {',
' background: #222 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .thumbcaption { color: #b0b0b0 !important; }',
'/* Осветление SVG/PNG с прозрачностью */',
'body.darkmode-vector2010 img.mw-invertable,',
'body.darkmode-vector2010 .mw-invertable img {',
' filter: invert(1) hue-rotate(180deg);',
'}',
'/* Инверсия формул Math */',
'body.darkmode-vector2010 img.mwe-math-fallback-image-inline,',
'body.darkmode-vector2010 img.mwe-math-fallback-image-display {',
' filter: invert(1) hue-rotate(180deg);',
'}',
'body.darkmode-vector2010 .mw-warning,',
'body.darkmode-vector2010 .errorbox,',
'body.darkmode-vector2010 .successbox,',
'body.darkmode-vector2010 .messagebox {',
' background: #2d2d2d !important;',
' color: #d0d0d0 !important;',
' border-color: #555 !important;',
'}',
'body.darkmode-vector2010 .catlinks {',
' background: #222 !important;',
' border-color: #444 !important;',
'}',
'/* ==== Вкладки: Статья, Обсуждение, Читать, Правка и т.д. ==== */',
'body.darkmode-vector2010 #left-navigation,',
'body.darkmode-vector2010 #right-navigation,',
'body.darkmode-vector2010 #p-views,',
'body.darkmode-vector2010 #p-namespaces,',
'body.darkmode-vector2010 #p-actions,',
'body.darkmode-vector2010 .vectorTabs,',
'body.darkmode-vector2010 .vectorMenu,',
'body.darkmode-vector2010 .vector-menu,',
'body.darkmode-vector2010 .mw-vector-tabs {',
' background: #1a1a1a !important;',
' background-image: none !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .vectorTabs ul,',
'body.darkmode-vector2010 .vector-menu-content,',
'body.darkmode-vector2010 .mw-vector-tabs ul {',
' background: #1a1a1a !important;',
' background-image: none !important;',
'}',
'body.darkmode-vector2010 .vectorTabs li,',
'body.darkmode-vector2010 .vectorMenu li {',
' background: #2a2a2a !important;',
' background-image: none !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .vectorTabs li a,',
'body.darkmode-vector2010 .vectorMenu h3 span,',
'body.darkmode-vector2010 .vectorMenu h3 a,',
'body.darkmode-vector2010 .mw-vector-tabs li a {',
' color: #6cb6ff !important;',
' background: transparent !important;',
' background-image: none !important;',
'}',
'body.darkmode-vector2010 .vectorTabs li a:hover,',
'body.darkmode-vector2010 .vectorMenu h3:hover span {',
' color: #ffffff !important;',
' background: #333 !important;',
'}',
'/* Активная вкладка (та, что сейчас открыта) */',
'body.darkmode-vector2010 .vectorTabs li.selected,',
'body.darkmode-vector2010 .vectorTabs li.selected a,',
'body.darkmode-vector2010 .vector-menu-tabs .selected a {',
' background: #1a1a1a !important;',
' background-image: none !important;',
' color: #ffffff !important;',
' border-bottom-color: #1a1a1a !important;',
'}',
'/* Иконки-«звёздочки» и стрелки меню */',
'body.darkmode-vector2010 .vectorTabs li.icon a,',
'body.darkmode-vector2010 .vectorMenu h3 span:after {',
' filter: invert(1) hue-rotate(180deg);',
'}',
'/* Выпадающие меню (Ещё, Действия) */',
'body.darkmode-vector2010 .vectorMenu .menu,',
'body.darkmode-vector2010 .vectorMenu .vector-menu-content-list {',
' background: #222 !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .vectorMenu .menu a {',
' color: #6cb6ff !important;',
'}',
'body.darkmode-vector2010 .vectorMenu .menu a:hover {',
' background: #333 !important;',
'}',
'body.darkmode-vector2010 #footer {',
' background: #1a1a1a !important;',
' border-top-color: #444 !important;',
' color: #a0a0a0 !important;',
'}',
'/* ==== Вкладки: универсальный блок ==== */',
'body.darkmode-vector2010 .mw-portlet,',
'body.darkmode-vector2010 .mw-portlet-body,',
'body.darkmode-vector2010 .mw-portlet-views,',
'body.darkmode-vector2010 .mw-portlet-namespaces,',
'body.darkmode-vector2010 .mw-portlet-actions,',
'body.darkmode-vector2010 .mw-portlet-cactions,',
'body.darkmode-vector2010 .vector-menu-tabs,',
'body.darkmode-vector2010 .vector-menu-content,',
'body.darkmode-vector2010 .vector-menu-content-list {',
' background: #1a1a1a !important;',
' background-image: none !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .mw-portlet h3,',
'body.darkmode-vector2010 .mw-portlet .mw-portlet-heading,',
'body.darkmode-vector2010 .vector-menu-heading {',
' background: #2a2a2a !important;',
' background-image: none !important;',
' color: #6cb6ff !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .mw-portlet li,',
'body.darkmode-vector2010 .vector-menu-tabs li,',
'body.darkmode-vector2010 .vector-menu-content-list li {',
' background: #2a2a2a !important;',
' background-image: none !important;',
' border-color: #444 !important;',
'}',
'body.darkmode-vector2010 .mw-portlet li a,',
'body.darkmode-vector2010 .vector-menu-tabs li a,',
'body.darkmode-vector2010 .vector-menu-content-list li a,',
'body.darkmode-vector2010 .mw-portlet a {',
' color: #6cb6ff !important;',
' background: transparent !important;',
' background-image: none !important;',
'}',
'body.darkmode-vector2010 .mw-portlet li a:hover,',
'body.darkmode-vector2010 .vector-menu-tabs li a:hover {',
' background: #333 !important;',
' color: #ffffff !important;',
'}',
'/* Активная вкладка */',
'body.darkmode-vector2010 .mw-portlet li.selected,',
'body.darkmode-vector2010 .mw-portlet li.selected a,',
'body.darkmode-vector2010 .vector-menu-tabs li.selected,',
'body.darkmode-vector2010 .vector-menu-tabs li.selected a {',
' background: #1a1a1a !important;',
' background-image: none !important;',
' color: #ffffff !important;',
' border-color: #1a1a1a !important;',
'}',
'/* Ссылки внутри вкладок, которые ещё не созданы */',
'body.darkmode-vector2010 .mw-portlet li a.new,',
'body.darkmode-vector2010 .vector-menu-tabs li a.new {',
' color: #ff7b7b !important;',
'}',
'/* Обёртки вокруг вкладок */',
'body.darkmode-vector2010 #p-namespaces,',
'body.darkmode-vector2010 #p-views,',
'body.darkmode-vector2010 #p-cactions,',
'body.darkmode-vector2010 #p-actions {',
' background: #1a1a1a !important;',
' background-image: none !important;',
'}',
'body.darkmode-vector2010 #p-namespaces ul,',
'body.darkmode-vector2010 #p-views ul,',
'body.darkmode-vector2010 #p-cactions ul,',
'body.darkmode-vector2010 #p-actions ul {',
' background: #1a1a1a !important;',
' background-image: none !important;',
'}',
].join( '\n' );
mw.util.addCSS( css );
}
// Инициализация
$( function () {
injectStyles();
createButton();
// Применяем сохранённую тему без анимации при загрузке
if ( isEnabled() ) {
$( document.body ).addClass( CLASS_NAME );
}
updateButton( isEnabled() );
// Следим за изменением темы оформления
mw.hook( 'skin.change' ).add( function () {
if ( isEnabled() ) {
$( document.body ).addClass( CLASS_NAME );
}
} );
} );
}( mediaWiki, jQuery ) );