사용자:하늘/addArticleMenuItem.js

< 사용자:하늘
하늘 (토론 | 기여)님의 2022년 4월 30일 (토) 17:54 판

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

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
function dropdownItem() {
    this.lastDropDownItem = document.querySelector('.content-tools .dropdown-item:last-child');
    this.AddItem = function ( func ) {
        var toAddItem = this.lastDropDownItem.cloneNode(true);
        toAddItem.href = 'javascript:;';
        toAddItem.innerHTML = '본문으로 이전';
        toAddItem.accessKey = '';
        toAddItem.title = '사용자 문서를 본문으로 이동합니다.';
        toAddItem.onclick = func;
        this.lastDropDownItem.after(toAddItem);
    }
}

new dropdownItem.AddItem( function () {
    wgPageName = mw.config.get('wgPageName');
    mw.notification.autoHideSeconds = { 'short': 2 };
    const to = wgPageName.split('/').pop(); //시리즈:리브레 한자사전/櫻
    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(data => {
        mw.notify('이동 완료!');
        location.href = mw.config.values.wgServer + "/wiki/" + to;
    }).fail(data => {
        mw.notify('이동 실패');
        console.log(data);
    });
})