diff --git a/ratingColor.js b/ratingColor.js new file mode 100644 index 0000000..4893f16 --- /dev/null +++ b/ratingColor.js @@ -0,0 +1,20 @@ + function updateRating(){ + let cardVote = document.querySelectorAll('.card__vote'); + for(let voteCard of cardVote){ + if (voteCard.innerHTML >= 0 && voteCard.innerHTML <= 3.9) { + voteCard.style.color = "red"; + } else if (voteCard.innerHTML >= 4 && voteCard.innerHTML <= 6.9) { + voteCard.style.color = "orange"; + } else if (voteCard.innerHTML >= 7 && voteCard.innerHTML <= 7.9) { + voteCard.style.color = "lightgreen"; + } else if (voteCard.innerHTML >= 8 && voteCard.innerHTML <= 10) { + voteCard.style.color = "lawngreen"; + } + } + } + document.addEventListener("DOMContentLoaded", function () { + setTimeout(updateRating, 500); + }); + + const observer = new MutationObserver(updateRating); + observer.observe(document.body, { childList: true, subtree: true });