1

I have retinal damage in my left eye that makes reading text in serif fonts difficult.
Someone once posted this javascript snippet that I save in my Chrome bookmark's bar, that changes a web page's fonts to Tahoma when I click it. It's wonderful.

I've noticed in recent years there is a trend for designing web pages with text displaying in shades of gray, rather than solid black. Gray is harder to read for me than black, and it renders poorly when printed.

I'm not a coding expert. Is there a simple addition that can be made to this code that will also change font color to solid black?

Here's the code snippet:

    javascript:Array.prototype.forEach.call(document.getElementsByTagName("*"), function(e){e.style.fontFamily ="Tahoma"})
Sohail Ashraf
  • 10,078
  • 2
  • 26
  • 42
Bugsi
  • 11
  • 1
  • Hi, you can try to append `; color:black` just after `"Tahoma"` (but before '}'), this should set black color to any html tag. – Pierre Mar 14 '20 at 15:02

2 Answers2

0

You could add one more property of color to change the color.

 Array.prototype.forEach.call(
      document.getElementsByTagName("*"),
      function(e) {
        e.style.fontFamily = "Tahoma";
        e.style.color = "#000000";
      }
    );

Demo:

function changeColor() {
  Array.prototype.forEach.call(
    document.getElementsByTagName("*"),
    function(e) {
      e.style.fontFamily = "Tahoma";
      e.style.color = "#000000";
    }
  );
}
* {
    color: green;
 }
<button type="button" onclick="changeColor()">Change Color</button>
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<div>Div</div>
<p>P</p>
<span>span</span><br>
<a href="#">a</a>
Sohail Ashraf
  • 10,078
  • 2
  • 26
  • 42
  • 1
    This worked perfectly. It's exactly what I wanted. It makes text readable again for me. I don't know what's with the design trend to make websites unreadable, but this restores my sanity. THANK YOU. – Bugsi Mar 14 '20 at 22:04
0

YOu can do it the following way.

javascript:Array.prototype.forEach.call(
  document.getElementsByTagName("*"), 
  function(e){
     e.style.fontFamily ="Tahoma"; e.style.color ="#000 !important"
  })

Hope it helps :)

Mr Khan
  • 2,139
  • 1
  • 7
  • 22