/* * displays a little counter within each post that displays the amount of likes * and amount of hates each post gets */ var mostLiked = 0; var mostHated = 0; var mostWhichevered = 0; let posts = document.querySelectorAll(".post"); for (let post of posts) { let likeCounter = 0; let hateCounter = 0; let countHate = false; let postbox = post.querySelector(".haitliek_box"); if (!postbox) continue; // post has no haeit/liek for (pointer = postbox.firstElementChild; pointer; pointer = pointer.nextElementSibling) { if (pointer.getAttribute("title") == "unliฤ“k") { likeCounter++; } else if (pointer.getAttribute("title") == "unhรฆit") { hateCounter++; } else if (pointer.classList.contains("icons-liek")) { countHate = false; } else if (pointer.classList.contains("icons-hait")) { countHate = true; } else if (pointer.tagName == "A" && pointer.href.includes("Profile")) { if (countHate) hateCounter++; else likeCounter++; } } if (likeCounter > mostLiked) mostLiked = likeCounter if (hateCounter > mostHated) mostHated = hateCounter if (likeCounter + hateCounter > mostWhichevered) mostWhichevered = likeCounter + hateCounter let counterElement = document.createElement("span"); counterElement.classList.add("hateLikeCounter"); counterElement.style.marginLeft = "5px"; counterElement.innerText = `๐Ÿ’™${likeCounter} ๐Ÿ’€${hateCounter}`; let firstBreak = postbox.querySelector("br"); postbox.insertBefore(counterElement, firstBreak); } const thread_title = document.getElementById("thread_title"); thread_title.innerText += " ๐Ÿ’™" + mostLiked.toString() + " ๐Ÿ’€" + mostHated.toString() + " โ“" + mostWhichevered.toString();