Greasy Fork is available in English.
Filters the draws on the site by the amount from more to less
当前为
// ==UserScript==
// @name Filter of draws by amount Lolzteam
// @version 0.1
// @description Filters the draws on the site by the amount from more to less
// @match https://zelenka.guru/forums/contests/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru
// @grant none
// @namespace http://greasyfork.icu/users/997663
// ==/UserScript==
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms));}
{
let currentScrollHeight = 0;
let scrollAttempts = 0;
while (scrollAttempts < 5) {
currentScrollHeight = document.body.scrollHeight;
const latestThreads = document.querySelectorAll('.latestThreads._insertLoadedContent > div[id^="thread-"]');
const threads = [];
latestThreads.forEach(thread => {
const id = thread.id;
const prefixes = thread.querySelectorAll('.moneyContestWithValue');
let sum = 0;
prefixes.forEach(prefix => {
if (prefix.innerText.includes('x')) {
const [x, y] = prefix.innerText.split('x');
sum += parseInt(x) * parseInt(y);
} else {
const numbers = prefix.innerText.split(/\s+/).map(Number);
sum += numbers.reduce((a, b) => a + b, 0);
}
});
threads.push({ id, sum });
});
threads.sort((a, b) => b.sum - a.sum);
threads.forEach(thread => {
const element = document.getElementById(thread.id);
element.parentNode.appendChild(element);
});
await(sleep(1000));
if (currentScrollHeight === document.body.scrollHeight) {
scrollAttempts++;
}
else {
scrollAttempts = 0;
}
}
}