User:Alpha Quadrant/afd helper.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. |
Documentation for this user script can be added at User:Alpha Quadrant/afd helper. |
//<pre><nowiki>
/************* afd Helper ************/
// This is a nearly identical copy of [[User:Jnothman/afd helper/script.js]]
// However, this script lacks the AfD nomination feature included in the original
// see User:Jnothman/afd_helper
importScript("User:Jnothman/automod.js");
afdh_signature = '~~'+'~';
afdh_summaryprompt = true;
afdh_useicons = false;
afdh_shortcuts = Object();
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['spk'] = 'Speedy keep';
afdh_shortcuts['c'] = 'Comment';
afdh_icons = Object();
afdh_icons['d'] = afdh_icons['wd'] = afdh_icons['sd'] = afdh_icons['sp'] = 'Symbol delete vote.svg';
afdh_icons['k'] = afdh_icons['sk'] = afdh_icons['wk'] = 'Symbol keep vote.svg';
afdh_icons['m'] = 'Symbol merge vote.svg';
afdh_icons['c'] = 'Symbol comment vote.svg';
afdh_commscs = Object();
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('"+escape(anchors[i].href)+"')";
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);
}
}
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;
var icon_link = '';
if (afdh_useicons && afdh_icons[vote.toLowerCase()])
icon_link = '[[File:' + afdh_icons[vote.toLowerCase()] + '|20px]] ';
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("* '''"+icon_link+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");
}
addOnloadHook(afd_helper);
//</nowiki></pre>