Created
March 13, 2023 01:21
-
-
Save s-thom/bde2aecf0a6753b29d3dd6c12ff6bf98 to your computer and use it in GitHub Desktop.
GitHub font changer userscript
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 GitHub Font Changer | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Change the font used in code blocks on GitHub | |
// @author Stuart Thomson <https://github.com/s-thom> | |
// @match https://github.com/* | |
// @match https://*.github.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Set your own font stack here | |
const fonts = "'Jetbrains Mono', ui-monospace, monospace"; | |
// Function helper to inject css | |
function addGlobalStyle(css) { | |
const style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
document.head.appendChild(style); | |
} | |
// Apply the font-family definition to code styles. | |
addGlobalStyle(` | |
code, | |
.blob-code-inner, | |
.blob-num { | |
font-family: ${fonts} !important; | |
} | |
`); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment