User:Jnothman/afd helper/script.js
Appearance
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. |
![]() | This user script seems to have a documentation page at User:Jnothman/afd helper/script. |
/************* afd Helper ************/
// see User:Jnothman/afd_helper
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>');
afdh_signature = '~~'+'~';
afdh_summaryprompt = true;
afdh_shortcuts = Array();
afdh_shortcuts['d'] = 'Delete';
afdh_shortcuts['k'] = 'Keep';
afdh_shortcuts['m'] = 'Merge';
afdh_shortcuts['mv'] = 'Move';
afdh_shortcuts['rd'] = 'Redirect';
afdh_shortcuts['rw'] = 'Rewrite';
afdh_shortcuts['t'] = 'Transwiki';
afdh_shortcuts['wd'] = 'Weak delete';
afdh_shortcuts['sd'] = 'Strong delete';
afdh_shortcuts['sp'] = 'Speedy delete';
afdh_shortcuts['sk'] = 'Strong keep';
afdh_shortcuts['wk'] = 'Weak keep';
afdh_shortcuts['c'] = 'Comment';
afdh_commscs = Array();
afdh_commscs['pn'] = 'per nom.';
function afd_helper() {
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_vote('"+anchors[i].href.replace(/'/g, '\\\'')+"')";
na.title = "Vote on deletion of "+unescape(matches[1]);
var inlink = document.createElement('sup');
inlink.appendChild(document.createTextNode('vote'));
na.appendChild(inlink);
anchors[i].parentNode.insertBefore(na, anchors[i].nextSibling);
}
if (am_get_title().indexOf(':') == -1)
am_add_li('tb', 'javascript:afd_nominate()', 'Nominate AFD', '', 'Nominate this article for deletion');
}
function afd_vote(edit_link) {
var shortcuts_list = '';
for (var key in afdh_shortcuts)
shortcuts_list += key + ': ' + afdh_shortcuts[key] + '; ';
var vote = window.prompt("Enter your vote. (Shortcuts available are: "+shortcuts_list+")");
if (!vote) return;
if (afdh_shortcuts[vote.toLowerCase()])
vote = afdh_shortcuts[vote.toLowerCase()];
shortcuts_list = '';
for (var key in afdh_commscs)
shortcuts_list += key + ': ' + afdh_commscs[key] + '; ';
var comment = window.prompt("Enter your comment. (Shortcuts available are: "+shortcuts_list+")");
if (typeof comment != 'string') return;
if (afdh_commscs[comment.toLowerCase()])
comment = afdh_commscs[comment.toLowerCase()];
var summary = vote;
if (afdh_summaryprompt)
if (!(summary = window.prompt("Enter the edit summary:", summary)))
summary = vote;
var url = edit_link +
'&amaddafter='+escape("* '''"+vote+"''' "+comment+" "+afdh_signature+" ~~"+"~~"+"~") +
'&amsummary='+escape(summary);
if (window.location.href.indexOf("/Log/") == -1)
window.location.href = url;
else
window.open(url, "afd_helper_vote");
}
function afd_nominate() {
var title = am_get_title();
var log_date = window.prompt("This should be the date of the latest AFD log. Change it if necessary.", am_guess_date());
if (!log_date)
return;
var reason = window.prompt("Please justify your AFD nomination of "+title+":");
if (!reason)
return;
var doc = document.open('text/html', 'replace');
doc.write('<html><frameset rows="*,3*,*">' +
'<frame src="'+am_make_url(title, '<!-- Please do not remove or change this AfD message until the issue is settled -->
<div class="boilerplate metadata" id="afd" style="margin: 0 5%; padding: 0 7px 7px 7px; background: #EDF1F1; border: 1px solid #999999; text-align: left; font-size:95%;">
'''This article is being considered for deletion in accordance with Wikipedia's [[Wikipedia:Deletion policy|deletion policy]][[Template:Afd|.]]'''<br />
Please share your thoughts on the matter at '''[[Wikipedia:Articles for deletion/{{PAGENAME}}|this article's entry]]''' on the Articles for Deletion page.<br />
You are welcome to edit this article, but please do not blank this article or remove this notice while the discussion is in progress. For more information, particularly on merging or moving the article during the discussion, read the [[Wikipedia:Guide to deletion|Guide to Deletion]].</div>
[[Category:Pages for deletion]]
<!-- End of AfD message, feel free to edit beyond this point -->', '', 'nomination for [[WP:AFD|deletion]]')+'">'+
'<frame src="'+am_make_url('Wikipedia:Articles for deletion/'+title, '', '===[['+title+']]===
'+reason+'', 'nominated for deletion')+'">'+
'<frame src="'+am_make_url('Wikipedia:Articles for deletion/Log/'+log_date, '', '{{Wikipedia:Articles for deletion/'+title+'}}', 'Nominating '+title+' for deletion')+'">'+
'</frameset></html>'
);
doc.close();
}