User:Juliancolton/closerfa.js

// Adapted from User:Animum/rfaclose.js.

importScript("User:Animum/urlparameters.js");

function closeRFA_init(outcome) { window.open(wgScript + "?title=" + wgPageName + "&action=edit&outcome=" + outcome, "_blank", ""); //Open in a new tab }

$(function {   if(wgTitle.indexOf("Requests for adminship/") != -1) {        mw.util.addPortletLink("p-cactions", "javascript:closeRFA_init(\"pass\")", "pass", "ca-rfapass");        mw.util.addPortletLink("p-cactions", "javascript:closeRFA_init(\"fail\")", "fail", "ca-rfafail");    } });

$(function {   if((UrlParameters["outcome"] == "pass" || UrlParameters["outcome"] == "fail") && wgTitle.indexOf("Requests for adminship/") != -1) {        if(document.editform.wpTextbox1.value.indexOf("boilerplate metadata rfa") != -1) return;        var user = wgTitle.split("/")[1];        document.editform.wpTextbox1.value = "\{\{subst:rfa" + (UrlParameters["outcome"] == "pass" ? "p" : "f") + "\}\}\n" + document.editform.wpTextbox1.value;       var lines = document.editform.wpTextbox1.value.split("\n");        lines[2] = "\nFinal tally: \{\{subst:rfatally\|" + user + "\}\}; closed per WP:SNOW by \[\[User:" + wgUserName + "\|" + wgUserName + "\]\] at \~\~\~\~\~";        document.editform.wpTextbox1.value = lines.join("\n") + "\n\{\{subst:rfab\}\}";        document.editform.wpSummary.value = "Closing RfA: " + (UrlParameters["outcome"] == "pass" ? "Successful" : "Unsuccessful");       document.editform.wpMinoredit.checked = true;        document.editform.wpSave.click;        window.setTimeout(function { window.close; }, 1000);    } });