this post was submitted on 11 Aug 2023
74 points (95.1% liked)

Asklemmy

43919 readers
1206 users here now

A loosely moderated place to ask open-ended questions

Search asklemmy ๐Ÿ”

If your post meets the following criteria, it's welcome here!

  1. Open-ended question
  2. Not offensive: at this point, we do not have the bandwidth to moderate overtly political discussions. Assume best intent and be excellent to each other.
  3. Not regarding using or support for Lemmy: context, see the list of support communities and tools for finding communities below
  4. Not ad nauseam inducing: please make sure it is a question that would be new to most members
  5. An actual topic of discussion

Looking for support?

Looking for a community?

~Icon~ ~by~ ~@Double_A@discuss.tchncs.de~

founded 5 years ago
MODERATORS
 

Most of the time when people say they have an unpopular opinion, it turns out it's actually pretty popular.

Do you have some that's really unpopular and most likely will get you downvoted?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] rikudou@lemmings.world 2 points 1 year ago* (last edited 1 year ago)

Inspired by this, I wrote this quick function to paste in your browser console, if you're on PC:

(() => {
    const comments = [...document.querySelectorAll('main > div > .comments > li')];
    const commentsHolder = document.querySelector('main > div > .comments');

    const sorted = comments.sort((a, b) => {
        const upvotesA = Number(a.querySelector('.comment-bottom-btns > button:nth-child(1) > span').innerText);
        const downvotesA = Number(a.querySelector('.comment-bottom-btns > button:nth-child(2) > span').innerText);
        const upvotesB = Number(b.querySelector('.comment-bottom-btns > button:nth-child(1) > span').innerText);
        const downvotesB = Number(b.querySelector('.comment-bottom-btns > button:nth-child(2) > span').innerText);

        const ratioA = upvotesA > downvotesA ? downvotesA / upvotesA : upvotesA / downvotesA;
        const ratioB = upvotesB > downvotesB ? downvotesB / upvotesB : upvotesB / downvotesB;

        const diffA = 1 - ratioA;
        const diffB = 1 - ratioB;

        if (diffA === diffB) {
            return upvotesA + downvotesA >= upvotesB + downvotesB ? -1 : 1;
        }

        return diffA > diffB ? 1 : -1;
    });
    for (const comment of sorted) {
        commentsHolder.appendChild(comment);
    }
})()

It sorts the comments by controversial, but first you need to scroll through all the comments to load them all.