font mono beta🔧

let english website display mono font

  1. // ==UserScript==
  2. // @name font mono beta🔧
  3. // @description let english website display mono font
  4. // @namespace font_mono
  5. // @author Covenant
  6. // @version 0.9.2
  7. // @license MIT
  8. // @homepage
  9. // @match *://*/*
  10. // @exclude https://fonts.google.com/*
  11. // @exclude https://fonts.bunny.net/*
  12. // @exclude https://codepen.io/*
  13. // @exclude https://web.archive.org/*
  14. // @exclude https://www.programmingfonts.org/*
  15. // @exclude https://www.codingfont.com/*
  16. // @exclude https://fonts.adobe.com/*
  17. // @exclude file:///*
  18. // @icon data:image/svg+xml;base64,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2IiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSIxNiIgZGF0YS12aWV3LWNvbXBvbmVudD0idHJ1ZSIgY2xhc3M9Im9jdGljb24gb2N0aWNvbi1pbmZvIj4KICAgIDxwYXRoIGQ9Ik0wIDhhOCA4IDAgMSAxIDE2IDBBOCA4IDAgMCAxIDAgOFptOC02LjVhNi41IDYuNSAwIDEgMCAwIDEzIDYuNSA2LjUgMCAwIDAgMC0xM1pNNi41IDcuNzVBLjc1Ljc1IDAgMCAxIDcuMjUgN2gxYS43NS43NSAwIDAgMSAuNzUuNzV2Mi43NWguMjVhLjc1Ljc1IDAgMCAxIDAgMS41aC0yYS43NS43NSAwIDAgMSAwLTEuNWguMjV2LTJoLS4yNWEuNzUuNzUgMCAwIDEtLjc1LS43NVpNOCA2YTEgMSAwIDEgMSAwLTIgMSAxIDAgMCAxIDAgMloiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KPC9zdmc+
  19. // @grant GM_setValue
  20. // @grant GM_getValue
  21. // @grant GM_registerMenuCommand
  22. // @connect
  23. // @run-at document-body
  24. // @noframes
  25. // ==/UserScript==
  26. const ary_os_font=[["","'Consolas',","'Cascadia Mono',","'Noto Mono',","'Noto Sans Mono',","'Liberation Mono',","'DejaVu Sans Mono',","'DroidSans_Mono',"],["'Cutive Mono',","'Courier Prime',","'M PLUS 1 Code',","'Xanh Mono',","'New Tegomin',"]];
  27. const ary_url=["https://fonts.googleapis.com/css2?family=Cutive+Mono&display=swap",
  28. "https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&display=swap",
  29. "https://fonts.googleapis.com/css2?family=M+PLUS+1+Code:wght@100;200;300;400;500;600;700&display=swap",
  30. "https://fonts.googleapis.com/css2?family=Xanh+Mono:ital@0;1&display=swap",
  31. "https://fonts.googleapis.com/css2?family=New+Tegomin&display=swap"];
  32. var value=GM_getValue('value', [0,0]);
  33. var web_font_name=GM_getValue('web_font_name', ary_os_font[value[0]][value[1]]);
  34. var font_weight=GM_getValue('font_weight', 300);
  35. var letter_spacing=web_font_name=="'Cutive Mono',"?"letter-spacing: -0.05em;":"";
  36. var timeoutID_1;
  37. function create_style(textContent,id,class_name){
  38. let style=create_node("style",class_name,true,document.body);
  39. style.type='text/css';
  40. style.id=id;
  41. style.textContent=textContent;
  42. return style;
  43. }
  44. const font_family_code="font-family: "+web_font_name+"'Noto Sans Mono','Noto Mono','Cascadia Code','Consolas','Liberation Mono','Monaco','Courier New','flag_patch','flag_white_patch','color_emoji','Noto Sans CJK JP','Meiryo','Yu Gothic','Microsoft JhengHei','symbol_sans','symbol2_sans','emoji_back',monospace;";
  45. const font_face_default=`
  46. @font-face{font-family: 'color_emoji';src: local('Twemoji Mozilla'),/*url('file:///C:/Program Files/Mozilla Firefox/fonts/TwemojiMozilla.ttf'),*/local('Noto Color Emoji'),local('Segoe UI Emoji'),local('Apple Color Emoji');}
  47. @font-face{font-family: 'symbol_sans';src: local('Segoe UI Symbol'),local('NotoSansSymbols-Regular'),local('NotoSansSymbols-Regular-Subsetted'),local('Noto Sans Symbols')/*,local('Apple Symbols')*/;}
  48. @font-face{font-family: 'symbol2_sans';src: local('NotoSansSymbols2-Regular'),local('NotoSansSymbols-Regular-Subsetted2'),local('Meiryo');}
  49. @font-face{font-family: 'emoji_back';src: local('Noto Color Emoji'),local('Toss Face Font Web'),local('Segoe UI Emoji');}
  50. @font-face{font-family: 'old_google';src: local('Noto Color Emoji'),local('NotoColorEmoji');}\n@font-face{font-family: 'old_samsung';src: local('SamsungColorEmoji');}
  51. @font-face{font-family: 'DroidSans_Mono';src: local('DroidSansMono');}\n@font-face{font-family: 'Cutive_Mono';src: local('Cutive Mono');}
  52. @font-face{font-family: 'Roboto_Regular';src: local('Roboto');}\n@font-face{font-family: 'Noto_Serif';src: local('NotoSerif');}
  53. @font-face{font-family: 'Dancing_Script';src: local('DancingScript');}\n@font-face{font-family: 'Coming_Soon';src: local('ComingSoon');}\n@font-face{font-family: 'Carrois_GothicSC';src: local('CarroisGothicSC-Regular');}
  54. \n`;
  55. var style_font_face;
  56. var style_user_css;
  57. if(document.body!=null){
  58. style_font_face=create_style(font_face_default,"gm_font_face_font_monospace",["user_gm_font_face","css_font_monospace"]);
  59. style_user_css=create_style("","gm_user_css_font_monospace",["user_gm_css","css_font_monospace"]);
  60. style_user_css.textContent+=`
  61. html:lang(en),body:lang(en),body:not(.fake_class) p:lang(en):not(.fake_class),body:lang(en):not(.fake_class) a:not(.fake_class),body:lang(en) li,body:lang(en) div:not(.emoji),body:lang(en) section,body:lang(en) blockquote
  62. {`+font_family_code+`font-weight: `+font_weight+`;`+letter_spacing+`/*font-size: 0.99em;font-stretch: ultra-condensed;*/}
  63. body:not(.fake_class) p:lang(en):not(.fake_class){font-size: 1rem;}
  64. html:lang(en) a{font-stretch: ultra-condensed;}\n`;
  65. }
  66. function create_link_stylesheet(url,class_name,is_appendChild,node,refNode){
  67. let link_stylesheet=create_node("link",class_name,is_appendChild,node,refNode);
  68. link_stylesheet.rel="stylesheet";
  69. link_stylesheet.href=url;
  70. return link_stylesheet;
  71. }
  72. function create_node(tagname,class_name,is_appendChild,node,refNode){
  73. let element=document.createElement(tagname);
  74. element.id="";
  75. if(Array.isArray(class_name)){
  76. for(let i=0; i<class_name.length; i++){element.classList.add(class_name[i]);}
  77. }else if(typeof class_name==='string'){element.classList.add(class_name);}
  78. if(is_appendChild){node.appendChild(element);}else{node.insertBefore(element, refNode);}
  79. return element;
  80. }
  81. function fn_url(url){
  82. let obj_url=new URL(url);
  83. let params=obj_url.searchParams;
  84. //let params=new URLSearchParams(obj_url.search);
  85. return [obj_url,params];
  86. }
  87. //console.log("break");
  88. function style_01(){
  89. if(style_user_css.parentNode==undefined){
  90. console.log("style_font_mono undefined");
  91. document.body.appendChild(style_font_face);
  92. document.body.appendChild(style_user_css);
  93. window.clearInterval(timeoutID_1);
  94. }
  95. }
  96. (function() {
  97. 'use strict';
  98. if(document.body==null)return;
  99. let url=fn_url(document.location);
  100. timeoutID_1=window.setInterval(( () => style_01()), 1000);
  101. //window.setTimeout(( () => style_01() ), 10000);
  102. GM_registerMenuCommand("use os mono font"+(value[0]==0?"✔️":""), () => {
  103. if(value[0]==0){
  104. value[1]=(value[1]+1)%(ary_os_font[value[0]].length);
  105. value=GM_setValue('value', [value[0],value[1]]);
  106. }else if(value[0]==1){
  107. value=GM_setValue('value', [0,1]);
  108. }
  109. });
  110. GM_registerMenuCommand("use web font"+(value[0]==1?"✔️":""), () => {
  111. if(value[0]==1){
  112. value[1]=(value[1]+1)%(ary_os_font[value[0]].length);
  113. value=GM_setValue('value', [value[0],value[1]]);
  114. }else if(value[0]==0){
  115. value=GM_setValue('value', [1,0]);
  116. }
  117. });
  118. if(value[0]==1){
  119. if(url[0].host.search(new RegExp("github.com", "i"))!=0&&url[0].host.search(new RegExp("steamdb.info", "i"))!=0&&url[0].host.search(new RegExp("developer.mozilla.org", "i"))!=0){
  120. let link=create_link_stylesheet(ary_url[value[1]],"gm_font_face_font_monospace",true,document.head);
  121. GM_registerMenuCommand("rst, "+web_font_name, () => {
  122. value=GM_setValue('value', [0,0]);
  123. });
  124. }else{
  125. GM_registerMenuCommand("rst, load webfont css fail", () => {
  126. value=GM_setValue('value', [0,0]);
  127. });
  128. }
  129. }
  130. //console.log(style_user_css.parentNode);
  131. })();

QingJ © 2025

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