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

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

2022년 5월 11일 (수) 10:30 판

function page( title ) {
	this.title = "";
	this.SetTitle = function(title) { this.title = title; };
	this.Moveto = function(to, reason) {
		new mw.Api().postWithToken('csrf', {
            "action": "move",
            "format": "json",
            "formatversion": "latest",
            "utf8": 1,
            "from": this.title,
            "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);
        });
	};
}

if (mw.config.get('wgCanonicalNamespace') == 'User' && mw.config.get('wgPageContentModel') == 'wikitext') {
    newDropdownItemTest = new newDropdownItem( document.querySelector('.content-tools .dropdown-item:last-child') );
    
    newDropdownItemTest.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('이동 완료!');
            new mw.Api().postWithEditToken({
                "action": "edit", "format": "json", "contentmodel": "wikitext",
                "title": to.split('/').pop(), //櫻
                "text": "#넘겨주기 [[" + to + "]]",  // #넘겨주기[[시리즈:리브레 한자사전/櫻]]
            }).done(data => {
                console.log(data);
            }).fail(data => { console.log(data); });
            location.href = mw.config.values.wgServer + "/wiki/" + to;
        }).fail(data => {
            mw.notify('이동 실패');
            console.log(data);
        });
    }, '시리즈:한자사전으로 이동', '시리즈:리브레 한자사전으로 이동하기');

    newDropdownItemTest.AddItem(function () {
        wgPageName = mw.config.get('wgPageName');
        mw.notification.autoHideSeconds = { 'short': 2 };
        const to = wgPageName.split('/').pop(); //시리즈:리브레 한자사전/櫻
        page1 = new page();
    	page1.title = wgPageName;
    	page1.Moveto(to);
    	
    }, '본문으로 이전', '사용자 문서를 본문으로 이동합니다.');
}