Make link to wikilink in header
by ShoeMaker
HTML
<h2><span class="mw-headline" id="Please_ignore_this_test"><a href="/wiki/User:Technical_13" title="User:Technical_13">Please ignore this test</a> because <a href="/wiki/User_talk:Technical_13" title="User_talk:Technical_13">I am cool</a>.</span></h2>
<p>This is a test that I will revert momentarily, please ignore. <a href="/wiki/User:Technical_13" title="User:Technical 13">Technical 13</a> (<a href="/wiki/User_talk:Technical_13" title="User talk:Technical 13">talk</a>|<a href="https://en.wikipedia.org/wiki/Special:Contributions/Technical_13" style="font-size:x-small; display:inline-block;">C</a><tt>|</tt><a original-title="Send a talkback!" href="#User talk:Technical 13" style="font-size:x-small; display:inline-block;" nopopup="1" id="TBsubmit2">TB</a><span class="before-localcomments">) </span><span class="localcomments" style="font-size: 95%; white-space: nowrap;" timestamp="1387854751631" title="03:12, 24 December 2013 (UTC)">10:12 pm, Today (UTC−5)</span><span class="after-localcomments"></span>
</p>
<dl>
<dd>Response post.. Please ignore.. Reverting momentarily. <a href="/wiki/User:Technical_13" title="User:Technical 13">Technical 13</a> (<a href="/wiki/User_talk:Technical_13" title="User talk:Technical 13">talk</a>|<a href="https://en.wikipedia.org/wiki/Special:Contributions/Technical_13" style="font-size:x-small; display:inline-block;">C</a><tt>|</tt><a original-title="Send a talkback!" href="#User talk:Technical 13" style="font-size:x-small; display:inline-block;" nopopup="1" id="TBsubmit3">TB</a><span class="before-localcomments">) </span><span class="localcomments" style="font-size: 95%; white-space: nowrap;" timestamp="1387854751632" title="03:12, 24 December 2013 (UTC)">10:12 pm, Today (UTC−5)</span><span class="after-localcomments"></span>
</dd>
</dl>
<br />
<div id="Foo" style="border: 1px solid #000; padding: 8px;"></div>
<div style="width: 100%; font-weight: bold; text-align: center; padding: 15px 0px;">BECOMES</div>
<div id="Bar"...
JavaScript
var headline = $('h2').find('span.mw-headline').html();
headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
$('h2').find('span.mw-headline').find('a').each(function () {
var linkedPage = $(this).attr('title');
var pipedPage = $(this).html();
var htmlLink = "<a href=\"/wiki/" + linkedPage + "\" title=\"" + linkedPage + "\">" + pipedPage + "<\/a>";
headline = headline.replace(htmlLink, pipedPage);
});
/* The following lines populates the input bars to show you what the replaced result would look like */
$("#Foo").text($('h2').find('span.mw-headline').html());
$("#Bar").text(headline);