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-01 提交的版本,查看 最新版本

  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. // @homepageURL https://github.com/holyspiritomb/userscripts
  15. // @resource interReg https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Regular.woff2
  16. // @resource interRegIt https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Italic.woff2
  17. // @resource interMed https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Medium.woff2
  18. // @resource interMedIt https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-MediumItalic.woff2
  19. // @resource interBold https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-Bold.woff2
  20. // @resource interBoldIt https://cdn.jsdelivr.net/npm/inter-ui@4.1.0/web/Inter-BoldItalic.woff2
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. let interReg = GM_getResourceURL("interReg", false);
  25. let interIt = GM_getResourceURL("interRegIt", false);
  26. let interMed = GM_getResourceURL("interMed", false);
  27. let interMedIt = GM_getResourceURL("interMedIt", false);
  28. let interBold = GM_getResourceURL("interBold", false);
  29. let interBoldIt = GM_getResourceURL("interBoldIt", false);
  30. var css = "";
  31. css += `
  32. @font-face {
  33. font-family: 'Inter';
  34. font-style: normal;
  35. font-weight: 400;
  36. font-display: swap;
  37. src: url(${interReg}) format("woff2");
  38. }
  39. @font-face {
  40. font-family: 'Inter';
  41. font-style: italic;
  42. font-weight: 400;
  43. font-display: swap;
  44. src: url(${interIt}) format("woff2");
  45. }
  46.  
  47. @font-face {
  48. font-family: 'Inter';
  49. font-style: normal;
  50. font-weight: 500;
  51. font-display: swap;
  52. src: url(${interMed}) format("woff2");
  53. }
  54. @font-face {
  55. font-family: 'Inter';
  56. font-style: italic;
  57. font-weight: 500;
  58. font-display: swap;
  59. src: url(${interMedIt}) format("woff2");
  60. }
  61.  
  62. @font-face {
  63. font-family: 'Inter';
  64. font-style: normal;
  65. font-weight: 700;
  66. font-display: swap;
  67. src: url(${interBold}) format("woff2");
  68. }
  69. @font-face {
  70. font-family: 'Inter';
  71. font-style: italic;
  72. font-weight: 700;
  73. font-display: swap;
  74. src: url(${interBoldIt}) format("woff2");
  75. }
  76.  
  77. body, .markdown-body { font-family: 'Inter', 'Lato', sans-serif !important; }`;
  78. if (typeof GM_addStyle != "undefined") {
  79. GM_addStyle(css);
  80. } else {
  81. var node = document.createElement("style");
  82. node.type = "text/css";
  83. node.appendChild(document.createTextNode(css));
  84. var heads = document.getElementsByTagName("head");
  85. if (heads.length > 0) {
  86. heads[0].appendChild(node);
  87. } else {
  88. // no head yet, stick it whereever
  89. document.documentElement.appendChild(node);
  90. }
  91. }
  92. })();