Bitcoin Forum

Other => Meta => Topic started by: TheBeardedBaby on October 22, 2019, 04:56:07 AM



Title: Sort by merit in the anniversary art contest?
Post by: TheBeardedBaby on October 22, 2019, 04:56:07 AM
I think this thread is perfect for implementation of "sort by merited posts" feature. It is a fast growing one and attract a lot of interest.
I tried using Top-merited recent replies (https://bitcointalk.org/index.php?action=merit;stats=topreplies) but it's not responsible anymore. :(


Title: Re: Sort by merit in the anniversary art contest?
Post by: hatshepsut93 on October 22, 2019, 08:07:31 AM
Here you go, it adds a "sort by merit" button right before the "reply" button. Works well even on large threads, tried it with all posts from the anniversary art thread.

Code:
// ==UserScript==
// @name     Bitcointalk Sort By Merit
// @version  1.0
// @grant    none
// @include        https://bitcointalk.org/index.php?topic=*
// @run-at         document-end
// ==/UserScript==

const sortBtn = document.createElement("a")
sortBtn.href = "javascript:void(0)"
sortBtn.textContent = "sort by merit"

const threadButtons = document.querySelector("td.mirrortab_back")

threadButtons.prepend(document.createTextNode(" | "))
threadButtons.prepend(sortBtn)

sortBtn.addEventListener("click", sortByMerit)

function sortByMerit() {
    const table = document.querySelector("#bodyarea .bordercolor > tbody")
    const posts = [...table.rows]
        .map(post => {
            try {
                const merit = [...post.querySelectorAll(".td_headerandpost .smalltext i > a")]
                    .map(e => {
                        return parseInt(e.nextSibling.textContent.match(/\((.*)\)/)[1])
                    })
                    .reduce((acc, e) => acc + e, 0)

                return { merit, post }
            } catch (e) {
                console.error(e)
            }
        })
        .sort(({ merit: merit1 }, { merit: merit2 }) => merit2 - merit1)

    posts.forEach(({ post, merit }) => {
        try {
            table.append(post)
        } catch (e) {}
    })
}



Title: Re: Sort by merit in the anniversary art contest?
Post by: LoyceV on October 22, 2019, 09:02:46 AM
For users who don't want to install user scripts: see 10yearBitcointalk.tk (http://10yearbitcointalk.tk/), following iasenko's request, updated every hour.

Update: the site works, but you risk running into bitcointalk.org image proxy: Bandwidth limit exceeded (https://bitcointalk.org/index.php?topic=5195094) problems.


Title: Re: Sort by merit in the anniversary art contest?
Post by: AverageGlabella on October 22, 2019, 09:27:32 AM
Its probably best to filter by merit once the competition is closer to ending otherwise it would be unfair to anyone who is posting new art as their art would be towards the end of the pile. We still have close to a month for entries and I think the better ones will start getting posted closer towards that date because better art usually takes longer to make. 


Title: Re: Sort by merit in the anniversary art contest?
Post by: LoyceV on October 22, 2019, 06:59:34 PM
Its probably best to filter by merit once the competition is closer to ending otherwise it would be unfair to anyone who is posting new art as their art would be towards the end of the pile.
I made a solution for that too, showing posts in random order: 10yearBitcointalk.tk/random.html (http://10yearbitcointalk.tk/random.html).
The order of posts is changed at each (hourly) update.