User:Mathwiz2020/afdcloser.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.
//<pre><nowiki> /************* afd closer************/ // adapted from User:Jnothman/afd_helper/script.js document.write('<script type="text/javascript"' + 'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/automod.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); afdc_signature = '~~'+'~'; afdc_summaryprompt = true; afdc_shortcuts = Array(); afdc_shortcuts['d'] = 'deleted'; afdc_shortcuts['sd'] = 'speedily deleted'; afdc_shortcuts['k'] = 'kept'; afdc_shortcuts['m'] = 'merged'; afdc_shortcuts['mv'] = 'moved'; afdc_shortcuts['rd'] = 'redirected'; afdc_shortcuts['rw'] = 'rewritten'; afdc_shortcuts['t'] = 'transwikied'; afdc_commscs = Array(); afdc_commscs['G1'] = 'patent nonsense.'; afdc_commscs['G2'] = 'test.'; afdc_commscs['G3'] = 'pure vandalism.'; afdc_commscs['G4'] = 'repost.'; afdc_commscs['G5'] = 'banned user.'; afdc_commscs['G6'] = 'history merging.'; afdc_commscs['G7'] = 'author request.'; afdc_commscs['G8'] = 'talk page of deleted article.'; afdc_commscs['G9'] = 'making room for move.'; afdc_commscs['A1'] = 'no context.'; afdc_commscs['A2'] = 'not English.'; afdc_commscs['A3'] = 'no content.'; afdc_commscs['A5'] = 'transwikied.'; afdc_commscs['A6'] = 'attack.'; afdc_commscs['A7'] = 'unremarkable people or groups.'; afdc_commscs['A8'] = 'blatant copy-vio.'; afdc_commscs['R1'] = 'redirects to non-existent page.'; afdc_commscs['R2'] = 'redirects to user page.'; afdc_commscs['R3'] = 'redirect from a typo.'; afdc_commscs['I1'] = 'redundant image.'; afdc_commscs['I2'] = 'corrupt image.'; afdc_commscs['I3'] = 'improperly licensed image.'; afdc_commscs['I4'] = 'lack of licensing on image.'; afdc_commscs['I5'] = 'unused copyrighted images.'; afdc_commscs['C1'] = 'empty category.'; afdc_commscs['C2'] = 'speedy renaming.'; afdc_commscs['C3'] = 'template categories.'; afdc_commscs['U1'] = 'user page deletion by users request.'; afdc_commscs['U2'] = 'recycling IP user pages.'; function afd_closer() { if (auto_mod()) return; var anchors = new Array(); { var oldanchors = document.getElementById('bodyContent').getElementsByTagName('a'); for (var i=0; i < oldanchors.length; i++) anchors[i] = oldanchors[i]; } var url_re = /\?title=Wikipedia:Articles_for_deletion\/([^&]+)&action=edit&/; var url, matches; for (var i=0; i < anchors.length; i++) { if (!(matches = anchors[i].href.match(url_re)) || (matches[1].substr(0, 4) == 'Log/')) continue; var na = document.createElement('a'); na.href = "javascript:afd_close('"+escape(anchors[i].href)+"')"; na.title = "Close the AfD of "+unescape(matches[1]); var inlink = document.createElement('sup'); inlink.appendChild(document.createTextNode(' | close')); na.appendChild(inlink); anchors[i].parentNode.insertBefore(na, anchors[i].nextSibling); } } function afd_close(edit_link) { var shortcuts_list = ''; for (var key in afdc_shortcuts) shortcuts_list += key + ': ' + afdc_shortcuts[key] + '; '; var vote = window.prompt("Enter the result. (Shortcuts available are: "+shortcuts_list+")"); if (!vote) return; if (afdc_shortcuts[vote.toLowerCase()]) vote = afdc_shortcuts[vote.toLowerCase()]; shortcuts_list = ''; for (var key in afdc_commscs) shortcuts_list += key + ': ' + afdc_commscs[key] + '; '; var comment = window.prompt("Enter the reason. (Shortcuts available are: "+shortcuts_list+")"); if (typeof comment != 'string') return; if (afdc_commscs[comment.toUpperCase()]) comment = "as per CSD " + comment.toUpperCase() + ": " + afdc_commscs[comment.toUpperCase()]; var summary = "closed AfD"; if (afdc_summaryprompt) if (!(summary = window.prompt("Enter the edit summary:", summary))) summary = "closed AfD"; var url = edit_link + '&amaddbefore='+escape("{{subst:at}} '''"+vote+"''' "+comment+" "+afdc_signature+" ~~"+"~~"+"~") + '&amaddafter='+escape("{{subst:ab}}") + '&amsummary='+escape(summary); if (window.location.href.indexOf("/Log/") == -1) window.location.href = url; else window.open(url, "afd_helper_close"); } addOnloadHook(afd_closer); //</nowiki></pre>