사용자:하늘/1.js

< 사용자:하늘
하늘 (토론 | 기여)님의 2022년 4월 30일 (토) 17:33 판 (새 문서: $(function() { var lastDropDownItem = document.querySelector('.content-tools .dropdown-item:last-child'); if (lastDropDownItem && mw.config.get('wgCanonicalNamespace') == 'Use...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
$(function() {
    var lastDropDownItem = document.querySelector('.content-tools .dropdown-item:last-child');
    if (lastDropDownItem && mw.config.get('wgCanonicalNamespace') == 'User' && mw.config.get('wgPageContentModel') == 'wikitext') {
        var toAddItem = lastDropDownItem.cloneNode(true);
        toAddItem.href = 'javascript:;';
        toAddItem.innerHTML = '본문으로 이전';
        toAddItem.accessKey = '';
        toAddItem.title = '사용자 문서를 본문으로 이동합니다.';
        toAddItem.onclick = function () {
            wgPageName = mw.config.get('wgPageName');
            mw.loader.using('mediawiki.notification')
            mw.notification.autoHideSeconds = { 'short': 2 };
            const to = wgPageName.match('/(.*)')[1];
            new mw.Api().postWithToken('csrf', {
                "action": "move",
                "format": "json",
                "formatversion": "latest",
                "utf8": 1,
                "from": wgPageName,
                "to": to,
                "reason": "일반 이름공간으로 이전",
                "movetalk": 1,
                "noredirect": 1,
                "movesubpages": 1
            }).done(function(data) {
                mw.notify('이동 완료!');
                location.href = mw.config.values.wgServer + "/wiki/" + to;
            }).fail(function(data) {
                mw.notify('이동 실패');
                console.log(data);
            });
        };
        lastDropDownItem.after(toAddItem);
    }
});