$(document).ready(function()
{
if(mw.config.get("wgAction") == "delete")
{
var backlinkWarning = $(".mw-warning.plainlinks");
if(backlinkWarning.length > 0)
{
backlinkWarning.append("<ul id='backlinkWarnings'></ul>");
var data = {action:"query",list:"backlinks",format:"json",bltitle:mw.config.get("wgPageName"),blnamespace:"0",blfilterredir:"nonredirects",bllimit:"1"};
$.post("/w/api.php",data, function(response)
{
if(response.query.backlinks.length > 0)
{
$("#backlinkWarnings").append("<li style='color:red;'>There are pages in mainspace that link to this article.</li>");
}
});
var data = {action:"query",list:"backlinks",format:"json",bltitle:mw.config.get("wgPageName"),blfilterredir:"redirects",bllimit:"1"};
$.post("/w/api.php",data, function(response)
{
if(response.query.backlinks.length > 0)
{
$("#backlinkWarnings").append("<li style='color:red;'>There are pages that redirect to this article.</li>");
}
});
var data = {action:"query",list:"embeddedin",format:"json",eititle:mw.config.get("wgPageName"),eilimit:"2"};
$.post("/w/api.php",data, function(response)
{
if(response.query.embeddedin.length > 1 || (response.query.embeddedin.length == 1 && response.query.embeddedin[0].title.replace(/ /g,"_") != mw.config.get("wgPageName")))
{
$("#backlinkWarnings").append("<li style='color:red;'>There are pages that transclude this page.</li>");
}
});
}
}
});