Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
importScript('User:Animum/urlparameters.js');
 
$(function() {
    if(UrlParameters["addtemplate"] == "blocked" && UrlParameters["duration"] > "" && UrlParameters["reason"] > "" && UrlParameters["action"] == "edit") {
        document.editform.wpTextbox1.value += "\n\{\{subst:blocked\|" + decodeURIComponent(UrlParameters["duration"]) + "\|" + decodeURIComponent(UrlParameters["reason"]) + "\}\} \~\~\~\~";
        document.editform.wpSummary.value = "You have been blocked from editing" + ".";
        document.editform.wpMinoredit.checked = true;
        document.editform.submit();
    }
});
 
function redirectToEditScreen() {
    location.href = wgScript + "?title=" + wgPageName + "&action=edit&addtemplate=blocked&duration=" + encodeURIComponent(document.getElementById("gblockDuration").value) + "&reason=" + encodeURIComponent(document.getElementById("gblockReason").value);
}
 
function buildGBlockForm() {
    location.href = "#top";
    document.getElementById("contentSub").innerHTML = '<fieldset style="font-size:10pt"><legend>GBlock data</legend><table><tr><td>Duration: </td><td><input name="gblockDuration" id="gblockDuration" type="text" /></td></tr><tr><td>Reason: </td><td><input name="gblockReason" id="gblockReason" type="text" /></td></tr><tr><td><input type="submit" onclick="redirectToEditScreen()" value="Submit" /></td></tr></table></fieldset>';
}
 
$(function() {
    if(wgNamespaceNumber == 3 && !UrlParameters["addtemplate"]) {
        mw.util.addPortletLink("p-tb", "javascript:buildGBlockForm()", "Block notification", "t-blocknotify");
    }
});