User:Writ Keeper/Scripts/deletionFinder.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$(document).ready(deletionChecker);
encodedTitle = encodeURIComponent(mw.config.get("wgPageName"));

function deletionChecker()
{
	var encodedTitle = encodeURIComponent(mw.config.get("wgPageName"));
	var delRequest = $.get("/w/api.php?action=query&list=logevents&format=json&leprop=ids&letype=delete&letitle="   encodedTitle   "&lelimit=1", null, delCallback, "json");
	if(mw.config.get("wgCanonicalNamespace") == "")
	{
		var afdRequest = $.get("/w/api.php?action=query&list=allpages&format=json&apfrom=Articles for deletion/"   encodedTitle   "&apto=Articles for deletion/"   encodedTitle   "&apnamespace=4&aplimit=1", null, afdCallback, "json");
	}
}
function delCallback(delResults)
{
	if(delResults.query.logevents[0] != null)
	{	
/*
		var searchNode = document.createElement("a");
		searchNode.href = mw.config.get("wgServer")   "/w/index.php?title=Special:Log&type=delete&page="   encodedTitle;
		searchNode.target = "_blank";
		searchNode.innerHTML = "<span style='font-size:x-small;'>prev dels</span>";
		document.getElementById("firstHeading").appendChild(searchNode);
*/
		var searchNode = " <a id='prevDelsLink' target='_blank'><span style='font-size:x-small;'>prev dels</span></a>"
		$("#firstHeading").append(searchNode);
		$("#prevDelsLink").attr("href", mw.config.get("wgServer")   "/w/index.php?title=Special:Log&type=delete&page="   encodedTitle);
	}
}
function afdCallback(afdResults)
{
	if(afdResults.query.allpages[0] != null)
	{
/*
		var searchNode = document.createElement("a");
		searchNode.href = mw.config.get("wgServer")   "/w/index.php?title=Special:AllPages&from=Articles for deletion/"   encodedTitle   "&to=Articles for deletion/"   encodedTitle   " (9z)&namespace=4";
		searchNode.target = "_blank";
		searchNode.innerHTML = "<span style='font-size:x-small;'>prev AfDs</span>";
		document.getElementById("firstHeading").appendChild(searchNode);
*/

		var searchNode = " <a id='prevAFDsLink' target='_blank'><span style='font-size:x-small;'>prev AfDs</span></a>"
		$("#firstHeading").append(searchNode);
$("#prevAFDsLink").attr("href", mw.config.get("wgServer")   "/w/index.php?title=Special:AllPages&from=Articles for deletion/"   encodedTitle   "&to=Articles for deletion/"   encodedTitle   " (9z)&namespace=4");
	}
}