Last active
October 17, 2019 15:06
-
-
Save Aran-Fey/1a0c5fa25617d9325e7baa8682560f92 to your computer and use it in GitHub Desktop.
Adds clickable link anchors to the python glossary
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
// ==UserScript== | |
// @name Python glossary permalinks | |
// @version 1.0.1 | |
// @description Adds clickable link anchors to the python glossary | |
// @match *://docs.python.org/*/glossary.html | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const glossary = document.querySelector('dl.glossary'); | |
for (const elem of glossary.getElementsByTagName('dt')){ | |
const anchor = document.createElement('a'); | |
anchor.classList.add('headerlink'); | |
anchor.title = 'Permalink to this definition'; | |
anchor.textContent = '¶'; | |
anchor.href = '#'+elem.id; | |
elem.appendChild(anchor); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment