Jump to content
Wikipedia The Free Encyclopedia

User:TheTVExpert/rmCloser.js

From Wikipedia, the free encyclopedia
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.
This user script seems to have a documentation page at User:TheTVExpert/rmCloser.
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.
 //rmCloser
 //<nowiki>
 varrmCloser={};
 window.rmCloser=rmCloser;

 $.when(
 mw.loader.using(['mediawiki.api','ext.gadget.morebits','ext.gadget.libExtraUtil']),
 $.ready
 ).then(function(){
 if(document.getElementById("requestedmovetag")!==null&&Morebits.pageNameNorm.indexOf("alk:")!==-1&&mw.config.get('wgCategories').includes('Requested moves')&&!document.getElementById("wikiPreview")&&mw.config.get('wgDiffOldId')==null){
 document.getElementById("requestedmovetag").innerHTML="<button id='rmCloserClose'>Close</button><button id='rmCloserRelist'>Relist</button><button id='rmCloserNotify'>Notify WikiProjects</button><span id='rmCloserRelistOptions' style='display:none'><input id='rmCloserRelistComment' placeholder='Relisting comment' oninput='if(this.value.length>20){this.size=this.value.length} else{this.size=20}'/><br><button id='rmCloserConfirm'>Confirm relist</button><button id='rmCloserCancel'>Cancel relist</button></span>";
 $('#rmCloserClose').click(rmCloser.callback);
 $('#rmCloserRelist').click(rmCloser.confirmRelist);
 $('#rmCloserConfirm').click(rmCloser.relist);
 $('#rmCloserCancel').click(rmCloser.cancelRelist);
 $('#rmCloserNotify').click(rmCloser.notify);
 }
 });

 rmCloser.confirmRelist=functionrmCloserConfirmRelist(e){
 if(e)e.preventDefault();
 document.getElementById("rmCloserRelistOptions").style.display="inline";
 document.getElementById("rmCloserClose").style.display="none";
 document.getElementById("rmCloserRelist").style.display="none";
 document.getElementById("rmCloserNotify").style.display="none";
 };

 rmCloser.cancelRelist=functionrmCloserCancelRelist(e){
 if(e)e.preventDefault();
 document.getElementById("rmCloserRelistOptions").style.display="none";
 document.getElementById("rmCloserClose").style.display="inline";
 document.getElementById("rmCloserRelist").style.display="inline";
 document.getElementById("rmCloserNotify").style.display="inline";
 };

 rmCloser.advert=' using [[User:TheTVExpert/rmCloser|rmCloser]]';

 rmCloser.callback=functionrmCloserCallback(e){
 if(e)e.preventDefault();

 rmCloser.Window=newMorebits.simpleWindow(600,450);
 rmCloser.Window.setTitle("Close requested move");
 rmCloser.Window.setScriptName('rmCloser');
 rmCloser.Window.addFooterLink('RM Closing instruction','WP:RMCI');
 rmCloser.Window.addFooterLink('Script documentation','User:TheTVExpert/rmCloser');
 rmCloser.Window.addFooterLink('Give feedback','User talk:TheTVExpert/rmCloser');

 varform=newMorebits.quickForm(rmCloser.evaluate);

 varresultField=form.append({
 type:'field',
 label:'Result'
 });

 resultField.append({
 type:'radio',
 name:'result',
 list:[
 {
 label:'Moved',
 value:'moved',
 event:function(){
 document.getElementsByName('customResult')[0].style.display='none';
 document.getElementsByName('customResult')[0].required=false;
 }
 },
 {
 label:'Not moved',
 value:'not moved',
 event:function(){
 document.getElementsByName('customResult')[0].style.display='none';
 document.getElementsByName('customResult')[0].required=false;
 }
 },
 {
 label:'No consensus',
 value:'no consensus',
 event:function(){
 document.getElementsByName('customResult')[0].style.display='none';
 document.getElementsByName('customResult')[0].required=false;
 }
 },
 {
 label:'Custom',
 value:'custom',
 event:function(){
 document.getElementsByName('customResult')[0].style.display='inline';
 document.getElementsByName('customResult')[0].required=true;
 }
 }
 ]
 });

 resultField.append({
 type:'input',
 name:'customResult'
 });

 varclosingCommentField=form.append({
 type:'field',
 label:'Closing comment'
 });

 closingCommentField.append({
 type:'textarea',
 name:'closingComment'
 });

 form.append({type:'submit',label:'Submit'});

 varformResult=form.render();
 rmCloser.Window.setContent(formResult);
 rmCloser.Window.display();

 document.getElementsByName('customResult')[0].style.display='none';
 document.getElementsByName('result')[0].required=true;
 };

 rmCloser.evaluate=function(e){
 varform=e.target;
 rmCloser.params=Morebits.quickForm.getInputData(form);

 Morebits.simpleWindow.setButtonsEnabled(false);
 Morebits.status.init(form);

 vartitle_obj=mw.Title.newFromText(Morebits.pageNameNorm);
 rmCloser.title=title_obj.getSubjectPage().toText();
 rmCloser.talktitle=title_obj.getTalkPage().toText();

 varresult=rmCloser.params.result;
 if(result=='custom'){
 result=rmCloser.params.customResult;
 }

 varclosingComment=rmCloser.params.closingComment;
 if(closingComment!=""){
 closingComment=' '+closingComment;
 closingComment=closingComment.replace(/\|/g,"{{!}}");
 closingComment=closingComment.replace(/=/g,"{{=}}");
 }

 vartalkpage=newMorebits.wiki.page(rmCloser.talktitle,'Closing move.');
 talkpage.load(function(talkpage){
 vartext=talkpage.getPageText();

 vartemplatesOnPage=extraJs.parseTemplates(text,false);
 varoldMovesPresent=[];
 vartemplate;
 for(vari=0;i<templatesOnPage.length;i++){
 if(templatesOnPage[i].name.toLowerCase()=="old moves"||templatesOnPage[i].name.toLowerCase()=="old move"){
 oldMovesPresent.push(templatesOnPage[i]);
 }elseif(templatesOnPage[i].name.toLowerCase()=="requested move/dated"){
 template=templatesOnPage[i];
 }
 }

 vartemplateFound=false;
 varnumberOfMoves=0;
 varline;
 vartemplateIndex=-1;
 varparsedDate;
 varrmSection;
 varnextSection=false;
 vartextToFind=text.split('\n');
 for(vari=0;i<textToFind.length;i++){
 line=textToFind[i];
 if(templateFound==false){
 if(/{{[Rr]equested move\/dated/.test(line)){
 templateFound=true;
 templateIndex=i;
 }
 }elseif(templateFound==true){
 if(/ \(UTC\)/.test(line)){
 line=line.substring(line.indexOf("This is a contested technical request"));
 parsedDate=line.match(/, ([0-9]{1,2} (January|February|March|April|May|June|July|August|September|October|November|December) [0-9]{4}) \(UTC\)/)[1];
 break;
 }elseif(/→/.test(line)){
 numberOfMoves++;
 }
 }
 }

 for(vari=templateIndex;i>=0;i--){
 line=textToFind[i];
 if(line.match(/^(==)[^=].+1円/)){
 rmSection=line.match(/^(==)[^=](.+)1円/)[2].trim();
 break;
 }
 }

 for(vari=templateIndex+1;i<textToFind.length;i++){
 line=textToFind[i];
 if(line.match(/^(==)[^=].+1円/)){
 nextSection=true;
 varescapedLine=line.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,'\\$&')
 varregex=newRegExp('('+escapedLine+')(?![\s\S]*('+escapedLine+'))','m');
 text=text.replace(regex,'{{subst:RM bottom}}\n\n'+line);
 break;
 }
 }

 varuserGroupText="";
 if(Morebits.userIsInGroup('sysop')){
 userGroupText="";
 }elseif(Morebits.userIsInGroup('extendedmover')){
 userGroupText="|pmc=y";
 }else{
 userGroupText="|nac=y";
 }
 text=text.replace(/{{[Rr]equested move\/dated\|.*\n?[^\[]*}}/,"{{subst:RM top|'''"+result+".'''"+closingComment+userGroupText+"}}");

 if(!nextSection){
 text+='\n{{subst:RM bottom}}';
 }

 varmultiMove=false;
 varmoveSectionPlain=rmSection;

 vardate=parsedDate;
 varfrom='';

 vardestination;
 for(vari=0;i<template.parameters.length;i++){
 if(template.parameters[i].name=="multiple"){
 multiMove=true;
 }elseif(template.parameters[i].name=="new1"){
 destination=template.parameters[i].value;
 break;
 }elseif(template.parameters[i].name=="1"){
 destination=template.parameters[i].value;
 }
 }
 if(destination=="?"){
 destination="";
 }

 varlink='Special:Permalink/'+talkpage.getCurrentID()+'#'+moveSectionPlain;

 vararchives=text.match(/{{[Aa]rchives/);
 if(archives==null){
 archives=text.match(/{{[Aa]rchive box/);
 if(archives==null){
 archives=text.match(/{{[Aa]rchivebox/);
 if(archives==null){
 archives=text.match(/==.*==/);
 }
 }
 }

 if(oldMovesPresent.length==0){
 if(result=="moved"){
 from='|from='+rmCloser.title;
 }
 text=text.replace(archives[0],'{{old move'+'|date='+date+from+'|destination='+destination+'|result='+result+'|link='+link+'}}\n\n'+archives[0]);
 }elseif(oldMovesPresent.length==1){
 varisValidFormat=false;
 varisListFormat=false;
 varnumOldMoves=0;
 for(vari=0;i<oldMovesPresent[0].parameters.length;i++){
 varparameterName=oldMovesPresent[0].parameters[i].name;
 parameterName=parameterName.toString();
 if(parameterName=="list"){
 isListFormat=true;
 break;
 }elseif(parameterName=="result1"){
 isValidFormat=true;
 numOldMoves++;
 }elseif(parameterName.includes("result")){
 numOldMoves++;
 }
 }

 if(isValidFormat&&!isListFormat){
 varoldMovesText=oldMovesPresent[0].wikitext;
 numOldMoves++;
 if(result=="moved"){
 from='|from'+numOldMoves+'='+rmCloser.title;
 }
 varnewTextToAdd='|date'+numOldMoves+'='+date+from+'|destination'+numOldMoves+'='+destination+'|result'+numOldMoves+'='+result+'|link'+numOldMoves+'='+link+'}}';
 oldMovesText=oldMovesText.substring(0,oldMovesText.length-2)+newTextToAdd;
 text=text.replace(oldMovesPresent[0].wikitext,oldMovesText);
 }elseif(isListFormat){
 if(result=="moved"){
 from='|from='+rmCloser.title;
 }
 text=text.replace(archives[0],'{{old move'+'|date='+date+from+'|destination='+destination+'|result='+result+'|link='+link+'}}\n\n'+archives[0]);
 }else{
 varoldMovesText='{{'+oldMovesPresent[0].name;
 for(vari=0;i<oldMovesPresent[0].parameters.length;i++){
 if(oldMovesPresent[0].parameters[i].name=="date"){
 oldMovesText+='|date1='+oldMovesPresent[0].parameters[i].value;
 }elseif(oldMovesPresent[0].parameters[i].name=="from"){
 oldMovesText+='|name1='+oldMovesPresent[0].parameters[i].value;
 }elseif(oldMovesPresent[0].parameters[i].name=="destination"){
 oldMovesText+='|destination1='+oldMovesPresent[0].parameters[i].value;
 }elseif(oldMovesPresent[0].parameters[i].name=="result"){
 oldMovesText+='|result1='+oldMovesPresent[0].parameters[i].value;
 }elseif(oldMovesPresent[0].parameters[i].name=="link"){
 oldMovesText+='|link1='+oldMovesPresent[0].parameters[i].value;
 }else{
 oldMovesText+=oldMovesPresent[0].parameters[i].wikitext;
 }
 }
 if(result=="moved"){
 from='|from2='+rmCloser.title;
 }
 varnewTextToAdd='|date2='+date+from+'|destination2='+destination+'|result2='+result+'|link2='+link+'}}';
 oldMovesText+=newTextToAdd;
 text=text.replace(oldMovesPresent[0].wikitext,oldMovesText);
 }

 }else{
 varoldMovesText='{{Old moves';
 varnumOldMoves=1;
 for(vari=0;i<oldMovesPresent.length;i++){
 for(varj=0;j<oldMovesPresent[i].parameters.length;j++){
 if(oldMovesPresent[i].parameters[j].name=="date"){
 oldMovesText+='|date'+numOldMoves+'='+oldMovesPresent[i].parameters[j].value;
 }elseif(oldMovesPresent[i].parameters[j].name=="from"){
 oldMovesText+='|name'+numOldMoves+'='+oldMovesPresent[i].parameters[j].value;
 }elseif(oldMovesPresent[i].parameters[j].name=="destination"){
 oldMovesText+='|destination'+numOldMoves+'='+oldMovesPresent[i].parameters[j].value;
 }elseif(oldMovesPresent[i].parameters[j].name=="result"){
 oldMovesText+='|result'+numOldMoves+'='+oldMovesPresent[i].parameters[j].value;
 }elseif(oldMovesPresent[i].parameters[j].name=="link"){
 oldMovesText+='|link'+numOldMoves+'='+oldMovesPresent[i].parameters[j].value;
 }else{
 oldMovesText+=oldMovesPresent[i].parameters[j].wikitext;
 }
 }
 numOldMoves++;
 }
 if(result=="moved"){
 from='|from'+numOldMoves+'='+rmCloser.title;
 }
 varnewTextToAdd='|date'+numOldMoves+'='+date+from+'|destination'+numOldMoves+'='+destination+'|result'+numOldMoves+'='+result+'|link'+numOldMoves+'='+link+'}}';
 oldMovesText+=newTextToAdd;
 text=text.replace(oldMovesPresent[0].wikitext,oldMovesText);
 for(vari=1;i<oldMovesPresent.length;i++){
 text=text.replace(oldMovesPresent[i].wikitext,"");
 }
 }

 talkpage.setPageText(text);
 talkpage.setEditSummary('Closing requested move; '+result+rmCloser.advert);
 talkpage.save(Morebits.status.actionCompleted('Moved closed.'));

 if(multiMove==true){
 varotherDestinations=[];
 varotherPages=[];
 for(i=2;i<(numberOfMoves+1);i++){
 varcurr;
 vardest;
 for(varj=0;j<template.parameters.length;j++){
 if(template.parameters[j].name==("current"+i)){
 curr=template.parameters[j].value;
 }elseif(template.parameters[j].name==("new"+i)){
 dest=template.parameters[j].value;
 break;
 }
 }

 if(curr!=null&&dest!=null){
 otherPages.push(curr);
 otherDestinations.push(dest);
 }
 }

 varpagesLeft=otherPages.length;
 for(varj=0;j<otherPages.length;j++){
 varotherTitle_obj=mw.Title.newFromText(otherPages[j]);
 rmCloser.otherTalktitle=otherTitle_obj.getTalkPage().toText();
 varotherPage=newMorebits.wiki.page(rmCloser.otherTalktitle,'Adding {{old move}} to '+rmCloser.otherTalktitle+'.');
 otherPage.load(function(otherPage){
 varotherText=otherPage.getPageText();

 vartemplatesOnOtherPage=extraJs.parseTemplates(otherText,false);
 varotherOldMovesPresent=[];
 for(vari=0;i<templatesOnOtherPage.length;i++){
 if(templatesOnOtherPage[i].name.toLowerCase()=="old moves"||templatesOnOtherPage[i].name.toLowerCase()=="old move"){
 otherOldMovesPresent.push(templatesOnOtherPage[i]);
 }
 }

 vartitle=mw.Title.newFromText(otherPage.getPageName()).getSubjectPage().toText();
 varOMcurr=otherPages[otherPages.indexOf(title)];
 varOMdest=otherDestinations[otherPages.indexOf(title)];
 varotherFrom='';
 if(OMdest=="?"){
 OMdest=="";
 }
 varotherDestination=OMdest;
 varotherArchives=otherText.match(/{{[Aa]rchives/);
 if(otherArchives==null){
 otherArchives=otherText.match(/{{[Aa]rchive box/);
 if(otherArchives==null){
 otherArchives=otherText.match(/{{[Aa]rchivebox/);
 if(otherArchives==null){
 otherArchives=otherText.match(/==.*==/);
 }
 }
 }

 if(otherOldMovesPresent.length==0){
 if(result=="moved"){
 otherFrom='|from='+OMcurr;
 }
 otherText=otherText.replace(otherArchives[0],'{{old move'+'|date='+date+otherFrom+'|destination='+otherDestination+'|result='+result+'|link='+link+'}}\n\n'+otherArchives[0]);
 }elseif(otherOldMovesPresent.length==1){
 varisValidFormat=false;
 varisListFormat=false;
 varnumOldMoves=0;
 for(vari=0;i<otherOldMovesPresent[0].parameters.length;i++){
 varparameterName=otherOldMovesPresent[0].parameters[i].name;
 parameterName=parameterName.toString();
 if(parameterName=="list"){
 isListFormat=true;
 break;
 }elseif(parameterName=="result1"){
 isValidFormat=true;
 numOldMoves++;
 }elseif(parameterName.includes("result")){
 numOldMoves++;
 }
 }

 if(isValidFormat&&!isListFormat){
 varoldMovesText=otherOldMovesPresent[0].wikitext;
 numOldMoves++;
 if(result=="moved"){
 otherFrom='|from'+numOldMoves+'='+OMcurr;
 }
 varnewTextToAdd='|date'+numOldMoves+'='+date+otherFrom+'|destination'+numOldMoves+'='+otherDestination+'|result'+numOldMoves+'='+result+'|link'+numOldMoves+'='+link+'}}';
 oldMovesText=oldMovesText.substring(0,oldMovesText.length-2)+newTextToAdd;
 otherText=otherText.replace(otherOldMovesPresent[0].wikitext,oldMovesText);
 }elseif(isListFormat){
 if(result=="moved"){
 otherFrom='|from='+OMcurr;
 }
 otherText=otherText.replace(otherArchives[0],'{{old move'+'|date='+date+otherFrom+'|destination='+otherDestination+'|result='+result+'|link='+link+'}}\n\n'+otherArchives[0]);
 }else{
 varoldMovesText='{{'+otherOldMovesPresent[0].name;
 for(vari=0;i<otherOldMovesPresent[0].parameters.length;i++){
 if(otherOldMovesPresent[0].parameters[i].name=="date"){
 oldMovesText+='|date1='+otherOldMovesPresent[0].parameters[i].value;
 }elseif(otherOldMovesPresent[0].parameters[i].name=="from"){
 oldMovesText+='|name1='+otherOldMovesPresent[0].parameters[i].value;
 }elseif(otherOldMovesPresent[0].parameters[i].name=="destination"){
 oldMovesText+='|destination1='+otherOldMovesPresent[0].parameters[i].value;
 }elseif(otherOldMovesPresent[0].parameters[i].name=="result"){
 oldMovesText+='|result1='+otherOldMovesPresent[0].parameters[i].value;
 }elseif(otherOldMovesPresent[0].parameters[i].name=="link"){
 oldMovesText+='|link1='+otherOldMovesPresent[0].parameters[i].value;
 }else{
 oldMovesText+=otherOldMovesPresent[0].parameters[i].wikitext;
 }
 }
 if(result=="moved"){
 otherFrom='|from2='+OMcurr;
 }
 varnewTextToAdd='|date2='+date+otherFrom+'|destination2='+otherDestination+'|result2='+result+'|link2='+link+'}}';
 oldMovesText+=newTextToAdd;
 otherText=otherText.replace(otherOldMovesPresent[0].wikitext,oldMovesText);
 }

 }else{
 varoldMovesText='{{Old moves';
 varnumOldMoves=1;
 for(vari=0;i<otherOldMovesPresent.length;i++){
 for(varj=0;j<otherOldMovesPresent[i].parameters.length;j++){
 if(otherOldMovesPresent[i].parameters[j].name=="date"){
 oldMovesText+='|date'+numOldMoves+'='+otherOldMovesPresent[i].parameters[j].value;
 }elseif(otherOldMovesPresent[i].parameters[j].name=="from"){
 oldMovesText+='|name'+numOldMoves+'='+otherOldMovesPresent[i].parameters[j].value;
 }elseif(otherOldMovesPresent[i].parameters[j].name=="destination"){
 oldMovesText+='|destination'+numOldMoves+'='+otherOldMovesPresent[i].parameters[j].value;
 }elseif(otherOldMovesPresent[i].parameters[j].name=="result"){
 oldMovesText+='|result'+numOldMoves+'='+otherOldMovesPresent[i].parameters[j].value;
 }elseif(otherOldMovesPresent[i].parameters[j].name=="link"){
 oldMovesText+='|link'+numOldMoves+'='+otherOldMovesPresent[i].parameters[j].value;
 }else{
 oldMovesText+=otherOldMovesPresent[i].parameters[j].wikitext;
 }
 }
 numOldMoves++;
 }
 if(result=="moved"){
 otherFrom='|from'+numOldMoves+'='+OMcurr;
 }
 varnewTextToAdd='|date'+numOldMoves+'='+date+otherFrom+'|destination'+numOldMoves+'='+otherDestination+'|result'+numOldMoves+'='+result+'|link'+numOldMoves+'='+link+'}}';
 oldMovesText+=newTextToAdd;
 otherText=otherText.replace(otherOldMovesPresent[0].wikitext,oldMovesText);
 for(vari=1;i<otherOldMovesPresent.length;i++){
 otherText=otherText.replace(otherOldMovesPresent[i].wikitext,"");
 }
 }

 otherPage.setPageText(otherText);
 otherPage.setEditSummary('Closing requested move; '+result+rmCloser.advert);
 otherPage.save(Morebits.status.actionCompleted('Moved closed.'));
 pagesLeft--;
 });
 }

 if(result=="moved"){
 varwaitInterval=setInterval(function(){
 if(pagesLeft==0){
 rmCloser.movePages(rmCloser.title,destination,otherPages,otherDestinations,link);
 clearInterval(waitInterval);
 }
 },500);
 }else{
 setTimeout(function(){location.reload()},2000);
 }
 }elseif(result=="moved"){
 varemptyArray=[];
 rmCloser.movePages(rmCloser.title,destination,emptyArray,emptyArray,link);
 }else{
 setTimeout(function(){location.reload()},2000);
 }
 });
 };

 rmCloser.movePages=functionrmCloserMovePages(curr1,dest1,currList,destList,link){
 varnumberToRemove=currList.length+1;

 rmCloser.talktitle=mw.Title.newFromText(Morebits.pageNameNorm).getTalkPage().toText();
 varpageAndSection=link;
 varmoveSummary='Moved per [['+pageAndSection+']]';
 varrmtrReason='Per [['+pageAndSection+']].';

 varform=newMorebits.quickForm();

 form.append({
 type:'header',
 label:'Move pages'
 });

 form.append({
 type:'div',
 className:'rmCloserMovePages'+curr1,
 label:curr1+' → '+dest1
 });

 form.append({
 type:'button',
 className:'rmCloserMovePages'+curr1,
 label:'Move directly',
 event:function(){
 rmCloser.directMove(curr1,dest1,false,moveSummary);
 for(vari=0;i<document.getElementsByClassName('rmCloserMovePages'+curr1).length;i++){
 document.getElementsByClassName('rmCloserMovePages'+curr1)[i].style.display='none';
 }
 numberToRemove--;
 }
 });

 if(!Morebits.userIsInGroup('sysop')&&!Morebits.userIsInGroup('extendedmover')){
 form.append({
 type:'button',
 className:'rmCloserMovePages'+curr1,
 label:'Submit technical request',
 event:function(){
 rmCloser.submitRMTR(curr1,dest1,rmtrReason);
 for(vari=0;i<document.getElementsByClassName('rmCloserMovePages'+curr1).length;i++){
 document.getElementsByClassName('rmCloserMovePages'+curr1)[i].style.display='none';
 }
 numberToRemove--;
 }
 });
 }else{
 form.append({
 type:'button',
 className:'rmCloserMovePages'+curr1,
 label:'Move directly without leaving a redirect',
 event:function(){
 rmCloser.directMove(curr1,dest1,true,moveSummary);
 for(vari=0;i<document.getElementsByClassName('rmCloserMovePages'+curr1).length;i++){
 document.getElementsByClassName('rmCloserMovePages'+curr1)[i].style.display='none';
 }
 numberToRemove--;
 }
 });
 }

 for(vari=0;i<currList.length;i++){
 form.append({
 type:'div',
 className:'rmCloserMovePages'+currList[i],
 label:currList[i]+' → '+destList[i]
 });
 form.append({
 type:'button',
 className:'rmCloserMovePages'+currList[i],
 name:currList[i],
 extra:destList[i],
 label:'Move directly',
 event:function(){
 rmCloser.directMove(this.name,this.extra,false,moveSummary);
 for(varj=0;j<document.getElementsByClassName('rmCloserMovePages'+this.name).length;j++){
 document.getElementsByClassName('rmCloserMovePages'+this.name)[j].style.display='none';
 }
 numberToRemove--;
 }
 });
 if(!Morebits.userIsInGroup('sysop')&&!Morebits.userIsInGroup('extendedmover')){
 form.append({
 type:'button',
 className:'rmCloserMovePages'+currList[i],
 name:currList[i],
 extra:destList[i],
 label:'Submit technical request',
 event:function(){
 rmCloser.submitRMTR(this.name,this.extra,rmtrReason);
 for(varj=0;j<document.getElementsByClassName('rmCloserMovePages'+this.name).length;j++){
 document.getElementsByClassName('rmCloserMovePages'+this.name)[j].style.display='none';
 }
 numberToRemove--;
 }
 });
 }else{
 form.append({
 type:'button',
 className:'rmCloserMovePages'+currList[i],
 name:currList[i],
 extra:destList[i],
 label:'Move directly without leaving a redirect',
 event:function(){
 rmCloser.directMove(this.name,this.extra,true,moveSummary);
 for(varj=0;j<document.getElementsByClassName('rmCloserMovePages'+this.name).length;j++){
 document.getElementsByClassName('rmCloserMovePages'+this.name)[j].style.display='none';
 }
 numberToRemove--;
 }
 });
 }
 }

 varformResult=form.render();
 rmCloser.Window.setContent(formResult);
 rmCloser.Window.display();

 varmoveInterval=setInterval(function(){
 if(numberToRemove==0){
 rmCloser.Window.close();
 clearInterval(moveInterval);
 setTimeout(function(){location.reload()},2000);
 }
 },500);
 };

 rmCloser.directMove=functionrmCloserDirectMove(curr,dest,suppressRedirect,editSummary){
 varpageToMove=newMorebits.wiki.page(curr,'Moving '+curr+' to '+dest+'.');
 pageToMove.setMoveDestination(dest);
 pageToMove.setMoveSubpages(true);
 pageToMove.setMoveTalkPage(true);
 pageToMove.setMoveSuppressRedirect(suppressRedirect);
 pageToMove.setEditSummary(editSummary+rmCloser.advert);
 pageToMove.move(Morebits.status.actionCompleted('Moved.'));
 };

 rmCloser.submitRMTR=functionrmCloserSubmitRMTR(curr,dest,reason){
 varrmtr=newMorebits.wiki.page('Wikipedia:Requested moves/Technical requests','Submitting request at WP:RM/TR');
 rmtr.load(function(page){
 vartext=rmtr.getPageText();
 vartextToFind=/\n{1,}(==== ?Requests to revert undiscussed moves ?====)/i;
 varrmtrText='{{subst:RMassist|1='+curr+'|2='+dest+'|reason='+reason+'}}';
 text=text.replace(textToFind,'\n'+rmtrText+'\n\n1ドル');
 rmtr.setPageText(text);
 rmtr.setEditSummary('Add request'+rmCloser.advert);
 rmtr.save(Morebits.status.actionCompleted('Requested.'));
 });
 };

 rmCloser.relist=functionrmCloserRelist(e){
 if(e)e.preventDefault();
 vartitle_obj=mw.Title.newFromText(Morebits.pageNameNorm);
 rmCloser.talktitle=title_obj.getTalkPage().toText();
 vartalkpage=newMorebits.wiki.page(rmCloser.talktitle,'Relisting.');

 varrelistingComment=document.getElementById('rmCloserRelistComment').value;

 talkpage.load(function(talkpage){
 vartext=talkpage.getPageText();

 vartemplateFound=false;
 varsig;
 varline;
 vartemplateIndex=-1;
 vartextToFind=text.split('\n');
 for(vari=0;i<textToFind.length;i++){
 line=textToFind[i];
 if(templateFound==false){
 if(/{{[Rr]equested move\/dated/.test(line)){
 templateFound=true;
 templateIndex=i;
 }
 }elseif(templateFound==true){
 if(/ \(UTC\)/.test(line)){
 sig=line;
 break;
 }
 }
 }

 text=text.replace(sig,sig+" {{subst:RM relist}}");

 if(relistingComment!=''){
 varnextSection=false;
 for(vari=templateIndex+1;i<textToFind.length;i++){
 line=textToFind[i];
 if(line.match(/^(==)[^=].+1円/)){
 nextSection=true;
 varescapedLine=line.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,'\\$&')
 varregex=newRegExp('('+escapedLine+')(?![\s\S]*('+escapedLine+'))','m');
 text=text.replace(regex,':<small>\'\'\'Relisting comment\'\'\': '+relistingComment+' ~~~~</small>\n\n'+line);
 break;
 }
 }

 if(!nextSection){
 text+='\n:<small>\'\'\'Relisting comment\'\'\': '+relistingComment+' ~~~~</small>';
 }
 }

 talkpage.setPageText(text);
 talkpage.setEditSummary('Relisted requested move'+rmCloser.advert);
 talkpage.save(Morebits.status.actionCompleted('Relisted.'));
 document.getElementById("requestedmovetag").innerHTML="";
 setTimeout(function(){location.reload()},2000);
 });
 };

 rmCloser.notify=functionrmCloserNotify(e){
 if(e)e.preventDefault();
 varwikiProjectTemplates=document.getElementsByClassName("wpb-project_link");
 varwikiProjectNames=[];
 varwikiProjects=[];
 for(vari=0;i<wikiProjectTemplates.length;i++){
 varwikiProjectName=wikiProjectTemplates[i].innerHTML;
 varwikiProjectTalk=mw.Title.newFromText(wikiProjectTemplates[i].innerHTML).getTalkPage().toText();
 if(!wikiProjectNames.includes(wikiProjectName)){
 wikiProjectNames.push(wikiProjectName);
 wikiProjects.push(wikiProjectTalk);
 }
 }

 varwikiProjectBannerShellHeaders=document.getElementsByClassName("wpb-header-combined");
 for(vari=0;i<wikiProjectBannerShellHeaders.length;i++){
 varsubprojectList=wikiProjectBannerShellHeaders[i];
 if(subprojectList.hasChildNodes()&&subprojectList.children.length>2){
 subprojectList=subprojectList.children[2];
 if(subprojectList.hasChildNodes()&&subprojectList.children.length>0){
 subprojectList=subprojectList.children;
 for(varj=0;j<subprojectList.length;j++){
 varwikiProjectName=subprojectList[j].title;
 varwikiProjectTalk=mw.Title.newFromText(subprojectList[j].title).getTalkPage().toText();
 if(!wikiProjectNames.includes(wikiProjectName)){
 wikiProjectNames.push(wikiProjectName);
 wikiProjects.push(wikiProjectTalk);
 }
 }
 }
 }
 }

 if(wikiProjects.length==0){
 mw.notify('No WikiProject banners found on this page');
 }else{
 varWindow=newMorebits.simpleWindow(600,450);
 Window.setTitle("Notify WikiProjects about requested move");
 Window.setScriptName('rmCloser');
 Window.addFooterLink('Script documentation','User:TheTVExpert/rmCloser');
 Window.addFooterLink('Give feedback','User talk:TheTVExpert/rmCloser');

 varform=newMorebits.quickForm(rmCloser.notifyCheck);

 form.append({
 type:'div',
 label:'WikiProjects with banners on this page:'
 });

 form.append({
 type:'checkbox',
 name:'wikiProject',
 list:wikiProjects.map(function(wp){
 varwplabel=wikiProjectNames[wikiProjects.indexOf(wp)];
 return{type:'option',label:wplabel,value:wp};
 })
 });

 if(wikiProjects[0]!='none'){
 form.append({type:'submit',label:'Notify selected WikiProject(s)'});
 }

 varformResult=form.render();
 Window.setContent(formResult);
 Window.display();
 }
 };

 rmCloser.notifyCheck=function(e){
 varform=e.target;
 rmCloser.params=Morebits.quickForm.getInputData(form);

 Morebits.simpleWindow.setButtonsEnabled(false);
 Morebits.status.init(form);

 varwikiProjectsToNotify=rmCloser.params.wikiProject;

 if(wikiProjectsToNotify.length==0){
 Morebits.status.error('Error','No WikiProjects selected');
 }else{
 varuniqueWikiProjects=[];
 varwikiProjectCount=0;
 for(vari=0;i<wikiProjectsToNotify.length;i++){
 vartalkpage=newMorebits.wiki.page(wikiProjectsToNotify[i],'Checking '+wikiProjectsToNotify[i]+'.');
 talkpage.setFollowRedirect(true);
 talkpage.load(function(talkpage){
 varwikiProjectToNotify=talkpage.getPageName();
 if(!uniqueWikiProjects.includes(wikiProjectToNotify)){
 uniqueWikiProjects.push(wikiProjectToNotify);
 }
 wikiProjectCount++;
 if(wikiProjectCount==wikiProjectsToNotify.length&&uniqueWikiProjects.length>0){
 rmCloser.notifyGetSection(uniqueWikiProjects);
 }
 });
 }
 }
 };

 rmCloser.notifyGetSection=function(wikiProjectsToNotify){
 vartitle_obj=mw.Title.newFromText(Morebits.pageNameNorm);
 rmCloser.talktitle=title_obj.getTalkPage().toText();
 vartalkpage=newMorebits.wiki.page(rmCloser.talktitle,'Getting section.');

 talkpage.load(function(talkpage){
 vartext=talkpage.getPageText();
 varline;
 vartemplateIndex=-1;
 varrmSection;
 vartextToFind=text.split('\n');
 for(vari=0;i<textToFind.length;i++){
 line=textToFind[i];
 if(/{{[Rr]equested move\/dated/.test(line)){
 templateIndex=i;
 break;
 }
 }

 for(vari=templateIndex;i>=0;i--){
 line=textToFind[i];
 if(line.match(/^(==)[^=].+1円/)){
 rmSection=line.match(/^(==)[^=](.+)1円/)[2].trim();
 break;
 }
 }

 rmCloser.notifyEvaluate(wikiProjectsToNotify,rmSection);
 });
 };

 rmCloser.notifyEvaluate=function(wikiProjectsToNotify,moveSection){
 varwikiProjectsNotified=[];
 varwikiProjectCount=0;
 for(varj=0;j<wikiProjectsToNotify.length;j++){
 vartalkpage=newMorebits.wiki.page(wikiProjectsToNotify[j],'Notifying '+wikiProjectsToNotify[j]+'.');
 talkpage.setFollowRedirect(true);
 talkpage.load(function(talkpage){
 varwikiProjectToNotify=talkpage.getPageName();
 vartext=talkpage.getPageText();

 rmCloser.talktitle=mw.Title.newFromText(Morebits.pageNameNorm).getTalkPage().toText();
 varpageAndSection=rmCloser.talktitle+"#"+moveSection;

 varnotified;

 if(confirm("\""+wikiProjectToNotify+"\" may have already been notified of the discussion. Do you wish to proceed?")){
 text+="\n\n== Requested move at [["+pageAndSection+"]] ==\n[[File:Information.svg|30px|left]] There is a requested move discussion at [["+pageAndSection+"]] that may be of interest to members of this WikiProject. ~~~~";

 talkpage.setPageText(text);
 talkpage.setEditSummary('Notifying of [['+pageAndSection+'\|requested move]]'+rmCloser.advert);
 talkpage.save(Morebits.status.actionCompleted('Notified.'));
 notified=true;
 }else{
 varcancelNotify=newMorebits.status('Error','Notification canceled','error');
 notified=false;
 }

 if(notified){
 wikiProjectsNotified.push(wikiProjectToNotify);
 }

 wikiProjectCount++;

 if(wikiProjectCount==wikiProjectsToNotify.length&&wikiProjectsNotified.length>0){
 rmCloser.notifyListOnTalkPage(wikiProjectsNotified);
 }
 });
 }
 };

 rmCloser.notifyListOnTalkPage=function(wikiProjectsNotified){
 vardiscussionPage=newMorebits.wiki.page(rmCloser.talktitle,'Adding note about notification to requested move');
 discussionPage.load(function(discussionPage){
 vardiscussionPageText=discussionPage.getPageText();

 vartemplateFound=false;
 varline;
 varnextSection=false;
 vartextToFind=discussionPageText.split('\n');
 for(vari=0;i<textToFind.length;i++){
 line=textToFind[i];
 if(templateFound==false){
 if(/{{[Rr]equested move\/dated/.test(line)){
 templateFound=true;
 }
 }elseif(templateFound==true){
 if(line.match(/^(==)[^=].+1円/)){
 nextSection=true;
 varescapedLine=line.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,'\\$&')
 varregex=newRegExp('('+escapedLine+')(?![\s\S]*('+escapedLine+'))','m');
 if(wikiProjectsNotified.length==1){
 varwikiProjectToNotify=wikiProjectsNotified[0];
 discussionPageText=discussionPageText.replace(regex,':<small>Note: [['+wikiProjectToNotify+'|'+wikiProjectToNotify.slice(15)+']] has been notified of this discussion. ~~~~</small>\n\n'+line);
 }else{
 vartextToInsert=':<small>Note: ';
 for(varj=0;j<wikiProjectsNotified.length;j++){
 varwikiProjectToNotify=wikiProjectsNotified[j];
 textToInsert+='[['+wikiProjectToNotify+'|'+wikiProjectToNotify.slice(15)+']]';
 if(j==wikiProjectsNotified.length-2){
 if(wikiProjectsNotified.length==2){
 textToInsert+=' and ';
 }else{
 textToInsert+=', and ';
 }
 }elseif(j!=wikiProjectsNotified.length-1){
 textToInsert+=', ';
 }
 }
 textToInsert+=' have been notified of this discussion. ~~~~</small>\n\n';
 discussionPageText=discussionPageText.replace(regex,textToInsert+line);
 }
 break;
 }
 }
 }

 if(!nextSection){
 if(wikiProjectsNotified.length==1){
 varwikiProjectToNotify=wikiProjectsNotified[0];
 discussionPageText+='\n:<small>Note: [['+wikiProjectToNotify+'|'+wikiProjectToNotify.slice(15)+']] has been notified of this discussion. ~~~~</small>';
 }else{
 discussionPageText+='\n:<small>Note: ';
 for(varj=0;j<wikiProjectsNotified.length;j++){
 varwikiProjectToNotify=wikiProjectsNotified[j];
 discussionPageText+='[['+wikiProjectToNotify+'|'+wikiProjectToNotify.slice(15)+']]';
 if(j==wikiProjectsNotified.length-2){
 if(wikiProjectsNotified.length==2){
 discussionPageText+=' and ';
 }else{
 discussionPageText+=', and ';
 }
 }elseif(j!=wikiProjectsNotified.length-1){
 discussionPageText+=', ';
 }
 }
 discussionPageText+=' have been notified of this discussion. ~~~~</small>';
 }
 }

 discussionPage.setPageText(discussionPageText);
 discussionPage.setEditSummary('Added note about notifying WikiProject about requested move'+rmCloser.advert);
 discussionPage.save(Morebits.status.actionCompleted('Note added.'));
 setTimeout(function(){location.reload()},2000);
 });
 };
 //</nowiki>

AltStyle によって変換されたページ (->オリジナル) /