Clean Font Weights

Make website font-weights standard (400) if below 400

目前为 2017-11-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Clean Font Weights
  3. // @namespace cleanFonts_kk
  4. // @description Make website font-weights standard (400) if below 400
  5. // @version 0.3
  6. // @author Kai Krause <kaikrause95@gmail.com>
  7. // @include *
  8. // @run-at document-end
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. function font() {
  13. // create the font
  14. var fontOverride_kk = document.createElement("style");
  15. fontOverride_kk.innerText = ".fontOverride_kk{font-weight: 400 !important;}";
  16. document.head.appendChild(fontOverride_kk);
  17.  
  18. // Get classes and tags without classes
  19. var allElements = document.querySelectorAll('*');
  20. for (var i = 0; i < allElements.length; i++) {
  21. var css = window.getComputedStyle(allElements[i], null);
  22. var fontWeight = css.getPropertyValue("font-weight");
  23. if (fontWeight && fontWeight < 400) {
  24. allElements[i].classList.add("fontOverride_kk");
  25. }
  26. }
  27. }
  28.  
  29. font();
  30.  
  31. setInterval(function(){
  32. font();
  33. }, 8000);