Skip to content

Instantly share code, notes, and snippets.

@hykilpikonna
Last active August 5, 2023 18:30
Show Gist options
  • Select an option

  • Save hykilpikonna/f6afdd8382e2e989965a7cc408cb6762 to your computer and use it in GitHub Desktop.

Select an option

Save hykilpikonna/f6afdd8382e2e989965a7cc408cb6762 to your computer and use it in GitHub Desktop.
Universal LXGW Wenkai Font Userscript
// ==UserScript==
// @name Universal Font
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Take over the world with your favorite font
// @author Azalea
// @match *://*/*
// @grant GM_addStyle
// @downloadURL https://gist.github.com/hykilpikonna/f6afdd8382e2e989965a7cc408cb6762/raw/userscript.js
// @updateURL https://gist.github.com/hykilpikonna/f6afdd8382e2e989965a7cc408cb6762/raw/userscript.js
// ==/UserScript==
(function() {
'use strict';
const excludedStarting = ["fa-", "TEX-", "mjx-", "icon-"]
const excludedEnding = ["-icon"]
const excludedClasses = ['google-symbols', 'site-nav-icon']
const nots = excludedStarting.map(it => `:not([class^="${it}"]):not([class*=" ${it}"])`).join("") +
excludedEnding.map(it => `:not([class$="${it}"]):not([class*="${it} "])`).join("") +
excludedClasses.map(it => `:not(.${it})`).join("")
const codeClasses = ['blob-code-content', 'CodeMirror'].map(it => `, .${it} *:not(i)${nots}`).join("")
const style = `
*:not(i)${nots} {
font-family: "LXGW Wenkai" !important;
font-synthesis: none;
}
code *, pre *${codeClasses} {
font-family: "LXGW Wenkai Mono" !important
}
`
GM_addStyle(style)
console.log("Font added.")
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment