User:Writ Keeper/Scripts/renameWarner.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Writ Keeper/Scripts/renameWarner. |
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 == "{{usernameblock}}" || blockReason == "{{causeblock}}" || blockReason == "{{softerblock}}")
{
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('<div id="rename-warning-simple"><span style="color:red;">NOTE: this user has made edits to WP:CHU/S; they may have already requested a rename.</span> <a target="_blank" href="//en.wikipedia.org/w/index.php?diff='+response.query.pages["7535778"].revisions[0].revid +'&direction=prev">Here\'s their most recent edit.</a></div>');
}
});
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('<div id="rename-warning-usurp"><span style="color:red;">NOTE: this user has made edits to WP:CHU/U; they may have already requested a rename.</span> <a target="_blank" href="//en.wikipedia.org/w/index.php?diff='+response.query.pages["8868700"].revisions[0].revid +'&direction=prev">Here\'s their most recent edit.</a></div>');
}
});
hasCheckedForUsernameChangeRequests = true;
}
else
{
$("#rename-warning-simple").show();
$("#rename-warning-usurp").show();
}
}
else
{
$("#rename-warning-simple").hide();
$("#rename-warning-usurp").hide();
}
});
}
});