User:水思/monobook.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<nowiki>
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 = '[[User:水思|水思]].[[User_talk:水思|talk]]';
afdh_summaryprompt = true;
 
afdh_shortcuts = Array();
afdh_shortcuts['d'] = '刪除';
afdh_shortcuts['k'] = '保留';
afdh_shortcuts['m'] = '合併';
afdh_shortcuts['mv'] = '移動';
afdh_shortcuts['rd'] = '重定向';
afdh_shortcuts['rw'] = '重寫';
afdh_shortcuts['t'] = 'Transwiki';
afdh_shortcuts['wd'] = 'Weak delete';
afdh_shortcuts['sd'] = 'Strong delete';
afdh_shortcuts['sp'] = '快速刪除';
afdh_shortcuts['sk'] = '快速保留';
afdh_shortcuts['wk'] = 'Weak keep';
afdh_shortcuts['c'] = '意見';
 
afdh_commscs = Array();
afdh_commscs['pn'] = ' as per nom.';
afdh_commscs['pmn'] = ' as per my 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;
    window.open(am_make_url(title, '{{'+'subst:afd}}', '', 'nomination for [[WP:AFD|deletion]]'), 'afdhn1');
    window.open(am_make_url('Wikipedia:Articles for deletion/Log/'+log_date, '', '{{'+'subst:afd3|pg='+title+'}}', 'Nominating [['+title+']] for deletion'), 'afdhn3');
    window.location.href = am_make_url('Wikipedia:Articles for deletion/'+title, '', '{{'+'subst:afd2|pg='+title+'|text='+reason+' '+'\r\n'+'*\'\'\''+afdh_shortcuts['d']+'\'\'\''+afdh_commscs['pmn']+afdh_signature+" 15:45, 1 August 2014 (UTC)"+'}}', 'nominated for deletion');
}
 
if (window.addEventListener) window.addEventListener("load",afd_helper,false);
else if (window.attachEvent) window.attachEvent("onload",afd_helper);
 
//</nowiki>