Skip to content

Instantly share code, notes, and snippets.

@9999years
Created June 29, 2021 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 9999years/ae2ff568aafbc438b95fc062abe40f7d to your computer and use it in GitHub Desktop.
Save 9999years/ae2ff568aafbc438b95fc062abe40f7d to your computer and use it in GitHub Desktop.
YAML spec user styles
// ==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