사용자:하늘/switchskin.js: 두 판 사이의 차이

편집 요약 없음
잔글 (Chirho님이 사용자:Cerulean/switchskin.js 문서를 넘겨주기를 만들지 않고 사용자:하늘/switchskin.js 문서로 이동했습니다: "Cerulean" 사용자의 이름을 "하늘"(으)로 바꿀 때 문서를 자동으로 이동했습니다)
 
(차이 없음)

2022년 5월 11일 (수) 10:30 기준 최신판

function switchSkin(skinname) {
    new mw.Api().postWithToken('csrf', {
        "action": "options",
        "format": "json",
        "change": "skin=" + skinname
    }).done(data => {
        location.href = location.href;
    });
}

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

    preferences.after(switchSkinB);
});