User:Writ Keeper/Scripts/historyDeleter.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(function() 
{
	if(mw.config.get("wgAction") == "view")
	{
		if($("li#ca-delete>a").length > 0)
		{
			var urlParam = $("li#ca-delete>a").attr("href").match(/&wpReason=[^&]+/);
			if(urlParam != null)
			{
				$("li#ca-history>a").attr("href", $("li#ca-history>a").attr("href") + urlParam[0]);
			}
		}
	}
	if(mw.config.get("wgAction") == "history")
	{
		if($("li#ca-delete>a").length > 0)
		{
			var urlParam = $(location).attr("href").match(/&wpReason=[^&]+/);
			if(urlParam != null)
			{
				$("li#ca-delete>a").attr("href", $("li#ca-delete>a").attr("href") + urlParam[0]);
			}
		}
	}
});