Github UI Font: Inter UI

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

当前为 2024-11-28 提交的版本,查看 最新版本

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