Last active
March 8, 2016 10:01
-
-
Save k1sul1/9fa949e1dcf5bd01ac89 to your computer and use it in GitHub Desktop.
bbPress Votes hide post if score is below threshold
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
// ES6 Magic, powered by Babel. | |
if (document.body.classList.contains("bbpress")) { | |
var replies = document.querySelectorAll(".reply"); | |
for (var i = 0; i < replies.length; i++) { | |
var reply = replies[i]; | |
if (parseInt(reply.querySelector(".bbpvotes-score").textContent, 10) <= -5) { | |
(function () { | |
var replyContent = reply.querySelector(".bbp-reply-content"); | |
replyContent.style.display = "none"; | |
var showReply = document.createElement("div"); | |
showReply.innerHTML = "<p class='bbpress-spamreply'>Tämä vastaus on piilotettu sen alhaisen pistemäärän vuoksi. Klikkaa tästä näyttääksesi vastauksen.</p>"; | |
showReply.addEventListener("click", function (e) { | |
e.target.remove(); | |
replyContent.style.display = "block"; | |
}); | |
reply.appendChild(showReply); | |
})(); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment