User:Interiot/js/nothanksweb gen.js

// When viewing the Special:Undelete page of a copyvio deletion, this will automatically fill out the Template:nothanks-sd to paste onto the creator's talk page // // Tested in Mozilla Firefox. Willing to fix issues on any browser but MSIE. if (wgPageName == "Special:Undelete") { addOnloadHook(function { 		// get the first deletion comment 		var latestDeletion = document.getElementsByTagName("li"); 		if (latestDeletion && latestDeletion[0]) { 			var delComment = latestDeletion[0].innerHTML.replace(/^.*<span/i, ""); 			if (/g12|copy|copied/i.test(delComment)) { 				var URL = delComment.match(/(http:\/\/[^) ,'}{]*)/i); if (URL) { URL = URL[0]; // find the article name (this involves a bit of guesswork/hardcoding) var articleName; for (i=1; !articleName && i<latestDeletion[0].childNodes.length; i++) { var key =latestDeletion[0].childNodes[i]; if (key.tagName && key.tagName.toLowerCase == "a" && (key.className == "new" || (!key.href.match(/index.php/) && !key.href.match(/wiki\/User/) && !key.href.match(/wiki\/Special:/)))) { articleName = key.innerHTML; } 					} 					if (articleName) { var div = document.createElement("div"); div.appendChild(document.createTextNode("{" + "{" + "subst:nothanks-sd|pg=" + articleName + "|url=" + URL + "}} --~" + "~" + "~" + "~")); div.style.fontFamily = "monospace"; div.style.marginLeft = "2em"; div.style.color = "#999"; latestDeletion[0].appendChild(div); } 				} 			} 		} 	}); }