User:Poccil/quickafd.js
From Wikipedia, the free encyclopedia
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.
/* Written by Peter O. Based on [[User:Howcheng/quickimgdelete.js]] */ //<pre><nowiki> // ==Helper functions== // from [[User:Jnothman/automod.js]] function AfdGuessUTCDate() { var monthnames = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var today = new Date(); return today.getUTCFullYear() + ' ' + monthnames[today.getUTCMonth()] + ' ' + today.getUTCDate(); } // From [[en:User:Lupin/autoedit.js]] function AfdGetParamValue(paramName) { var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var h=document.location; var m=cmdRe.exec(h); if (m) { try { return decodeURIComponent(m[1]); } catch (someError) {} } return null; } function qid_afd_openWindow(url, windowName) { if (!windowName) windowName = 'qid_afd_window'; var res = window.open(url, windowName); if (!res) alert("qid_afd_openWindow: window.open() returned null"); } // ==General configuration== qid_afd_autosave = true; // Should the edits be saved automatically? // Site info qid_afd_path = "/w/index.php"; qid_afd_prettypath = "/wiki/"; qid_afd_hostname = window.location.hostname; // ==Automatic 'nominate for deletion' script== // Configuration nfd_text = "Nominate for deletion"; nfd_tooltip = "Nominate this article for deletion"; nfd_prompt = "Why do you want to nominate this article for deletion?"; afd_delReq = "Wikipedia:Articles_for_deletion/Log/"+AfdGuessUTCDate(); function mnx_nomForDel() { var afdcat = promptafdcat(); var reason = prompt(nfd_prompt, ''); if (!reason) return; var pagename = encodeURIComponent(getPname()); qid_afd_openWindow(qid_afd_path + '?title=Wikipedia:Articles_for_deletion/'+pagename + '&afdcat='+afdcat+'&action=edit&fakeaction=mnx_afd2' + '&nomtry=1&afdpage=' + pagename+'&reason='+reason,'qid_afd_afd2_window'); qid_afd_openWindow(qid_afd_path + '?title=' + afd_delReq + '&action=edit&fakeaction=mnx_afd3' + '&afdpage=' + pagename + '&reason=' + encodeURIComponent(reason), 'qid_afd_afd3_window'); var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; window.location = editlk+'&fakeaction=mnx_afd1'; } function mnx_addAFD(template){ var afdpage=AfdGetParamValue('afdpage') var afdcat=AfdGetParamValue('afdcat') var afdreason=AfdGetParamValue('reason') var template='{{subs'+'t:afd2|pg='+afdpage +'|cat='+afdcat +'|text='+afdreason +'}} ~'+'~'+'~'+'~' var editformval = document.editform.wpTextbox1.value.replace(/\s+$/,""); if(editformval==""){ document.editform.wpTextbox1.value = template; summary = template+" : Listing for deletion"; document.editform.wpSummary.value = summary if (qid_afd_autosave) document.editform.wpSave.click(); } else { var nomtry=parseInt(AfdGetParamValue('nomtry'))+1 var newloc=window.location var nextnom=afdpage+"_("+nomtry+ordinalend(nomtry)+"_nomination)" qid_afd_openWindow(qid_afd_path + '?title=Wikipedia:Articles_for_deletion/'+nextnom + '&afdcat='+afdcat+'&action=edit&fakeaction=mnx_afd2' + '&nomtry=1&afdpage='+afdpage+'&reason='+afdreason, 'qid_afd_afd2_window'); } } function ordinalend(num){ if((num%10==1)&&Math.floor((num%100)/10)!=1)return "st" if((num%10==2)&&Math.floor((num%100)/10)!=1)return "nd" if((num%10==3)&&Math.floor((num%100)/10)!=1)return "rd" return "th" } function mnx_addTemplateTop(template) { var editformval = document.editform.wpTextbox1.value; document.editform.wpTextbox1.value = template+"\n"+editformval; summary = template+" : Listing for deletion"; document.editform.wpSummary.value = summary if (qid_afd_autosave) document.editform.wpSave.click(); } function mnx_addTemplateBottom(template) { var editformval = document.editform.wpTextbox1.value; document.editform.wpTextbox1.value = editformval+"\n"+template; summary = template+" : Listing for deletion"; document.editform.wpSummary.value = summary if (qid_afd_autosave) document.editform.wpSave.click(); } function promptafdcat(){ var p=prompt( 'AFD category? [M]Media/music; ' +'[O]Org/product; ' +'[B]Bio; ' +'[S]Society; ' +'[W]Web/ internet; ' +'[G]Game/sport; ' +'[T]Sci/tech;' +'[F]Fiction/arts; ' +'[P]Places; ' +'[I]Don\'t know','U' ) if(!p)return p p=p.toUpperCase() if(p.length!=1||!(/[OBSWGTFPIM]/.test(p))) return "U" return p } function mnx_onload() { addLink('p-tb', 'javascript:mnx_nomForDel()', "Nominate for deletion", 'afd-nominate', "Nominate for deletion"); var fakeaction = AfdGetParamValue('fakeaction'); switch (fakeaction) { case 'mnx_afd1': mnx_addTemplateTop('{{subs'+'t:afd}}'); break; case 'mnx_afd2': mnx_addAFD(); break; case 'mnx_afd3': mnx_addTemplateBottom('{{Wikipedia:Articles for deletion/' +AfdGetParamValue('afdpage')+'}}'); break; } } addOnloadHook(mnx_onload); /* </nowiki></pre> */