Show ratings in comments - Greasemonkey script

#1

Simple Greasemonkey script to show buyers ratings in comments section.

In raters array add “username : rating” pair.

// ==UserScript==
// @name        Show me raters
// @namespace    
// @version     1
// @grant       none
// ==/UserScript==

 var raters = {
   'Shamalli': 5,
   'BadRater': 1
 };

var comments = document.getElementsByClassName("comment__info");
 
for (var i = 0; i < comments.length; i++) {
  var names = comments[i].getElementsByClassName("t-link");

  for (var j = 0; j < names.length; j++) {
    for (var rater_name in raters) {
      if (rater_name == names[j].innerHTML) {
        var rating = raters[rater_name];
        switch (rating) {
          case 5:
          case 4:
            var name_color = "transparent";
            var class_name = "-color-green-bright";
            break;
          case 3:
            var name_color = "#f59620";
            var class_name = "-color-orange";
            break;
          case 2:
          case 1:
            var name_color = "#ce2424";
            var class_name = "-color-red";
            break;
        }
        
        names[j].style.backgroundColor = name_color;
    
        var elem = document.createElement('span');
        elem.setAttribute('class', 'e-text-label ' + class_name + ' -size-s');
        elem.innerHTML = rating;
    
        insertAfter(elem, names[j]);
    
        var space = document.createTextNode("\u00A0");
        insertAfter(space, names[j]);
      }
    }
  }
}

function insertAfter(newNode, referenceNode) {
    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}