Skip to content

Instantly share code, notes, and snippets.

@hungtcs
Last active December 18, 2020 15:28
Show Gist options
  • Save hungtcs/819a64fa9e6bfa37ce391f29765acfa3 to your computer and use it in GitHub Desktop.
Save hungtcs/819a64fa9e6bfa37ce391f29765acfa3 to your computer and use it in GitHub Desktop.
Change Github Font Family
// ==UserScript==
// @name Change Github Font Family
// @name:zh-CN Github网站字体切换
// @icon https://github.githubassets.com/favicons/favicon.png
// @version 0.0.3
// @description custom github font family
// @description:zh-CN 切换Github等网站的字体
// @namespace https://gist.github.com/hungtcs
// @author 鸿则<hungtcs@outlook.com>
// @homepage https://gist.github.com/hungtcs/819a64fa9e6bfa37ce391f29765acfa3
// @match https://github.com/**
// @match https://gist.github.com/**
// @match https://stackblitz.com/edit/**
// @run-at document-start
// @updateURL https://gist.github.com/hungtcs/819a64fa9e6bfa37ce391f29765acfa3/raw/522377a3039e141e8fe70725b0bd55ad0f71e8d9/change-github-font-family.user.js
// @downloadURL https://gist.github.com/hungtcs/819a64fa9e6bfa37ce391f29765acfa3/raw/522377a3039e141e8fe70725b0bd55ad0f71e8d9/change-github-font-family.user.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
const href = window.location.href;
const fontFamilies = ['Droid Sans Mono for Powerline', 'monospace'].join(',');
const styleElement = document.createElement('style');
document.head.appendChild(styleElement);
switch(true) {
case /stackblitz\.com\/edit/.test(href): {
styleElement.innerHTML = `.view-lines { font-family: ${ fontFamilies } !important; }`;
break;
}
case /github\.com/.test(href): {
styleElement.innerHTML = `
.blob-code-inner { font-family: ${ fontFamilies } !important; }
.CodeMirror pre { font-family: ${ fontFamilies } !important; }
.previewable-comment-form textarea, .markdown-body pre, .markdown-body code { font-family: ${ fontFamilies } !important; }
`;
break;
}
default: {
break;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment