跳转到内容

User:Cdip150/common.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
if(location.protocol=="http:"){
	location.replace((""+location).replace(/^http\:\/\// ,"https:\/\/"));
}

window.setTimeoutat=function(varDate, func){
	return setTimeout(func, (Date==(varDate || {}).constructor?varDate.getTime():Date.parse(varDate))-Date.now() );
};

$( function(){
	var $frmDYKcp, frmDYKcp;
	
	if( mw.config.get("wgPageName")=="Wikipedia:新条目推荐/候选" && mw.util.getParamValue("dykcp")==1) {
		
		frmDYKcp=(
			($frmDYKcp=$('<form name="frmDYKcp" id="frmDYKcp" />')
			.on("submit", function(){return false} )
			.append('<p>')
			.append("源碼檔案:")
			.append('<input type="file" name="txtSrcFilePath" id="txtSrcFilePath" />')
			.append('<input type="button" name="btnLoadFile" id="btnLoadFile" value="載入" />')
			.append('<br />')
			.append('<textarea wrap="off" rows="15" name="txtMySrcCode" id="txtMySrcCode" style="width:80%" />')
			.append('<p>')
			.append("每小時更新之分秒:")
			.append('<input type="text" name="txtMin" id="txtMin" value="02" size="2" />')
			.append('<input type="text" name="txtSec" id="txtSec" value="20" size="2" />')
			.append('<p>')
			.append("上架間隔時數:")
			.append('<input type="text" name="txtFixh" id="txtFixh" value="0" size="10" />')
			.append('<p>')
			.append("從")
			.append('<input type="text" name="txtStartDate" id="txtStartDate" size="30" />')
			.append('<input type="button" name="btnStart" id="btnStart" value="開始執行" />')
			.append('<input type="button" name="btnGetNowTime" id="btnGetNowTime" value="(現在時間)" />')
			).appendTo(
				$("div#bodyContent").empty()
			)
		).get(0);

        frmDYKcp.btnLoadFile.onclick=function(){
            var fr=new FileReader();
            
            fr.onload=function(){
                frmDYKcp.txtMySrcCode.value=fr.result;
            };

            fr.readAsText(frmDYKcp.txtSrcFilePath.files[0]);
        };
		
        var timer_id=setTimeout(frmDYKcp.btnGetNowTime.onclick=function(){
        	frmDYKcp.txtStartDate.value=(new Date(Date.now()*1+8*60*60*1000)).toISOString().replace(/Z$/,"").replace(/\..*?$/,"")+"+0800";
        },100);
        
        frmDYKcp.btnStart.onclick=function(){
        	clearTimeout(timer_id);
        	
        	timer_id=setTimeoutat( $("#txtStartDate").get(0).value, function nextupd(){
        		var fixh=frmDYKcp.txtFixh.value, m=frmDYKcp.txtMin.value, s=frmDYKcp.txtSec.value;
        		
        		(!fixh || isNaN(fixh) )?fixh=0:fixh*=1;
        		(!m || isNaN(m) )?m=0:m=Math.floor(m);
        		(!s || isNaN(s) )?s=0:s=Math.floor(s);
        		
        		window.open((""+location).replace(/\?.*$/,"")+"?botcount=2&fixh="+fixh+"&_="+Date.now());
        		
				var nexttime=new Date(Date.now()*1+1*60*60*1000);
				nexttime.setMinutes(m);
				nexttime.setSeconds(s);
				timer_id=setTimeoutat(nexttime, nextupd);

        	});
        };
		
	}

	//改變編輯框字型
	$("textarea").css({"font-size":"10pt","font-family":"細明體,MingLiU"}).each(function(){
		this.rows=Math.floor(this.rows*0.9);
	});
	
});

importScript('User:Cdip150/工具/介面/ConvertRefNoteTag.js');


// [[User:Bencmq/script/CheckUser.js]] 请保留此行注释
//importScript('User:Bencmq/script/CheckUser.js');

(function runVoteCount(){
	if( (window.opener || {closed:true} ).closed ) return null;
	
	if( (mw || {util:null} ).util==null || $("#mw-normal-catlinks").length<=0 ) {
		setTimeout(runVoteCount, 5000);
		return null;
	}
	
	if( mw.config.get("wgPageName")!="Wikipedia:新条目推荐/候选" || mw.util.getParamValue("botcount")!=2) return null;
	
	$("img").each(function(){
		this.src=this.srcset="";
	}).remove();
	
	setTimeout( window.opener.$('#txtMySrcCode').get(0).value, 1000);

})();