跳转到内容

User:小躍/test4.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
//Test
if ((wgPageName=="Wikipedia:当前的破坏")&&(wgUserName=="小躍")){
	var csids='';
	var checkblocksectionid=0;
	var cscontent='';
	var cssectionidc='';
	var cssectionidcL=0;
	var csusername='';
	var beblockedbyadmin='';
	var beblockedtimestamp='';
	var beblockedexpiry='';
	var beblockedreason='';
	var timeselect='';
	var cseditbtn='';
	var cscontentR='';
	var checkblockchild編號=0;
	var checkblock編輯編號=0;
}// if end
if ((wgPageName=="Wikipedia:当前的破坏")&&(wgUserName=="小躍")){
	for(checkblockchild編號=15;checkblockchild編號<200;checkblockchild編號++){
		$('h3:nth-child('+checkblockchild編號.toString()+') > span.mw-editsection').append('<input id="CheckBlock_'+checkblockchild編號.toString()+'" class="oo-ui-inputWidget-input oo-ui-buttonElement-button" style="background-color:green;color:#fff" value="Check Block" title="Check Block" type="button" onclick="checkblocksearchsectionid('+checkblockchild編號+')"/>');
	}//索取child編號
	//#mw-content-text > div > h3:nth-child(18) > span.mw-editsection > a
}// if end
	
	function checkblocksearchsectionid(checkblockchildid){
		checkblocksectionid=$('h3:nth-child('+checkblockchildid.toString()+') > span.mw-editsection > a').attr('href').split("&")[2].split("=")[1];
		$('<div id="checkblocksearchsectionid" title="Search Section ID of Editing for querying">' +
		'<label for="csidst">Section ID:</label> ' +
     	'<select id="csidst" style="padding:1px;vertical-align:baseline;">'+
     	'<option value="'+checkblocksectionid+'">'+checkblocksectionid+
     	'</select><br/>'+
     	'<input id="wpCheckblockusername" value="Search" title="Search the name of user" type="button"/>'+
		'</div>'
     ).dialog({
        modal: false,
        autoOpen: true,
        width: 500,
        
     });
     $('#wpCheckblockusername').click(checkblockcheck);
	}
		function checkblockcheck() {
		event.preventDefault();
		var api = new mw.Api();
		api.get( {
			'action' : 'query',
			'titles' : wgPageName,
			'prop'   : 'revisions|info',
			'intoken' : 'edit',
			'rvprop' : 'content',
			"rvsection": $('#csidst').val(),
			'indexpageids' : 1
		} ).done( function (result) {
			result = result.query;
			var page = result.pages[result.pageids[0]];
			cscontent=page.revisions[0]["*"].toString();
			cssectionidc=cscontent.split("===")[1];
			cssectionidcL=cssectionidc.length;
			csusername=cssectionidc.substring(10,(cssectionidcL-3));
			$('<div id="checkblockcheckshow" title="Block of checking for IP address or user name">' +
					'<label>IP address or user name:'+csusername+'</label><br> ' +
					'<label>This IP address or user name is no be blocked.Please close this window.</label></br> ' +
					'</div>'
     			).dialog({
        			modal: false,
    				autoOpen: true,
        			width: 500,
     			});
				api.get( {
					'action' : 'query',
					"list": "blocks",
					"bkdir": "older",
					"bkusers": csusername,
					"bklimit": "1"
				}).done( function (result) {
					result = result.query;
					beblockedbyadmin=result.blocks[0].by.toString();
					beblockedtimestamp=result.blocks[0].timestamp.toString().replace(/T/,' ').replace(/Z/,' (UTC)');
					beblockedexpiry=result.blocks[0].expiry.toString().replace(/T/,' ').replace(/Z/,' (UTC)');
					beblockedreason=result.blocks[0].reason.toString().replace(/\{\{/,'<nowiki>{{').replace(/\}\}/,'}}</nowiki>');
					if(!((cscontent.match("[Bb]locked"))||(cscontent.match(/封禁([1-3][0-9][0-9]|[1-9][0-9]||[0-9]|([三六九][十])|[一二兩三六七九])(天|日|[个個]月|小[时時]|年|[週周])/)))){
					timeselect='<label for="timest">Section Day(s) of be blocked:</label> ' +'<select id="timest" style="padding:1px;vertical-align:baseline;">'+
					'<option value="12小時">12小時'+
					'<option value="1天">1天'+
					'<option value="1天7小時">1天7小時'+
					'<option value="2天">2天'+
					'<option value="3天">3天'+
					'<option value="7天">7天'+
					'<option value="14天">14天'+
					'<option value="30天">30天'+
					'<option value="60天">60天'+
					'<option value="90天">90天'+
					'<option value="180天">180天'+
					'<option value="1年">1年'+
					'<option value="2年">2年'+
					'<option value="3年">3年'+
					'<option value="永久">永久'+
     				'</select>';
     				cseditbtn='<input id="wpcsblockEdit" value="Edit" title="Edit this page" type="button"/>';
					}else{
						timeselect='<label>This block of checking has done.</label>';	
					}
					
					document.getElementById("checkblockcheckshow").innerHTML=
					'<label>IP address or user name:'+csusername+'</label><br> ' +
					'<label>Be blocked by admin:'+beblockedbyadmin+'</label></br>' +
					'<label>Start Time of be blocked:'+beblockedtimestamp+'</label> <br>' +
					'<label>End Time of be blocked:'+beblockedexpiry+'</label> <br/>' +
					'<label>Reason of be blocked:'+beblockedreason+'</label> <br>'+timeselect+'</br>' +cseditbtn;
     			$('#wpcsblockEdit').click(checkblockcheckdone);
     			});//2nd api get end
		});//1st api get end
		
	}
	function checkblockcheckdone(){
		event.preventDefault();
		if(cscontent.match("处理:")){
			cscontentR=cscontent.replace(/处理:/,'处理:{{Blocked|'+$('#timest').val()+'||'+beblockedbyadmin+'}}。--~~'+'~~');
			checkblockresult( wgPageName,wgPageName,$('#csidst').val(),cscontentR,'新增已被封禁處理的結果。',mw.util.getUrl(wgPageName));
		}
		$('<div id="checkblockdone" title="OK">' +
		'<label>編輯成功。</label> ' +
		'</div>'
     			).dialog({
        			modal: false,
    				autoOpen: true,
        			width: 500,
     			});
	}
	function checkblockresult( tracePage,destinationPage,EditSection,edittext,editsummary,linkTo ) {
		var api = new mw.Api();
		api.get( {
			'action' : 'query',
			'titles' : tracePage,
			'prop'   : 'revisions|info',
			'intoken' : 'edit',
			'rvprop' : 'content',
			'indexpageids' : 1
		} ).done( function (result) {
			result = result.query;
			var page = result.pages[result.pageids[0]];
			
		api.post( {
			'action' : 'edit',
			'title' : destinationPage,
			'text' :edittext,
			'section':EditSection,
			'summary' :editsummary,
			'token' : page.edittoken
		} ).done( function () {
			window.location.href = linkTo;
		} );
		} );
	}