User:John F. Lewis/CheckDeletion.js

// This script checks AfD and the Deletion log for previous deletion. If they exist 'Prev AfD' or 'Prev dels' is displayed. Click it and find out! // // TODO: // Nothing yet. Contact me and suggest something!

$(document).ready(deletionChecker); encodedTitle = encodeURIComponent(wgTitle); function deletionChecker {	if(wgCanonicalNamespace == "" || wgCanonicalNamespace == "User"|| wgCanonicalNamespace == "Talk"|| wgCanonicalNamespace == "User talk") {		var encodedTitle = encodeURIComponent(wgTitle); var delRequest = $.get("/w/api.php?action=query&list=logevents&format=json&leprop=ids&letype=delete&letitle=" + encodedTitle + "&lelimit=1", null, delCallback, "json"); var afdRequest = $.get("/w/api.php?action=query&list=allpages&format=json&apfrom=Articles%20for%20deletion%2F" + encodedTitle + "&apto=Articles%20for%20deletion%2F" + encodedTitle + "&apnamespace=4&aplimit=1", null, afdCallback, "json"); } } function delCallback(delResults) {	if(delResults.query.logevents[0] != null) {			var searchNode = document.createElement("a"); searchNode.href = wgServer + "/w/index.php?title=Special%3ALog&type=delete&page=" + encodedTitle; searchNode.target = "_blank"; searchNode.innerHTML = " prev dels "; document.getElementById("firstHeading").appendChild(searchNode); } } function afdCallback(afdResults) {	if(afdResults.query.allpages[0] != null) {		var searchNode = document.createElement("a"); searchNode.href = wgServer + "/w/index.php?title=Special%3AAllPages&from=Articles+for+deletion%2F" + encodedTitle + "&to=Articles+for+deletion%2F" + encodedTitle + "+%289z%29&namespace=4"; searchNode.target = "_blank"; searchNode.innerHTML = " prev AfDs "; document.getElementById("firstHeading").appendChild(searchNode); } }