I have created a repository on similar concept that changes the colors of the texts whose colors are recognised by html5 (we don't have to use actual #rrggbb values and could just use the names as html5 standardised about 140 of them)
$( document ).ready(function() {_x000D_
_x000D_
function hiliter(word, element) {_x000D_
var rgxp = new RegExp("\\b" + word + "\\b" , 'gi'); // g modifier for global and i for case insensitive _x000D_
var repl = '<span class="myClass">' + word + '</span>';_x000D_
element.innerHTML = element.innerHTML.replace(rgxp, repl);_x000D_
_x000D_
};_x000D_
_x000D_
hiliter('dolor', document.getElementById('dolor'));_x000D_
});
_x000D_
.myClass{_x000D_
_x000D_
background-color:red;_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<html>_x000D_
<head>_x000D_
<title>highlight</title>_x000D_
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>_x000D_
_x000D_
<link href="main.css" type="text/css" rel="stylesheet"/>_x000D_
_x000D_
</head>_x000D_
<body id='dolor'>_x000D_
<p >_x000D_
Lorem ipsum dolor sit amet, consectetuer adipiscing elit._x000D_
</p>_x000D_
<p>_x000D_
Quisque bibendum sem ut lacus. Integer dolor ullamcorper libero._x000D_
Aliquam rhoncus eros at augue. Suspendisse vitae mauris._x000D_
</p>_x000D_
<script type="text/javascript" src="main.js" charset="utf-8"></script>_x000D_
</body>_x000D_
</html>
_x000D_