Anonymous ID: 639ad8 Aug. 5, 2018, 11:19 a.m. No.2466234   🗄️.is 🔗kun   >>6516 >>6643

Just in case anyone wants it, I have updated the code to move the most answered posts in a full thread to the top. It makes it easier to read up on old threads. To use it, enter a number of required answers for each post, and push the button.

 

Put the code in Options -User JS.

 

let requiredAnswers = 3; //Change this value if neededlet numberOfPosts = $('.post').length;let thread = document.getElementsByClassName("thread")[0];let done = false;let warning = false;let buttonInput = document.createElement("div");if (active_page == 'thread') { buttonInput.id = "buttonInput"; buttonInput.innerHTML = "<br<input type='button' id='button' value='Get most answered posts' onclick='prependMostAnswered()'><input id='inputField' type='textfield' value='" + requiredAnswers + "'>"; thread.parentNode.insertBefore(buttonInput, thread);}function prependMostAnswered() { numberOfPosts = $('.post').length; if (done) { return; } if (numberOfPosts > 750) { if (document.getElementById("warning") != null) { document.getElementById("warning").innerHTML = ""; } var br = document.createElement("br"); thread.parentNode.insertBefore(br, thread); let numberOfAnswers = inputField.value; for (let i = 0; i < document.getElementsByClassName("post").length; i++) { let post = document.getElementsByClassName("post")[i]; let answers = post.childNodes[0].childNodes[10]; if (answers !== undefined && answers.childElementCount >= numberOfAnswers) { post.style.backgroundColor = '#FFFCEE'; thread.parentNode.insertBefore(post, thread); var br = document.createElement("br"); thread.parentNode.insertBefore(br, thread); } } document.getElementById("buttonInput").innerHTML = ""; done = true; } else { document.getElementById("button").value = "Wait for " + (750 - numberOfPosts) + " new posts."; if (!warning) { var text = document.createElement("div"); text.id = "warning"; text.innerHTML = "<br> Thread is not full, the code only works for finshed threads."; thread.parentNode.insertBefore(text, thread); warning = true; } } }