User:Bawolff/fastProtect.js

//options

var reason = "Testing FastProtect"

function fastProtect {

addPortletLink("p-tb", "javascript:quicklyProtect;", "Speedy protect", "ca-quickprotect", "Automatically fully protect very quickly", "~");

}

function quicklyProtect {

iframe = document.createElement("iframe");

var pageName = window.escape(wgPageName); alert("page: " + pageName); iframe.setAttribute("src", "http://en.wikinews.org/w/index.php?action=protect&title=" + pageName); iframe.id = "JSQuickProtectForm";

if (iframe.addEventListener) iframe.addEventListener("load", ProtectForm, false); else if (iframe.attachEvent) iframe.attachEvent("onload", ProtectForm); else alert("JS quick protect error");

document.getElementsByTagName("body")[0].appendChild(iframe);

}

fastProtect;

function ProtectForm {

var form = iframe.contentDocument.getElementsByTagName("form")[0]; var options = iframe.contentDocument.getElementsByTagName("option");

options[2].selected = true;

form.setAttribute("onsubmit", "options[5].selected = true; alert('Selected option 5');"); iframe.contentDocument.getElementById("mwProtect-reason").value = reason + " - Using FastProtect";

form = iframe.contentDocument.getElementById("mw-Protect-Form"); form.submit; }