편집 요약 없음 |
편집 요약 없음 |
||
1번째 줄: | 1번째 줄: | ||
if (mw.config.get('wgPageContentModel') == 'wikitext' && location.href.indexOf('veaction') == -1) { | |||
if (mw.config.get('wgPageContentModel') == 'wikitext' && location.href.indexOf('veaction') == -1 | var editButton = document.querySelector('#ca-edit'); | ||
var editButton = document.querySelector(' | |||
var veditButton = editButton.cloneNode(true); | var veditButton = editButton.cloneNode(true); | ||
veditButton.href = | |||
veditButton.href = veditButton.href.replace('action', 'veaction'), | |||
veditButton.title = '비주얼 에디터로 편집하기', | veditButton.title = '비주얼 에디터로 편집하기', | ||
//veditButton.innerHTML = veditButton.innerHTML.replace('편집', 'VE'), | |||
veditButton.innerHTML = '<i class="fas fa-eye"></i>', | veditButton.innerHTML = '<i class="fas fa-eye"></i>', | ||
veditButton.accessKey = 'v', | veditButton.accessKey = 'v', | ||
editButton.after(veditButton); | editButton.after(veditButton); | ||
//비주얼 에디터 | |||
} | } | ||
//console.log(mw.config); | |||
//console.log(mw.config.get('wgPageContentModel')); | |||
function toDark() { setDarkLight('dark'); } | |||
function toLight() { setDarkLight('light'); } | |||
function setAuto() { setDarkLight(null); } | |||
function setDarkLight(option) { | |||
new mw.Api().saveOption('liberty-dark', option).done(function () { location = location }); | |||
} | |||
$(function () { | |||
var Button = document.querySelector('.dropdown-divider.view-logout').previousElementSibling.cloneNode(); | |||
var ToDarkButton = Button.cloneNode(); | |||
ToDarkButton.innerText = '다크모드(강제)'; | |||
ToDarkButton.onclick = toDark; | |||
var ToLightButton = Button.cloneNode(); | |||
ToLightButton.innerText = '라이트모드(강제)'; | |||
ToLightButton.onclick = toLight; | |||
var setAutoButton = Button.cloneNode(); | |||
setAutoButton.innerText = '다크모드(자동)'; | |||
setAutoButton.onclick = setAuto; | |||
if (mw.user.options.values['liberty-dark'] == undefined) { | |||
$('.dropdown-divider.view-logout').before(ToDarkButton); | |||
$(ToDarkButton).after(ToLightButton); | |||
if (window.matchMedia("(prefers-color-scheme: dark)").matches) { | |||
mw.loader.load('/index.php?title=사용자:하늘/liberty-dark.css&action=raw&ctype=text/css', 'text/css'); document.body.classList.add('Liberty-dark'); | |||
} | |||
} else if (mw.user.options.values['liberty-dark'] == 'light') { | |||
$('.dropdown-divider.view-logout').before(ToDarkButton); | |||
$(ToDarkButton).after(setAutoButton); | |||
} else if (mw.user.options.values['liberty-dark'] == 'dark') { | |||
$('.dropdown-divider.view-logout').before(setAutoButton); | |||
$(setAutoButton).after(ToLightButton); | |||
mw.loader.load('/index.php?title=사용자:하늘/liberty-dark.css&action=raw&ctype=text/css', 'text/css'); | |||
document.body.classList.add('Liberty-dark'); | |||
} | |||
}); |
2022년 10월 23일 (일) 11:53 판
if (mw.config.get('wgPageContentModel') == 'wikitext' && location.href.indexOf('veaction') == -1) {
var editButton = document.querySelector('#ca-edit');
var veditButton = editButton.cloneNode(true);
veditButton.href = veditButton.href.replace('action', 'veaction'),
veditButton.title = '비주얼 에디터로 편집하기',
//veditButton.innerHTML = veditButton.innerHTML.replace('편집', 'VE'),
veditButton.innerHTML = '<i class="fas fa-eye"></i>',
veditButton.accessKey = 'v',
editButton.after(veditButton);
//비주얼 에디터
}
//console.log(mw.config);
//console.log(mw.config.get('wgPageContentModel'));
function toDark() { setDarkLight('dark'); }
function toLight() { setDarkLight('light'); }
function setAuto() { setDarkLight(null); }
function setDarkLight(option) {
new mw.Api().saveOption('liberty-dark', option).done(function () { location = location });
}
$(function () {
var Button = document.querySelector('.dropdown-divider.view-logout').previousElementSibling.cloneNode();
var ToDarkButton = Button.cloneNode();
ToDarkButton.innerText = '다크모드(강제)';
ToDarkButton.onclick = toDark;
var ToLightButton = Button.cloneNode();
ToLightButton.innerText = '라이트모드(강제)';
ToLightButton.onclick = toLight;
var setAutoButton = Button.cloneNode();
setAutoButton.innerText = '다크모드(자동)';
setAutoButton.onclick = setAuto;
if (mw.user.options.values['liberty-dark'] == undefined) {
$('.dropdown-divider.view-logout').before(ToDarkButton);
$(ToDarkButton).after(ToLightButton);
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
mw.loader.load('/index.php?title=사용자:하늘/liberty-dark.css&action=raw&ctype=text/css', 'text/css'); document.body.classList.add('Liberty-dark');
}
} else if (mw.user.options.values['liberty-dark'] == 'light') {
$('.dropdown-divider.view-logout').before(ToDarkButton);
$(ToDarkButton).after(setAutoButton);
} else if (mw.user.options.values['liberty-dark'] == 'dark') {
$('.dropdown-divider.view-logout').before(setAutoButton);
$(setAutoButton).after(ToLightButton);
mw.loader.load('/index.php?title=사용자:하늘/liberty-dark.css&action=raw&ctype=text/css', 'text/css');
document.body.classList.add('Liberty-dark');
}
});