User:Kenb215/js/afc-helper.js

//

document.write(' ');

afch_declines = Array; afch_accepts = Array;

afch_accepts["create"] = 'create'; afch_accepts["all"] = 'all'; afch_accepts["manual"] = 'manual';

afch_declines["exists"] = 'already%20exists'; afch_declines["empty"] = 'empty%20submission'; afch_declines["notarget"] = 'no%20target%20given'; afch_declines["unlikely"] = 'not%20a%20likely%20title'; afch_declines["manual"] = 'manual';

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 = ""; for (var key in afch_accepts) { if( !afch_accepts.hasOwnProperty(key) ) { // Twinke workaround? continue; }               link = "javascript:afc_vote('"+escape(anchors[i].href)+"','"+key+"','"+afch_accepts[key]+"','accept')"; bla += "["+key+"]"; }       bla += " ";; for (var key in afch_declines) { if( !afch_declines.hasOwnProperty(key) ) { // Twinke workaround? continue; }               link = "javascript:afc_vote('"+escape(anchors[i].href)+"','"+key+"','decline - "+afch_declines[key]+"','')"; bla += "["+key+"]"; }       bla += " "; anchors[i].parentNode.innerHTML += bla;

} }

function afc_vote(edit_link,type,reason,action) { var type2 = type; if (type == "manual") type2 = "accept";

var url = edit_link + '&amfind='+escape("==(.*)==")+ '&amreplace='+escape('$0\n'+action+'')+ '&amlocal=1'+ '&amaddafter='+escape(" "+"\n"+"") + '&amsummary='+escape(reason); if (action == '') { url += "&amautosave=yes;"; }   window.location.href = url;

if (action == "accept" && type != "manual") { title = window.prompt("Create at title?"); url = "http://en.wikipedia.org/w/index.php?title="+escape(title)+"&action=edit"; window.open(url, "afd_helper_vote"); } } $(afc_helper);

//