Jump to content

User:Theone00/scripts/afc-backlog-help.js

From 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.
// <pre><nowiki>
 
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Henrik/js/automod.js' +
  '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
afch_declines = Array();
 
afch_declines["exists"] = 'already%20exists%20AFC%20Backlog%Drive';
afch_declines["v"] = 'not%20verifiable%20AFC%20Backlog%Drive';
afch_declines["nn"] = 'not%20a%20notable%20person%20AFC%20Backlog%Drive';
afch_declines["web"] = 'not%20a%20notable%20website%20AFC%20Backlog%Drive';
afch_declines["corp"] = 'not%20a%20notable%20corporation%20AFC%20Backlog%Drive';
afch_declines["band"] = 'not%20a%20notable%20band%20or%20musician%20AFC%20Backlog%Drive';
afch_declines["dict"] = 'dictionary%20definition%20AFC%20Backlog%Drive'';
afch_declines["context"] = 'lacks%20context%20AFC%20Backlog%Drive'';
afch_declines["cv"] = 'copyright%20violation%20AFC%20Backlog%Drive'';
afch_declines["blank"] = 'blank%20entry%20AFC%20Backlog%Drive'';
afch_declines["adv"] = 'advertising%20AFC%20Backlog%Drive'';
afch_declines["neo"] = 'neologism%20AFC%20Backlog%Drive'';
afch_declines["lang"] = 'not%20in%20English%20AFC%20Backlog%Drive'';
afch_declines["joke"] = 'appears%20to%20be%20a%20joke%20AFC%20Backlog%Drive'';
afch_declines["npov"] = 'not%20neutrally%20written%20AFC%20Backlog%Drive'';
afch_declines["blp"] = 'defamatory%20AFC%20Backlog%Drive'';
 
function afc_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_creation\/([^&]+)&action=edit&/;
    //var url_re = /\?title=User:Henrik\/sandbox\/([^&]+)&action=edit&/;
    var url, matches;
    for (var i=0; i < anchors.length; i++) {
        if (!(matches = anchors[i].href.match(url_re))
         || (anchors[i].parentNode.parentNode.tagName != 'H2'))
            continue;
 
        bla = "<span id=\"afc-helper\">";
        for (var key in afch_declines) {   
          if( !afch_declines.hasOwnProperty(key) ) { // Twinke workaround?
           continue;
          }      
          link = "javascript:afc_vote('"+escape(anchors[i].href)+"','"+key+"','"+afch_declines[key]+"')";
          bla += "[<a href=\""+link+"\">"+key+"</a>]";
        }
        bla += "</span>";
        anchors[i].parentNode.innerHTML += bla;
 
    }
}
 
function afc_vote(edit_link,type,reason) {
    var url = edit_link + 
        '&amfind='+escape("==(.*)==")+
        '&amreplace='+escape('$0\n{{subst:afc top}}')+
        '&amlocal=1'+
        '&amaddafter='+escape("{{subst:afc "+type+"}} ~~"+"~~\n"+"{{subst:afc b}}") +
        '&amsummary='+escape("decline - " + reason);
 
    if (window.location.href.indexOf("/Log/") == -1)
      window.location.href = url;
    else
      window.open(url, "afd_helper_vote");
}
addOnloadHook(afc_helper);
 
// </nowiki></pre>