Greasy Fork

来自缓存

Greasy Fork is available in English.

Drawing amount Lolzteam

try to take over the world!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Drawing amount Lolzteam
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       You
// @match        https://zelenka.guru/forums/contests/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru
// @grant        none
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */
/* jshint esversion:6 */


var sumTotal = document.createElement('a');
var nextpage = document.querySelector('#content > div > div > div > div > div.discussionList > form > span');
sumTotal.className = 'button OverlayTrigge1r';
sumTotal.innerHTML = 'Сумма розыгрышей';

document.querySelector('#content > div > div > div > div > div.pageNavLinkGroup > div.linkGroup.SelectionCountContainer').appendChild(sumTotal);


sumTotal.onclick = async function() {
    sumTotal.style.pointerEvents = 'none';
    function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms));}
    {
        let currentScrollHeight = 0;
        let scrollAttempts = 0;
        while (scrollAttempts < 5) {
            currentScrollHeight = document.body.scrollHeight;
            window.scrollTo(0, currentScrollHeight);
            if (nextpage) {
                nextpage.click();
            }
            await(sleep(1000));
            if (currentScrollHeight === document.body.scrollHeight) {
                scrollAttempts++;
            }
            else {
                scrollAttempts = 0;
                var dynamicElements = document.querySelectorAll('[id^="thread-"]');
                var total = 0;
                for (var i = 0; i < dynamicElements.length; i++) {
                    var threadTitle = dynamicElements[i].querySelector('span.threadTitle--prefixGroup > span.prefix.general.moneyContestWithValue');
                    if (threadTitle) {
                        var text = threadTitle.innerText;
                        var numbers = text.split('x');
                        var sum = 1;
                        for (var j = 0; j < numbers.length; j++) {
                            sum *= parseInt(numbers[j]);
                        }
                        total += sum;
                    }

                sumTotal.innerHTML = (total + ' | ' + dynamicElements.length);
            };

            }
             window.scrollTo(0, 0);
        }


    };
}