Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
functionNavboxStuff(){if(mw.config.get('wgAction')=="view"){vargetRedirectTitles=function(nav){varrLinks=nav.getElementsByClassName("mw-redirect");if(rLinks.length==0)return;varrPipe=Array.from(rLinks,r=>r.title).join("|");varrQuery="&redirects="+encodeURIComponent(rPipe);if(navEdit=nav.getElementsByClassName("nv-edit")[0])navEdit.getElementsByTagName("a")[0].href+=rQuery;if(mw.config.get('wgNamespaceNumber')==10)document.getElementById("ca-edit").getElementsByTagName("a")[0].href+=rQuery;};Array.from(document.getElementsByClassName("navbox")).forEach(getRedirectTitles);}if(mw.config.get('wgAction')=="edit"){vartextbox=document.getElementById("wpTextbox1");if(textbox.getAttribute("readonly"))return;varrQuery=newURLSearchParams(location.href).get("redirects");if(!rQuery)return;vartitles=decodeURIComponent(rQuery).split('|');vartargets={};varcount=titles.length;// divide titles into groups of 50 because this is the limitvargetChunks=function(a,n){varr=[];for(vari=0,s=a.length;i<s;i+=n)r.push(a.slice(i,i+n));returnr;}varchunks=getChunks(titles,50);varallDone=false;varf1=function(r){returnr.json();}varf2=function(r){r.query.pages.forEach(mapTarget);}varurlBase="/w/api.php?action=query&prop=revisions&rvprop=content&rvslots=main&format=json&formatversion=2&titles=";varmapTarget=function(p){varcontent=p.revisions[0].slots.main.content;// grab first [[Wikilink]] from content of a known-functional redirectvartRaw=content.match(/(?<=\[\[)[^\[\]]+(?=\]\])/)[0];// normalize underscores and excess spacestargets[p.title]=tRaw.replace(/[\s_]+/g," ").trim();}varreplaceIfAllLoaded=function(){if(allDone||Object.keys(targets).length<count)return;allDone=true;replaceLinks(textbox,targets);}for(vari=0;i<chunks.length;i++){varurl=urlBase+chunks[i].join("|");fetch(url).then(f1).then(f2);}setInterval(replaceIfAllLoaded,250);}}functionreplaceLinks(textbox,dict){varkeys=Object.keys(dict);vartext=textbox.value;for(vari=0;i<keys.length;i++){varredirect=keys[i];vartarget=dict[redirect];if(target.includes('#'))continue;varparts=((FF=redirect[0].toUpperCase())!=(ff=redirect[0].toLowerCase()))?[`[${FF}${ff}]`,redirect.substring(1)]:['',redirect];varparts2=parts[0]+parts[1].replace(/[-\/\\^$*+?.()|[\]{}]/g,'\\$&');varreg1='[\\s_]*('+parts2.replace(/ /g,'[\\s_]+')+')[\\s_]*';varreg=newRegExp("\\[\\["+reg1+"(?:\\|\\s*([^\\[\\]\n]+))?\\s*\\]\\]","g");varreplace2=function(m,mLink,mPipe){if(mPipe){// normalizemPipe=mPipe.replace(/[\s_]+/g," ").trim();// simplify [[Foo|Foo]] → [[Foo]]if(target==mPipe)return`[[${target}]]`;// if existing redirect link is like [[Foo (song)|Foo]]if(redirect.startsWith(mPipe)){// determine the suffix of redirect linkvarsuff=redirect.substring(mPipe.length);// if target title is like "Föó (song)"if(target.endsWith(suff)){// subtract suffix from target title when piping new linkvartPipe=target.substring(0,target.length-suff.length);// [[Föó (song)|Föó]]return`[[${target}|${tPipe}]]`;}return`[[${target}]]`;}// [[Foo|Bar]] became [[Föó|Bar]]return`[[${target}|${mPipe}]]`;}// no return yet means original link was unpiped// if target has parentheses, pipe it anyway [[Foo (film)]] → [[Foo (film)|Foo]]varmPar=target.match(/^([^\(\)]+) \([^\(\)]+\)$/);if(mPar)return`[[${target}|${mPar[1]}]]`;// no special effectsreturn`[[${target}]]`;}text=text.replace(reg,replace2);}if(text==textbox.value)return;textbox.value=text;document.getElementById("wpDiff").click();}NavboxStuff();