Github UI Font: Inter UI

Use the Inter font for all the non-code text on Github. Version code matches inter font version code.

当前为 2025-02-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Github UI Font: Inter UI
  3. // @namespace https://github.com/holyspiritomb
  4. // @author spiritomb
  5. // @version 4.1.0
  6. // @description Use the Inter font for all the non-code text on Github. Version code matches inter font version code.
  7. // @license MIT
  8. // @match https://github.com/*
  9. // @match https://*.github.com/*
  10. // @run-at document-start
  11. // @grant GM_addStyle
  12. // @grant GM_getResourceURL
  13. // @grant unsafeWindow
  14. // @icon https://www.google.com/s2/favicons?domain=github.com
  15. // @homepageURL https://github.com/holyspiritomb/userscripts
  16. // @homepage https://github.com/holyspiritomb/userscripts
  17. // @resource interReg https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Regular.woff2
  18. // @resource interRegIt https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Italic.woff2
  19. // @resource interMed https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Medium.woff2
  20. // @resource interMedIt https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-MediumItalic.woff2
  21. // @resource interBold https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Bold.woff2
  22. // @resource interBoldIt https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-BoldItalic.woff2
  23. // ==/UserScript==
  24.  
  25. (function() {
  26. let interReg = GM_getResourceURL("interReg", false);
  27. let interIt = GM_getResourceURL("interRegIt", false);
  28. let interMed = GM_getResourceURL("interMed", false);
  29. let interMedIt = GM_getResourceURL("interMedIt", false);
  30. let interBold = GM_getResourceURL("interBold", false);
  31. let interBoldIt = GM_getResourceURL("interBoldIt", false);
  32. var css = "";
  33. css += `
  34. @font-face {
  35. font-family: 'Inter';
  36. font-style: normal;
  37. font-weight: 400;
  38. font-display: swap;
  39. src: url(${interReg}) format("woff2");
  40. }
  41. @font-face {
  42. font-family: 'Inter';
  43. font-style: italic;
  44. font-weight: 400;
  45. font-display: swap;
  46. src: url(${interIt}) format("woff2");
  47. }
  48.  
  49. @font-face {
  50. font-family: 'Inter';
  51. font-style: normal;
  52. font-weight: 500;
  53. font-display: swap;
  54. src: url(${interMed}) format("woff2");
  55. }
  56. @font-face {
  57. font-family: 'Inter';
  58. font-style: italic;
  59. font-weight: 500;
  60. font-display: swap;
  61. src: url(${interMedIt}) format("woff2");
  62. }
  63.  
  64. @font-face {
  65. font-family: 'Inter';
  66. font-style: normal;
  67. font-weight: 700;
  68. font-display: swap;
  69. src: url(${interBold}) format("woff2");
  70. }
  71. @font-face {
  72. font-family: 'Inter';
  73. font-style: italic;
  74. font-weight: 700;
  75. font-display: swap;
  76. src: url(${interBoldIt}) format("woff2");
  77. }
  78.  
  79. body, .markdown-body { font-family: 'Inter', 'Lato', sans-serif !important; }`;
  80. if (typeof GM_addStyle != "undefined") {
  81. GM_addStyle(css);
  82. } else {
  83. var node = document.createElement("style");
  84. node.type = "text/css";
  85. node.appendChild(document.createTextNode(css));
  86. var heads = document.getElementsByTagName("head");
  87. if (heads.length > 0) {
  88. heads[0].appendChild(node);
  89. } else {
  90. // no head yet, stick it whereever
  91. document.documentElement.appendChild(node);
  92. }
  93. }
  94. })();