Jump to content

User:Bot523/monobook.js

From Wikipedia, the free encyclopedia
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.
//<nowiki>
// AfD decatting, substituting closeboxes
addOnloadHook(function() {
if(location.href.indexOf('afddecat=Y')!=-1)
{
  var subst;
  if(document.editform.wpTextbox1.value.indexOf(
     'The following discussion is an archived debate of the proposed deletion of '+
     'the article below.')==-1
     &&document.editform.wpTextbox1.value.indexOf("{{a"+"t}}")==-1
     &&document.editform.wpTextbox1.value.indexOf("{{afd "+"t}}")==-1
     &&document.editform.wpTextbox1.value.indexOf("{{afd "+"top}}")==-1) {window.close(); return;} //still open, do nothing
  subst=1;
  if(document.editform.wpTextbox1.value.indexOf("{{a"+"t}}")==-1
     &&document.editform.wpTextbox1.value.indexOf("{{afd "+"t}}")==-1
     &&document.editform.wpTextbox1.value.indexOf("{{afd "+"top}}")==-1) subst=0;
  document.editform.wpTextbox1.value=document.editform.wpTextbox1.value.
    split("{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD|").join("{{ns:0|");
  document.editform.wpTextbox1.value=document.editform.wpTextbox1.value.
    split("{{a"+"t}}").join("{{subs"+"t:at}}").split("{{afd "+"t}}").join("{{subs"+"t:at}}").
    split("{{afd "+"top}}").join("{{subs"+"t:at}}");
  document.editform.wpTextbox1.value=document.editform.wpTextbox1.value.
    split("{{a"+"b}}").join("{{subs"+"t:ab}}").split("{{afd "+"b}}").join("{{subs"+"t:ab}}").
    split("{{afd "+"bottom}}").join("{{subs"+"t:ab}}");
  document.editform.wpMinoredit.checked='checked';
  document.editform.wpSummary.value="BOT: Removing [[WP:AFDC|category]] from closed" 
    + " [[WP:AFD|AfD]] debate"+(subst?" and [[WP:SUBST|substing]] closebox":"");
  document.editform.wpSave.click();
}
else if(location.href.indexOf("Wikipedia:Articles_for_deletion/")!=-1) window.close();
});
//</nowiki>