사용자:하늘/switchskin.js

< 사용자:하늘
하늘 (토론 | 기여)님의 2022년 1월 29일 (토) 17:07 판

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
function switchSkin(skinname) {
    new mw.Api().postWithToken('csrf', {
        "action": "options",
        "format": "json",
        "change": "skin=" + skinname
    }).done(data => {
        location.href = location.href;
    });
}

function switchSkinButton () {
    var node2 = '';
    var node = document.querySelector('#pt-preferences');
    if (node !== null) {
        node2 = node.cloneNode(1);
        var a = document.createElement('a');
        a.title = '스킨 바꾸기';
        a.onclick = function () { switchSkin("liberty") };
        a.innerText = a.title;
        a.style.cursor = 'pointer';
        node2.innerHTML = '', node2.append(a);
    } else {
        var node = document.querySelector('.login-dropdown-menu > .dropdown-divider:nth-of-type(2) + *');
        node2 = node.cloneNode(1);
        node2.title = "스킨 바꾸기";
        node2.onclick = function () { switchSkin("timeless") };
        node2.innerText = node2.title;
        node2.href = 'javascript:;';
    }

    node.after(node2);
}

switchSkinButton();