User:MindstormsKid/vector.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. |
The accompanying .css page for this skin can be added at User:MindstormsKid/vector.css. |
// The Articles for Creation Helper
// v1.3 beta
//
// Originally written by [[User:Henrik]] at http://en.wikipedia.org/wiki/User:Henrik/js/afc-helper.js
// Revised by [[User:The Earwig]].
// See http://en.wikipedia.org/wiki/Wikipedia:Articles_for_creation
//
// <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>');
document.write('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>');
afch_accepts = {
accept: "accepted",
othertitle: "accepted at another title",
reason: "accepted with custom reason"
};
afch_declines = {
exists: "already exists",
blank: "blank request",
notarget: "target article does not exist, or was not specified",
unlikely: "unlikely search term, or source needed",
reason: "custom reason"
};
afch_comments = { comment: "adding a comment" };
function afc_helper() {
jQuery.noConflict();
if (auto_mod()) { return; }
var requests = jQuery(".mw-headline").filter(function(){ return this.childNodes[0].nodeValue == "Redirect request: " && !/\/wiki\//.test(this.childNodes[1].href); });
requests.each(function(){
var edit = jQuery(this).prev();
jQuery.each(afch_accepts, function(k, v){ edit.append('[<a href="#" style="background-color: #A0FFA0;" class="afch_accepts">' + k + '</a>]'); });
jQuery.each(afch_declines, function(k, v){ edit.append('[<a href="#" style="background-color: #ffcece;" class="afch_declines">' + k + '</a>]'); });
jQuery.each(afch_comments, function(k, v){ edit.append('[<a href="#" style="background-color: #ffec83;" class="afch_comments">' + k + '</a>]'); });
});
jQuery(".afch_accepts").click(function(){
afc_vote(this.parentNode.nextSibling.nextSibling, this.innerHTML, afch_accepts[this.innerHTML], "accept");
return false;
});
jQuery(".afch_declines").click(function(){
afc_vote(this.parentNode.nextSibling.nextSibling, this.innerHTML, "decline - " + afch_declines[this.innerHTML], "");
return false;
});
jQuery(".afch_comments").click(function(){
afc_vote(this.parentNode.nextSibling.nextSibling, this.innerHTML, afch_comments[this.innerHTML], "comment");
return false;
});
}
function afc_vote(title, type, reason, action) {
var comments, type2 = type, edit_link = title.parentNode.childNodes[0].childNodes[1].href;
var redirOrigin = title.childNodes[1].innerHTML, redirTarget = title.parentNode.nextSibling.nextSibling.childNodes[1].innerHTML;
if (type == "comment") { type2 = window.prompt("Comment:"); }
if (type == "reason" && action == "accept") {
comments = window.prompt("Reason for accepting:");
type2 = "accept|" + comments;
}
if (type == "othertitle") {
type2 = window.prompt("Other title:");
redirOrigin = type2;
}
if (type == "accept") {
type2 = "";
}
if (type == "reason" && action == "") {
comments = window.prompt("Reason for declining:");
type2 = "decline|" + comments;
}
if (action == "accept" && (!redirOrigin || !redirTarget)) { return; }
if (action != "comment") {
var url = edit_link
+ '&amfind=' + escape("==(.*)==")
+ '&amreplace=' + escape('$0\n{{subst:afc top|' + action + '}}')
+ '&amlocal=1'
+ '&amaddafter=' + escape("\n{{subst:afc redirect|" + type2 + "}} ~~" + "~~\n" + "{{subst:afc b}}")
+ '&amsummary=' + escape(reason)
+ '&amautosave=yes';
} else {
var url = edit_link
+ '&amfind=' + escape("==(.*)==")
+ '&amreplace=' + escape('$0')
+ '&amlocal=1'
+ '&amaddafter=' + escape("\n:{{afc comment|1=" + type2 + "}} ~~" + "~~")
+ '&amsummary=' + escape(reason)
+ '&amautosave=yes';
}
console.log(url);
return;
if (action == "accept") {
var url2 = "http://en.wikipedia.org/w/index.php?title=" + escape(redirOrigin)
+ "&action=edit&amsummary=Created+via+%5B%5BWP:AFC%7CArticles+for+Creation%5D%5D.+%5B%5BWP:AFC%2FR%7CYou+can+help%21%5D%5D&amfind=.*&amlocal=1&amreplace=%23REDIRECT+%5B%5B"
+ escape(redirTarget) + "%5D%5D+%7B%7BR+from+alternate+name%7D%7D&amautosave=yes";
var url3 = "http://en.wikipedia.org/w/index.php?title=Talk:" + escape(redirOrigin)
+ "&action=edit&amsummary=%7B%7Bsubst%3AWPAFC%2Fredirect%7D%7D&amfind=.*&amlocal=1&amreplace=%7B%7Bsubst%3AWPAFC%2Fredirect%7D%7D&amautosave=yes";
window.open(url2, "afd_helper_vote2");
window.open(url3, "afd_helper_vote3");
}
window.location.href = url;
}
addOnloadHook(afc_helper);
// </nowiki></pre>