User:Wetittwinkle/twinkle.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// <nowiki>
(function(window,document,$,undefined){window.wgUXS=function(wg,hans,hant,cn,tw,hk,sg,zh,mo,my){var ret={'zh':zh||hans||hant||cn||tw||hk||sg||mo||my,'zh-hans':hans||cn||sg||my,'zh-hant':hant||tw||hk||mo,'zh-cn':cn||hans||sg||my,'zh-sg':sg||hans||cn||my,'zh-tw':tw||hant||hk||mo,'zh-hk':hk||hant||mo||tw,'zh-mo':mo||hant||hk||tw};return ret[wg]||zh||hans||hant||cn||tw||hk||sg||mo||my;};window.wgULS=function(hans,hant,cn,tw,hk,sg,zh,mo,my){return wgUXS(mw.config.get('wgUserLanguage'),hans,hant,cn,tw,hk,sg,zh,mo,my);};window.wgUVS=function(hans,hant,cn,tw,hk,sg,zh,mo,my){return wgUXS(mw.config.get('wgUserVariant'),hans,hant,cn,tw,hk,sg,zh,mo,my);};var Twinkle={};window.Twinkle=Twinkle;Twinkle.userAuthorized=Morebits.userIsInGroup("autoconfirmed")||Morebits.userIsInGroup("confirmed");Twinkle.initCallbacks=[];Twinkle.addInitCallback=function twinkleAddInitCallback(func){Twinkle.initCallbacks.push(func);};Twinkle.defaultConfig={};Twinkle.defaultConfig.twinkle={summaryAd:" ([[WP:TW|TW]])",deletionSummaryAd:" ([[WP:TW|TW]])",protectionSummaryAd:" ([[WP:TW|TW]])",blockSummaryAd:" ([[WP:TW|TW]])",userTalkPageMode:"tab",dialogLargeFont:false,blankTalkpageOnIndefBlock:false,customBlockReasonList:[],openTalkPage:[],openTalkPageOnAutoRevert:false,markRevertedPagesAsMinor:["vand"],watchRevertedPages:[],offerReasonOnNormalRevert:true,confirmOnFluff:false,showRollbackLinks:["diff","others"],customRevertSummary:[],notifyUserOnDeli:true,deliWatchPage:"default",deliWatchUser:"default",speedySelectionStyle:"buttonClick",watchSpeedyPages:[],markSpeedyPagesAsPatrolled:true,notifyUserOnSpeedyDeletionNomination:["db","g1","g2","g3","g5","g11","g12","g13","g16","a1","a2","a5","a6","f6","r2","r3","r7"],welcomeUserOnSpeedyDeletionNotification:["db","g1","g2","g3","g5","g11","g12","g13","g16","a1","a2","a5","a6","f6","r2","r3","r7"],promptForSpeedyDeletionSummary:[],openUserTalkPageOnSpeedyDelete:[],deleteTalkPageOnDelete:true,deleteRedirectsOnDelete:true,deleteSysopDefaultToTag:false,speedyWindowHeight:500,speedyWindowWidth:800,logSpeedyNominations:false,speedyLogPageName:"CSD日志",noLogOnSpeedyNomination:["o1"],enlargeG11Input:false,unlinkNamespaces:["0","10","100","118"],defaultWarningGroup:"1",showSharedIPNotice:true,watchWarnings:false,customWarningList:[],autoMenuAfterRollback:false,xfdWatchDiscussion:"default",xfdWatchPage:"default",xfdWatchUser:"default",markXfdPagesAsPatrolled:true,FwdCsdToXfd:Morebits.userIsInGroup('sysop'),afdDefaultCategory:"delete",afdFameDefaultReason:"沒有足夠的可靠資料來源能夠讓這個條目符合[[Wikipedia:關注度]]中的標準",afdSubstubDefaultReason:"過期小小作品",XfdClose:(Morebits.userIsInGroup('sysop')?'all':'hide'),copyvioWatchPage:"default",copyvioWatchUser:"default",markCopyvioPagesAsPatrolled:true,markDraftCopyvioWithCSD:false,revertMaxRevisions:50,batchdeleteChunks:50,batchMax:5000,batchProtectChunks:50,batchundeleteChunks:50,proddeleteChunks:50,revisionTags:"Twinkle",configPage:"Wikipedia:Twinkle/参数设置",projectNamespaceName:mw.config.get("wgFormattedNamespaces")[4],sandboxPage:"Wikipedia:沙盒",};switch(mw.config.get("skin")){case"vector":Twinkle.defaultConfig.twinkle.portletArea="right-navigation";Twinkle.defaultConfig.twinkle.portletId="p-twinkle";Twinkle.defaultConfig.twinkle.portletName="TW";Twinkle.defaultConfig.twinkle.portletType="menu";Twinkle.defaultConfig.twinkle.portletNext="p-search";break;case"timeless":Twinkle.defaultConfig.twinkle.portletArea="mw-related-navigation";Twinkle.defaultConfig.twinkle.portletId="p-twinkle";Twinkle.defaultConfig.twinkle.portletName="Twinkle";Twinkle.defaultConfig.twinkle.portletType="menu";Twinkle.defaultConfig.twinkle.portletNext="page-tools";break;default:Twinkle.defaultConfig.twinkle.portletArea=null;Twinkle.defaultConfig.twinkle.portletId="p-cactions";Twinkle.defaultConfig.twinkle.portletName=null;Twinkle.defaultConfig.twinkle.portletType=null;Twinkle.defaultConfig.twinkle.portletNext=null;break;}
Twinkle.defaultConfig.friendly={groupByDefault:true,watchTaggedPages:false,watchMergeDiscussions:false,markTaggedPagesAsMinor:false,markTaggedPagesAsPatrolled:true,tagArticleSortOrder:"cat",enableStub:true,customTagList:[],watchStubbedPages:false,markStubbedPagesAsMinor:false,stubArticleSortOrder:"cat",customStubList:[],markTalkbackAsMinor:true,insertTalkbackSignature:true,talkbackHeading:wgULS("回复通告","回覆通告"),mailHeading:wgULS("您有新邮件!","您有新郵件!"),markSharedIPAsMinor:true};Twinkle.getPref=function twinkleGetPref(name){var result;if(typeof Twinkle.prefs==="object"&&typeof Twinkle.prefs.twinkle==="object"){result=Twinkle.prefs.twinkle[name];}else if(typeof window.TwinkleConfig==="object"){result=window.TwinkleConfig[name];}
if(result===undefined){return Twinkle.defaultConfig.twinkle[name];}
return result;};Twinkle.getFriendlyPref=function twinkleGetFriendlyPref(name){var result;if(typeof Twinkle.prefs==="object"&&typeof Twinkle.prefs.friendly==="object"){result=Twinkle.prefs.friendly[name];}else if(typeof window.FriendlyConfig==="object"){result=window.FriendlyConfig[name];}
if(result===undefined){return Twinkle.defaultConfig.friendly[name];}
return result;};Twinkle.addPortlet=function(navigation,id,text,type,nextnodeid)
{var root=document.getElementById(navigation);if(!root){return null;}
var item=document.getElementById(id);if(item){if(item.parentNode&&item.parentNode===root){return item;}
return null;}
var nextnode;if(nextnodeid){nextnode=document.getElementById(nextnodeid);}
var skin=mw.config.get("skin");if(skin==="vector"&&type==="menu"&&(navigation==="left-navigation"||navigation==="right-navigation")){type="menu";}else if(skin==="timeless"&&type==="menu"&&(navigation==="mw-site-navigation"||navigation==="mw-related-navigation")){type="menu";}else{type="";}
var outerDivClass;var innerDivClass;switch(skin)
{case"vector":if(navigation!=="portal"&&navigation!=="left-navigation"&&navigation!=="right-navigation"){navigation="mw-panel";}
outerDivClass=(navigation==="mw-panel")?"portal":(type==="menu"?"vectorMenu":"vectorTabs");innerDivClass=(navigation==="mw-panel")?"body":(type==="menu"?"menu":"");break;case"modern":if(navigation!=="mw_portlets"&&navigation!=="mw_contentwrapper"){navigation="mw_portlets";}
outerDivClass="portlet";innerDivClass="pBody";break;case"timeless":outerDivClass="sidebar-chunk";innerDivClass="sidebar-inner";break;default:navigation="column-one";outerDivClass="portlet";innerDivClass="pBody";break;}
var outerDiv=document.createElement("div");outerDiv.className=outerDivClass+" emptyPortlet";outerDiv.id=id;if(nextnode&&nextnode.parentNode===root){root.insertBefore(outerDiv,nextnode);}else{root.appendChild(outerDiv);}
var h5;if(skin==="timeless"){h5=document.createElement("h2");}else{h5=document.createElement("h3");}
if(type==="menu"){var span=document.createElement("span");span.appendChild(document.createTextNode(text));h5.appendChild(span);var a=document.createElement("a");a.href="#";$(a).click(function(e){e.preventDefault();if(!Twinkle.userAuthorized){alert("抱歉,您需达自动确认后方可使用Twinkle。");}});h5.appendChild(a);}else{h5.appendChild(document.createTextNode(text));}
outerDiv.appendChild(h5);var innerDiv=null;if(type==="menu"){innerDiv=document.createElement("div");innerDiv.className=innerDivClass;outerDiv.appendChild(innerDiv);if(skin==="timeless"){navigation=document.createElement("div");navigation.className="mw-portlet";innerDiv.appendChild(navigation);var navigationname=document.createElement("h3");navigationname.innerText=text;navigation.appendChild(navigationname);var portletbody=document.createElement("div");portletbody.className="mw-portlet-body";navigation.appendChild(portletbody);innerDiv=portletbody;}}
var ul=document.createElement("ul");(innerDiv||outerDiv).appendChild(ul);return outerDiv;};Twinkle.addPortletLink=function(task,text,id,tooltip)
{if(Twinkle.getPref("portletArea")!==null){Twinkle.addPortlet(Twinkle.getPref("portletArea"),Twinkle.getPref("portletId"),Twinkle.getPref("portletName"),Twinkle.getPref("portletType"),Twinkle.getPref("portletNext"));}
var link=mw.util.addPortletLink(Twinkle.getPref("portletId"),typeof task==="string"?task:"#",text,id,tooltip);$('.client-js .skin-vector #p-cactions').css('margin-right','initial');if($.isFunction(task)){$(link).click(function(ev){task();ev.preventDefault();});}
if($.collapsibleTabs){$.collapsibleTabs.handleResize();}
return link;};var scriptpathbefore=mw.util.wikiScript("index")+"?title=",scriptpathafter="&action=raw&ctype=text/javascript";$.ajax({url:scriptpathbefore+"User:"+encodeURIComponent(mw.config.get("wgUserName"))+"/twinkleoptions.js"+scriptpathafter,dataType:"text"}).fail(function(){mw.notify("未能加载twinkleoptions.js");}).done(function(optionsText){if(optionsText===""){return;}
optionsText=optionsText.replace(/(?:^(?:\/\/[^\n]*\n)*\n*|(?:\/\/[^\n]*(?:\n|$))*$)/g,"");if(optionsText.lastIndexOf("window.Twinkle.prefs = ",0)===0){optionsText=optionsText.replace(/(?:^window.Twinkle.prefs = |;\n*$)/g,"");}
try{var options=JSON.parse(optionsText);if(options){Twinkle.prefs=options;}}
catch(e){mw.notify("未能解析twinkleoptions.js");}}).always(function(){$(Twinkle.load);});Twinkle.load=function(){var specialPageWhitelist=['Contributions','DeletedContributions','Prefixindex','AbuseLog'];var isSpecialPage=(mw.config.get('wgNamespaceNumber')===-1&&specialPageWhitelist.indexOf(mw.config.get('wgCanonicalSpecialPageName'))===-1);var isOldIE=($.client.profile().name==='msie'&&$.client.profile().versionNumber<9);if(isSpecialPage||!Twinkle.userAuthorized){return;}
if(isOldIE){mw.notify(wgULS('警告:Twinkle不兼容旧版本IE浏览器,请更换浏览器之后再使用。','警告:Twinkle與舊版本IE瀏覽器不相容,請更換瀏覽器之後再使用。'));return;}
if(window.top!==window.self){return;}
if(window.top!==window.self){return;}
Morebits.wiki.api.setApiUserAgent('Twinkle~zh~/2.0 ('+mw.config.get('wgDBname')+')');Twinkle.arv();Twinkle.warn();if(Morebits.userIsInGroup('sysop')){Twinkle.block();}
Twinkle.talkback();Twinkle.speedy();Twinkle.copyvio();Twinkle.xfd();Twinkle.image();Twinkle.protect();Twinkle.tag();Twinkle.stub();Twinkle.diff();Twinkle.unlink();Twinkle.config.init();Twinkle.fluff.init();if(Morebits.userIsInGroup('sysop')){Twinkle.batchdelete();Twinkle.batchundelete();}
if(Twinkle.getPref('XfdClose')!=='hide'){Twinkle.close();}
Twinkle.addPortletLink(mw.util.wikiScript("index")+"?title="+Twinkle.getPref('configPage'),wgULS('设置','設定'),'tw-config',wgULS('设置Twinkle参数','設定Twinkle參數'));Twinkle.initCallbacks.forEach(function(func){func();});Twinkle.addInitCallback=function(func){func();};if(Twinkle.getPref("dialogLargeFont")){mw.util.addCSS(".morebits-dialog-content, .morebits-dialog-footerlinks { font-size: 100% !important; } "+".morebits-dialog input, .morebits-dialog select, .morebits-dialog-content button { font-size: inherit !important; }");}};}(window,document,jQuery));
// </nowiki>