User:Wbm1058/ControversialMoves.js

// Adds a checkbox to the "Move page" special page, containing the content "Do you think this move might be controversial?" // When checked, a move request is added to the talkpage, using the proper template.

wgCanonicalSpecialPageName === "Movepage" && wgRelevantPageName.indexOf(":") == -1 && // mainspace only $(function($){ var submitButton = $(".mw-submit > input"), submitText = submitButton.val;  function submitFunction( e ){    e.preventDefault;    var newTitle = $("#wpNewTitleMain").val;    if ( newTitle == wgRelevantPageName || ! newTitle ) {     alert( "Please select a new page title." ); return;   }    submitButton.attr("disabled", "disabled");    $( "body" ).css("cursor", "wait");    $.ajax( { "url" : "/w/api.php", data : { "format" : "json", "action" : "tokens" }, "error" : cmError, success : function( t ){ $.ajax( { "url" : "/w/api.php", "type" : "POST", "data" : { "format" : "json", "action" : "edit", "title" : "Talk:" + wgRelevantPageName, "watchlist" : "watch", "section" : "new", "sectiontitle" : "Requested move", appendtext : "\{\{subst:requested move|" + newTitle + "}}" + $("#wpReason").val + " \~\~\~\~", "token" : t.tokens.edittoken }, "error" : cmError, "success" : function{ location.href = "/wiki/Talk:" + wgRelevantPageName + "#Requested_move" }}) }}) }  function cmError( q, w, e ){    $("#movepage").append( $(" ").css("color","red").text("An error has occured: " + e ) );  }  submitButton.parent.parent.before( $(" ").append(     $(" "),       $(" ").append( $(" ").attr({"type":"checkbox","id":"controversialMove"} ).click(function{        var checked = $(this).attr("checked") == "checked";        submitButton.attr("value", checked ? "Propose moving the page" : submitText );       $("#wpMovetalk").attr("disabled", checked && "disabled" );        $("#movepage")[ checked ? "on" : "off" ]( "submit", submitFunction );      }), " ", $(" ").attr("for", "controversialMove").text("Do you think this move might be controversial?") )    ) ) })