Created
June 29, 2021 15:47
-
-
Save 9999years/ae2ff568aafbc438b95fc062abe40f7d to your computer and use it in GitHub Desktop.
YAML spec user styles
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
// ==UserScript== | |
// @name YAML spec tweaks | |
// @description Better link indicators | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0.0 | |
// @author Rebecca Turner | |
// @match https://yaml.org/* | |
// @icon https://www.google.com/s2/favicons?domain=yaml.org | |
// @grant GM_addStyle | |
// ==/UserScript== | |
// Documentation: https://www.tampermonkey.net/documentation.php | |
(function() { | |
'use strict'; | |
GM_addStyle(` | |
a[href^="#"] { | |
background: none; | |
text-decoration: underline blue; | |
} | |
a.termanchor { | |
text-decoration: none; | |
} | |
`); | |
document.querySelectorAll('a') | |
.forEach(n => { | |
if (n.hasAttribute('href') || n.classList.contains('indexterm')) { | |
return; | |
} | |
const href = `#${n.getAttribute('id')}`; | |
n.classList.add('termanchor'); | |
n.setAttribute('href', href); | |
n.innerHTML = "<sup>🔗</sup>"; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment