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

(새 문서: $(function() { var lastDropDownItem = document.querySelector('.content-tools .dropdown-item:last-child'); if (lastDropDownItem && mw.config.get('wgCanonicalNamespace') == 'Use...)
 
(문서를 비움)
태그: 비우기
 
(사용자 2명의 중간 판 32개는 보이지 않습니다)
1번째 줄: 1번째 줄:
$(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);
    }
});

2024년 1월 6일 (토) 17:33 기준 최신판