Created
April 28, 2014 23:56
-
-
Save jeffbr13/11387443 to your computer and use it in GitHub Desktop.
Greasemonkey script to add link anchors to Wikipedia page subheadings
This file contains 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
// https://benjeffrey.com/greasemonkey-script-for-wikipedia-subheading-links | |
// Available under the MPL 2.0 | |
// ==UserScript== | |
// @key value | |
// @name Wikipedia Subheading Links | |
// @namespace com.benjeffrey.wikipedia-subheading-links | |
// @description Add links to subheadings on Wikipedia pages. | |
// @include http://*.wikipedia.org/* | |
// @include https://*.wikipedia.org/* | |
// ==/UserScript== | |
contentsItems = document.getElementById('toc').getElementsByTagName('li'); | |
for (var i = 0; i < contentsItems.length; i++) { | |
subheadingHash = contentsItems[i].getElementsByTagName('a')[0].hash.slice(1); | |
subheading = document.getElementById(subheadingHash); | |
subheading.innerHTML = ('<a href="#' + subheadingHash + '">' + subheading.innerHTML + ' #</a>'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment