|
|
11번째 줄: |
11번째 줄: |
| //비주얼 에디터 | | //비주얼 에디터 |
| } | | } |
| //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');
| |
| }
| |
| });
| |