User:Writ Keeper/Scripts/backlinkWarner.js

$(document).ready(function {	if(mw.config.get("wgAction") == "delete")	{		var backlinkWarning = $(".mw-warning.plainlinks");		if(backlinkWarning.length > 0)		{			backlinkWarning.append("");			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("There are pages in mainspace that link to this article."); }			});			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("There are pages that redirect to this article."); }			});			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("There are pages that transclude this page."); }			});		}	} });