User:Bot523/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
// 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();
});