Github Code Font: Victor Mono

Makes Github's code font Victor Mono. Targets mobile Chrome-based browsers via Adguard for Android & mobile Iceraven (Firefox) via Violentmonkey.

  1. // ==UserScript==
  2. // @name Github Code Font: Victor Mono
  3. // @namespace https://github.com/holyspiritomb
  4. // @author spiritomb
  5. // @version 1.5.6a
  6. // @description Makes Github's code font Victor Mono. Targets mobile Chrome-based browsers via Adguard for Android & mobile Iceraven (Firefox) via Violentmonkey.
  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 victorR https://cdn.jsdelivr.net/npm/victormono@1.5.6/dist/woff/VictorMono-Regular.woff
  18. // @resource victorRW https://cdn.jsdelivr.net/npm/victormono@1.5.6/dist/woff2/VictorMono-Regular.woff2
  19. // @resource victorI https://cdn.jsdelivr.net/npm/victormono@1.5.6/dist/woff/VictorMono-Italic.woff
  20. // @resource victorIW https://cdn.jsdelivr.net/npm/victormono@1.5.6/dist/woff2/VictorMono-Italic.woff2
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. // this is hacky but it works?
  25. let victorRegular = GM_getResourceURL("victorR", false);
  26. let victorRegular2 = GM_getResourceURL("victorRW", false);
  27. let victorItalic = GM_getResourceURL("victorI", false);
  28. let victorItalic2 = GM_getResourceURL("victorIW", false);
  29. var css = "";
  30. css += `
  31. :root {
  32. --fontStack-monospace: "Victor Mono", ui-monospace, Menlo, Consolas, Liberation Mono, monospace;
  33. }
  34.  
  35. @font-face {
  36. font-family: "Victor Mono";
  37. src: url(${victorRegular2}) format("woff2"),
  38. url(${victorRegular}) format("woff");
  39. font-weight: 400;
  40. font-style: normal;
  41. font-display: swap;
  42. }
  43. @font-face {
  44. font-family: "Victor Mono";
  45. src: url(${victorItalic2}) format("woff2"),
  46. url(${victorItalic}) format("woff");
  47. font-weight: 400;
  48. font-style: italic;
  49. font-display: swap;
  50. }
  51. .CheckStep-line,
  52. .blob-code-inner,
  53. .commit-ref,
  54. .highlight pre,
  55. .markdown-body code,
  56. .markdown-body pre,
  57. .markdown-body tt,
  58. .pl-c,
  59. .pl-c span,
  60. .react-blob-print-hide,
  61. .react-file-line,
  62. .text-mono,
  63. code .link-gray,
  64. code,
  65. kbd,
  66. pre,
  67. textarea#read-only-cursor-text-area,
  68. tt,
  69. [class^='pl-'] {
  70. font-family: "Victor Mono" !important;
  71. }
  72. .pl-c,
  73. .pl-c span {
  74. font-style: italic !important;
  75. }
  76.  
  77. `;
  78. if (typeof GM_addStyle != "undefined") {
  79. GM_addStyle(css);
  80. } else {
  81. let styleNode = document.createElement("style");
  82. styleNode.appendChild(document.createTextNode(css));
  83. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  84. }
  85. })();