User:Writ Keeper/Scripts/renameWarner.js

if(typeof hasCheckedForUsernameChangeRequests == "undefined") {	hasCheckedForUsernameChangeRequests = false; } if(typeof hasRequestedNameChange == "undefined") {	hasRequestedNameChange = ""; }

$(document).ready(function {	if(mw.config.get("wgCanonicalSpecialPageName") == "Block")	{		$("#mw-input-wpReason").change(function {			var blockReason = $("#mw-input-wpReason").val; if(blockReason == "" || blockReason == "" || blockReason == "") {				if(!hasCheckedForUsernameChangeRequests) {					var data = {action:"query",format:"json",prop:"revisions",rvprop:"ids",rvlimit:"1",rvuser:$("#mw-bi-target").val,pageids:"7535778"}; $.post("/w/api.php",data,function(response)					{						if(typeof response.query.pages["7535778"].revisions != "undefined")						{							hasRequestedNameChange = hasRequestedNameChange + "S";							$("#mw-input-wpReason").after(' NOTE: this user has made edits to WP:CHU/S; they may have already requested a rename. Here\'s their most recent edit. ');						}					}); data.pageids = "8868700"; $.post("/w/api.php",data,function(response)					{						if(typeof response.query.pages["8868700"].revisions != "undefined")						{							hasRequestedNameChange = hasRequestedNameChange + "U";							var usurpWarningAnchor;							if($("#rename-warning-simple").length > 0)							{								usurpWarningAnchor = $("#rename-warning-simple");							}							else							{								usurpWarningAnchor = $("#mw-input-wpReason");							}							usurpWarningAnchor.after(' NOTE: this user has made edits to WP:CHU/U; they may have already requested a rename. Here\'s their most recent edit. ');						}					}); hasCheckedForUsernameChangeRequests = true; }				else {					$("#rename-warning-simple").show; $("#rename-warning-usurp").show; }			}			else {				$("#rename-warning-simple").hide; $("#rename-warning-usurp").hide; }		});	} });