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.
// <source lang="javascript">//Script to automate closing XfDs by adding a 'close' links to XfD debates//written by [[User:Gogo Dodo]] inspired by [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]] and [[User:Jnothman/afd helper/script.js]]functioncloseXfD_links(){// no point in running unless in view modeif(mw.config.get('wgAction')=='view'){// Articles for Deletionif(mw.config.get('wgTitle').indexOf('Articles for deletion/Log/')==0){varanchorsAll=document.getElementById('bodyContent').getElementsByTagName('a');varurl_re=/\?title=Wikipedia:Articles_for_deletion\/[^&]+&action=edit§ion=T-1/;varanchorsToAdd=newArray();for(vari=0;i<anchorsAll.length;i++){if(anchorsAll[i].parentNode.className=='editsection'&&anchorsAll[i].href.match(url_re)){anchorsToAdd.push(anchorsAll[i]);}}closeXfD_addlinks(anchorsToAdd);return;}// Articles for Deletion sub-pageif(mw.config.get('wgTitle').indexOf('Articles for deletion/')==0){varanchorsAll=document.getElementById('bodyContent').getElementsByTagName('a');varurl_re=/\?title=Wikipedia:Articles_for_deletion\/[^&]+&action=edit§ion=1/;varanchorsToAdd=newArray();for(vari=0;i<anchorsAll.length;i++){if(anchorsAll[i].parentNode.className=='editsection'&&anchorsAll[i].href.match(url_re)){anchorsToAdd.push(anchorsAll[i]);}}closeXfD_addlinks(anchorsToAdd);return;}// Files for deletionif(mw.config.get('wgTitle').indexOf('Files for deletion')==0){varanchorsAll=document.getElementById('bodyContent').getElementsByTagName('a');varurl_re=/\?title=Wikipedia:Files_for_deletion\/[^&]+&action=edit§ion=(T-)?([2-9]|\d\d+)/;varanchorsToAdd=newArray();for(vari=0;i<anchorsAll.length;i++){if(anchorsAll[i].parentNode.className=='editsection'&&anchorsAll[i].href.match(url_re)){anchorsToAdd.push(anchorsAll[i]);}}closeXfD_addlinks(anchorsToAdd);return;}// Miscellany for deletionif(mw.config.get('wgTitle')=='Miscellany for deletion'){varanchorsAll=document.getElementById('bodyContent').getElementsByTagName('a');varurl_re=/\?title=Wikipedia:Miscellany_for_deletion\/[^&]+&action=edit&/;varanchorsToAdd=newArray();for(vari=0;i<anchorsAll.length;i++){if(anchorsAll[i].parentNode.className=='editsection'&&anchorsAll[i].href.match(url_re)&&anchorsAll[i].href.indexOf('/Front_matter&action=edit')==-1){anchorsToAdd.push(anchorsAll[i]);}}closeXfD_addlinks(anchorsToAdd);return;}// Redirects for discussionif(mw.config.get('wgTitle').indexOf('Redirects for discussion')==0){varanchorsAll=document.getElementById('bodyContent').getElementsByTagName('a');varurl_re=/\?title=Wikipedia:Redirects_for_discussion\/[^&]+&action=edit§ion=(T-)?([2-9]|\d\d+)/;varanchorsToAdd=newArray();for(vari=0;i<anchorsAll.length;i++){if(anchorsAll[i].parentNode.className=='editsection'&&anchorsAll[i].href.match(url_re)&&anchorsAll[i].href.indexOf('/Header&action=edit')==-1){anchorsToAdd.push(anchorsAll[i]);}}closeXfD_addlinks(anchorsToAdd);return;}// Templates for deletionif(mw.config.get('wgTitle').indexOf('Templates for deletion')==0){varanchorsAll=document.getElementById('bodyContent').getElementsByTagName('a');varurl_re=/\?title=Wikipedia:Templates_for_deletion\/[^&]+&action=edit§ion=(T-)?([2-9]|\d\d+)/;varanchorsToAdd=newArray();for(vari=0;i<anchorsAll.length;i++){if(anchorsAll[i].parentNode.className=='editsection'&&anchorsAll[i].href.match(url_re)&&anchorsAll[i].href.indexOf('/Header&action=edit')==-1&&anchorsAll[i].href.indexOf('/Holding_cell&action=edit')==-1){anchorsToAdd.push(anchorsAll[i]);}}closeXfD_addlinks(anchorsToAdd);return;}}}functioncloseXfD_action(){// no point in running unless in edit modeif(mw.config.get('wgAction')=='edit'&&document.location.search.indexOf('&closeXfD=true')!=-1){varresult=prompt("Result of discussion?");// check if no result entered and if not exitif(result==null||result=="")return;varcomments=prompt("Comments?");varnonadmin=" ([[Wikipedia:Non-admin closure|non-admin closure]])";if(typeofmw.config.get('wgUserGroups')=="object"&&mw.config.get('wgUserGroups')){for(varg=0;g<mw.config.get('wgUserGroups').length;++g){if(mw.config.get('wgUserGroups')[g]=="sysop"){nonadmin="";break;}}}varf=document.editform,t=f.wpTextbox1;if(document.title.indexOf("Editing Wikipedia:Articles for deletion/")!=-1){varsearchKey=newRegExp('{'+'{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD..}}\n','i');t.value=t.value.replace(searchKey,"");t.value="{"+"{subst:"+"at"+"}} '''"+result+"'''."+nonadmin+" "+comments+" ~"+"~"+"~"+"~\n\n"+t.value;t.value+="\n{"+"{subst:"+"ab"+"}}";}if(document.title.indexOf("Editing Wikipedia:Files for deletion/")!=-1){t.value=t.value.substr(0,t.value.indexOf('\n'))+"\n{"+"{subst:"+"ffd top"+"}} '''"+result+"'''."+nonadmin+" "+comments+" ~"+"~"+"~"+"~\n"+t.value.substr(t.value.indexOf('\n'));t.value+="\n{"+"{subst:"+"ffd bottom"+"}}";}if(document.title.indexOf("Editing Wikipedia:Miscellany for deletion/")!=-1){t.value="{"+"{subst:"+"mfd top"+"}} '''"+result+"'''."+nonadmin+" "+comments+" ~"+"~"+"~"+"~\n\n"+t.value;t.value+="\n{"+"{subst:"+"mfd bottom"+"}}";}if(document.title.indexOf("Editing Wikipedia:Redirects for discussion/")!=-1){t.value=t.value.substr(0,t.value.indexOf('\n'))+"\n{"+"{subst:"+"rfd top"+"}} '''"+result+"'''."+nonadmin+" "+comments+" ~"+"~"+"~"+"~\n"+t.value.substr(t.value.indexOf('\n'));t.value+="{"+"{subst:"+"rfd bottom"+"}}";}if(document.title.indexOf("Editing Wikipedia:Templates for deletion/")!=-1){t.value=t.value.substr(0,t.value.indexOf('\n'))+"\n{"+"{subst:"+"tfd top"+"}} '''"+result+"'''."+nonadmin+" "+comments+" ~"+"~"+"~"+"~\n"+t.value.substr(t.value.indexOf('\n'));t.value+="{"+"{subst:"+"tfd bottom"+"}}";}f.wpSummary.value="Closing debate; result was "+result+nonadmin;}}functioncloseXfD_addlinks(anchorsToAdd){for(vari=0;i<anchorsToAdd.length;i++){varcloselink=document.createElement('a');closelink.href=anchorsToAdd[i].href+'&closeXfD=true';closelink.title='Close XfD';closelinktext=document.createElement('sup');closelinktext.appendChild(document.createTextNode(' Close '));closelink.appendChild(closelinktext);anchorsToAdd[i].parentNode.insertBefore(closelink,anchorsToAdd[i].nextSibling);}}$(closeXfD_links);$(closeXfD_action);//end XfD closing script// </source>