ka-extension / ka-extension-ts

A browser extension for Khan Academy.
MIT License
19 stars 11 forks source link

Button on discussion pages to show only unanswered questions #208

Open An0n3m0us opened 3 years ago

An0n3m0us commented 3 years ago

There currently is no sort options on discussion pages and all types of questions are shown, whether answered or not, so a number of unanswered questions go unnoticed.

I created code for this but I have not found the time to finish it off. One can test it by simply pasting it into the console on a page like the following: https://www.khanacademy.org/computing/computer-programming/d

It automatically processes the questions after the Show More button is pressed too.

old = 0
cur = 0
function timeout() {
    setTimeout(function () {
        cur = document.getElementsByClassName("_xu2jcg")
        if (old != cur.length) {
            old = cur.length
            for (var i = 0; i < document.getElementsByClassName("_3qeerd").length; i++) {
                document.getElementsByClassName("_3qeerd")[i].parentNode.parentNode.innerHTML = ""
            }
        }
        timeout();
    }, 1000);
}
timeout();
JettBurns14 commented 3 years ago

Nice! To make this more powerful, I'd suggest simply hiding (not deleting) answered questions, give them a custom class, and display them again if a button on the left side is clicked, hiding unanswered questions in the same way. This would allow for having answered/unanswered tabs, which I think #209 is talking about.

Let me know if/when you finish that and we'll see about combining this with #209 in a larger update.