docs.rs font and size fixes

change the default fonts on rust docs sites

  1. // ==UserScript==
  2. // @name docs.rs font and size fixes
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.9.17
  5. // @description change the default fonts on rust docs sites
  6. // @author You
  7. // @match *://docs.rs/*
  8. // @match *://doc.rust-lang.org/*
  9. // @match *://crates.io/*
  10. // @match *://rust-lang.github.io/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=docs.rs
  12. // @grant none
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // THIS RUNS FIRST! The ordering matters (eg: for `p`).
  20.  
  21. // Select all elements with a class containing "font"
  22. const bodyElements = document.querySelectorAll("body, h1, h2, h3, h4, h5, h6, div, a, ol, li, ul, p, .font");
  23.  
  24. // Loop through each element
  25. bodyElements.forEach(element => {
  26. // https://stackoverflow.com/questions/38454240/using-css-important-with-javascript
  27. element.style = "line-height: normal !important";
  28. });
  29.  
  30. // THIS RUNS LAST! The ordering matters (eg: for `p`).
  31.  
  32. // Select all elements with a class containing "font" (common for code blocks)
  33. const fontSizeElements = document.querySelectorAll("pre, code, p");
  34.  
  35. // Loop through each element
  36. fontSizeElements.forEach(element => {
  37. // https://stackoverflow.com/questions/38454240/using-css-important-with-javascript
  38. element.style = "font-size: 12pt !important";
  39. });
  40.  
  41. })();