AntonMs,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.red{
background-color: #FF0000;
}
</style>
</head>
<body>
<p>1</p><p class="advclass">7789</p><p class="advclass">1</p>
<script>
function get(sel,str)
{
return Array.prototype.filter.call(document.querySelectorAll(sel), function(el) { return el.textContent.indexOf(str) > -1 })
}
var elem = get('.advclass','7789')[0]
elem.classList.add('red')
</script>
</body>
</html>