Bitcoin Forum
July 12, 2025, 01:54:55 AM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Sort by merit in the anniversary art contest?  (Read 402 times)
TheBeardedBaby (OP)
Legendary
*
Offline Offline

Activity: 2268
Merit: 3200


₿uy / $ell ..oeleo ;(


View Profile
October 22, 2019, 04:56:07 AM
Last edit: October 22, 2019, 05:06:27 AM by iasenko
 #1

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 but it's not responsible anymore. Sad

hatshepsut93
Legendary
*
Offline Offline

Activity: 3052
Merit: 2166


View Profile
October 22, 2019, 08:07:31 AM
Merited by Welsh (4), hugeblack (3), Halab (2), stompix (1), Xal0lex (1), Findingnemo (1), DdmrDdmr (1), o_e_l_e_o (1), TheBeardedBaby (1)
 #2

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) {}
    })
}

LoyceV
Legendary
*
Offline Offline

Activity: 3738
Merit: 19274


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
October 22, 2019, 09:02:46 AM
Last edit: October 22, 2019, 07:05:52 PM by LoyceV
Merited by malevolent (2), stompix (1), TheBeardedBaby (1), Kalemder (1)
 #3

For users who don't want to install user scripts: see 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 problems.

¡uʍop ǝpᴉsdn pɐǝɥ ɹnoʎ ɥʇᴉʍ ʎuunɟ ʞool no⅄
AverageGlabella
Legendary
*
Offline Offline

Activity: 1232
Merit: 1082


View Profile
October 22, 2019, 09:27:32 AM
Merited by suchmoon (4), Welsh (2), DdmrDdmr (2), LoyceV (1), malevolent (1)
 #4

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. 
LoyceV
Legendary
*
Offline Offline

Activity: 3738
Merit: 19274


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
October 22, 2019, 06:59:34 PM
Merited by lucky80 (1)
 #5

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.
The order of posts is changed at each (hourly) update.

¡uʍop ǝpᴉsdn pɐǝɥ ɹnoʎ ɥʇᴉʍ ʎuunɟ ʞool no⅄
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!