Skip to content

Instantly share code, notes, and snippets.

@genzj
Last active June 9, 2023 09:17
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 genzj/f4af7da0d9f9b79d4a48d8ca6b5aba54 to your computer and use it in GitHub Desktop.
Save genzj/f4af7da0d9f9b79d4a48d8ca6b5aba54 to your computer and use it in GitHub Desktop.
Use NerdFont in code/pre tags, such as github
// ==UserScript==
// @name NerdFont for Code
// @namespace http://genzj.info/
// @version 0.1
// @description Use NerdFont in code/pre tags, such as github
// @author You
// @match https://github.com/*
// @match https://gist.github.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
GM_addStyle (`
@font-face {
font-family: 'patched-nerd-fonts';
src: url('https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@master/patched-fonts/RobotoMono/Regular/RobotoMonoNerdFontMono-Regular.ttf');
src: url('https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@master/patched-fonts/RobotoMono/Regular/RobotoMonoNerdFontMono-Regular.ttf') format('truetype');
font-weight: 100;
font-style: normal;
}
@font-face {
font-family: 'NerdFontsSymbols Nerd Font';
/* @TODO you need to adjust the path to the font: */
src: url("https://www.nerdfonts.com/assets/fonts/Symbols-2048-em%20Nerd%20Font%20Complete.woff2") format("woff2");
font-weight: normal;
font-style: normal;
}
textarea[aria-label="file content"],
.react-code-text,
.markdown-body .highlight pre,
.markdown-body pre {
font-family: "NerdFontsSymbols Nerd Font", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace !important;
}
`);
})();
@genzj
Copy link
Author

genzj commented Jun 9, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment