全局字体优化 - 小米字体(优化)/微软/思源黑体

优化网页字体显示,优先使用小米MiSans Medium,备选微软雅黑/思源黑体,并正确渲染Emoji

  1. // ==UserScript==
  2. // @name 全局字体优化 - 小米字体(优化)/微软/思源黑体
  3. // @namespace https://github.com/yourusername
  4. // @version 1.0.0
  5. // @description 优化网页字体显示,优先使用小米MiSans Medium,备选微软雅黑/思源黑体,并正确渲染Emoji
  6. // @author yuanjie221
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 定义 CSS 规则
  16. const cssRules = `
  17. @font-face {
  18. font-family: "Apple Color Emoji";
  19. src: local("Apple Color Emoji");
  20. unicode-range: U+2100-10FFFF;
  21. }
  22. @font-face {
  23. font-family: "Segoe UI Emoji";
  24. src: local("Segoe UI Emoji");
  25. unicode-range: U+2100-10FFFF;
  26. }
  27.  
  28. /* 全局字体规则 */
  29. :not(i, s, a:hover, span, textarea, [aria-hidden=true], [class^=fa], [class*=icon], #_#_) {
  30. font-family:
  31. "Apple Color Emoji", "Segoe UI Emoji",
  32. "MiSans Medium", /* 小米字体英文名 */
  33. "小米字体 Medium", /* 小米字体中文名 */
  34. "Microsoft YaHei", /* 微软雅黑 */
  35. "Noto Sans CJK SC", /* 思源黑体 */
  36. -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  37. }
  38.  
  39. /* 代码块专用字体 */
  40. pre, code, textarea, samp, kbd, var, [class*=code] {
  41. font-family:
  42. "Apple Color Emoji", "Segoe UI Emoji",
  43. ui-monospace, SFMono-Regular, Menlo, Consolas,
  44. "Source Han Mono SC", "Noto Sans Mono CJK SC", monospace !important;
  45. }
  46. `;
  47.  
  48. // 动态插入样式
  49. const style = document.createElement('style');
  50. style.type = 'text/css';
  51. style.appendChild(document.createTextNode(cssRules));
  52. document.head.appendChild(style);
  53.  
  54. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址