Bye Calculator

Projected bye score for DT Draft

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Bye Calculator
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Projected bye score for DT Draft
// @author       Sahil Choujar
// @match        https://www.ultimatefooty.com.au/*/matchup*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @grant        none
// ==/UserScript==

var team1 = [];
var team2 = [];
var one, score1, count, pro1, two, pro2, team1score, team2score, score2, curr1, curr2;

const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());


(function() {
    'use strict';
    

    // Your code here...
    $(document).ready(function(){
        
        one = $(".points.scoring.team1-player .player-actual span");
        score1 = $(".text-left .team-actual");
        count = 0;
        
        one.each(function(index, value){
            team1.push({key: count, score: $(value).text()});
            count++;
        });
        
        pro1 = $(".points.yet-to-play.team1-player .player-proj");
        
        
        pro1.each(function(index, value){
            team1.push({key: count, score: $(value).html().trim()});
            count++;
        });
        
        curr1 = $(".points.in-progress.team1-player .player-actual span");
        
        curr1.each(function(index, value){
            team1.push({key: count, score: $(value).text()});
            count++;
        });
        
        $.merge(one, pro1);
        $.merge(one, curr1);
        
        team1.sort(function (a, b) {
            return a.score.localeCompare( b.score, undefined, {numeric: true});
        });
        
        team1.reverse();
        team1.length = params.count || 12;
        
        team1score = 0;
        team1.forEach(function(player){
            //console.log(player.score);
            console.log(player.key, ": ", player.score);
            team1score = team1score + parseInt(player.score);
            $(one[player.key]).closest("td").css("background-color", "orange");
        });
        console.log(team1score);
        console.info(team1.toString());
        
        score1.html(team1score + " <s>" + score1.html() + "</s>");
        
        score2 = $(".text-right .team-actual");
        
        two = $(".points.scoring.team2-player .player-actual span");
        pro2 = $(".points.yet-to-play.team2-player .player-proj");
        count = 0;
        
        two.each(function(index, value){
            team2.push({key: count, score: $(value).text()});
            count++;
        });
        
        pro2.each(function(index, value){
            team2.push({key: count, score: $(value).html().trim()});
            count++;
        });
        
        curr2 = $(".points.in-progress.team2-player .player-actual span");
        
        curr2.each(function(index, value){
            team2.push({key: count, score: $(value).text()});
            count++;
        });
        
        
        $.merge(two, pro2);
        $.merge(two, curr2);
        
        team2.sort(function (a, b) {
            return a.score.localeCompare( b.score, undefined, {numeric: true});
        });
        
        team2.reverse();
        team2.length = params.count || 12;
        
        team2score = 0;
        team2.forEach(function(player){
            console.log(player.key, ": ", player.score);
            team2score = team2score + parseInt(player.score);
            $(two[player.key]).closest("td").css("background-color", "orange");
        });
        
        console.log(team2score);
        //console.info(team2.toString());
   
        
        score2.html(team2score + " <s>" + score2.html() + "</s>");
        
    });
})();