Jump to content

User:Writ Keeper/Scripts/historySection.js

From Wikipedia, the free encyclopedia
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()
{
	var $autoLinkSearch = $(".diff-otitle span.autocomment>a");
	if($autoLinkSearch.length > 0) 
	{
		var autoLink = $($autoLinkSearch[0]);
		var regexResult = autoLink.attr("href").match(/\/wiki\/[^#]+(#.+)/);
		if(regexResult.length > 0)
		{
			autoLink.attr("href", $("div#mw-diff-otitle1>strong>a").attr("href") + regexResult[1]);
		}
	}
	$autoLinkSearch = $(".diff-ntitle span.autocomment>a");
	if($autoLinkSearch.length > 0)
	{
		var autoLink = $($autoLinkSearch[0]);
		var regexResult = autoLink.attr("href").match(/\/wiki\/[^#]+(#.+)/);
		if(regexResult.length > 0)
		{
			autoLink.attr("href", $("div#mw-diff-ntitle1>strong>a").attr("href") + regexResult[1]);
		}
	}
});