Custom Fixed Font in Gmail

Custom fixed-font in Gmail messages

当前为 2017-02-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Custom Fixed Font in Gmail
  3. // @namespace https://mail.google.com
  4. // @include https://mail.google.com/*
  5. // @icon https://mail.google.com/favicon.ico
  6. // @run-at document-start
  7. // @description Custom fixed-font in Gmail messages
  8. // @version 1.2
  9. // @license CC0; https://creativecommons.org/publicdomain/zero/1.0/
  10. // @homepageURL https://github.com/lidel/userscripts
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. var fontName = 'Droid Sans Mono';
  15. var fontSubset = 'latin';
  16.  
  17. // dragons below this line
  18. var fontCss = 'font-family: \'' + fontName + '\', monospace !important;';
  19. // plain-text messages
  20. var css = '.ii, .Ak {' + fontCss + '}';
  21. // editor
  22. css += '.editable {' + fontCss + '}';
  23. // load
  24. var heads = document.getElementsByTagName('head');
  25. if (heads.length > 0) {
  26. var link = document.createElement('link');
  27. link.rel = 'stylesheet';
  28. link.href = '//fonts.googleapis.com/css?family=' + fontName.replace(/\ /g, '+') + '&subset=' + fontSubset;
  29. heads[0].appendChild(link);
  30. var node = document.createElement('style');
  31. node.type = 'text/css';
  32. node.appendChild(document.createTextNode(css));
  33. heads[0].appendChild(node);
  34. }