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

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