Created
December 8, 2012 08:24
-
-
Save BenMQ/4239258 to your computer and use it in GitHub Desktop.
section permalink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addOnloadHook(function() { | |
var pLink = document.getElementById('t-permalink') | |
if (pLink) { | |
var permalink = pLink.firstChild.href.replace(/title=[^&]*&/,'') | |
pLink.firstChild.href = permalink; | |
}; | |
var lis = document.getElementsByClassName('mw-headline'); | |
var li, section_name, section_link; | |
for (var i=0; i < lis.length; i++){ | |
li = lis[i]; | |
section_name = li.getAttribute('id'); | |
section_link = document.createElement('a'); | |
link_text = document.createTextNode('Permalink'); | |
section_link.href = permalink + '#' + section_name; | |
section_link.appendChild(link_text); | |
li.parentNode.appendChild(section_link); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment