您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add week Median to league screen on Sleeper.com.
当前为
- // ==UserScript==
- // @name Sleeper.com - FFL - Output Weekly Median.
- // @description Add week Median to league screen on Sleeper.com.
- // @version 1.0.0
- // @namespace http://jbout.in/
- // @author Jeremy 'HLVE'
- // @match *://sleeper.com/leagues/*/*
- // @require https://code.jquery.com/jquery-1.9.1.min.js
- // @grant GM_setValue
- // @grant GM_getValue
- // @grant GM_addStyle
- // ==/UserScript==
- $(window).on("load popstate", function (event) {
- tabIDs();
- if (window.location.pathname.split('/')[3].indexOf("league") != -1) {
- var medianValue = calculateMedian();
- }
- $(document).on('click touchend', '#tabLeague', function () {
- setTimeout(function () {
- var medianValue = calculateMedian();
- }, 150);
- });
- });
- function tabIDs() {
- const tabEl = $("div.center-tab-selector > div.item-tab"),
- matchupTab = $("div.center-tab-selector > div.item-tab:contains('MATCHUP')"),
- teamTab = $("div.center-tab-selector > div.item-tab:contains('TEAM')"),
- leagueTab = $("div.center-tab-selector > div.item-tab:contains('LEAGUE')"),
- playersTab = $("div.center-tab-selector > div.item-tab:contains('PLAYERS')"),
- trendTab = $("div.center-tab-selector > div.item-tab:contains('TREND')"),
- tradeTab = $("div.center-tab-selector > div.item-tab:contains('TRADES')"),
- scoreTab = $("div.center-tab-selector > div.item-tab:contains('SCORES')");
- setTimeout(function () {
- $(matchupTab).attr('id', 'tabMatchup');
- $(teamTab).attr('id', 'tabTeam');
- $(leagueTab).attr('id', 'tabLeague');
- $(playersTab).attr('id', 'tabPlayers');
- $(trendTab).attr('id', 'tabTrending');
- $(tradeTab).attr('id', 'tabTrades');
- $(scoreTab).attr('id', 'tabScores');
- }, 35);
- }
- function calculateMedian() {
- var matchupTitleContainer = $(".league-tab-container .title").first(),
- scoreContainer = $("div.league-matchups div.roster-score-and-projection-matchup div.score"),
- numbers = [];
- $(scoreContainer).each(function () {
- var value = parseFloat($(this).text());
- if (!isNaN(value)) {
- numbers.push(value);
- }
- });
- // Sort the scores in ascending order
- numbers.sort(function (a, b) {
- return a - b;
- });
- // Calculate the median
- var median;
- var len = numbers.length;
- if (len === 0) {
- median = 0; // If no numbers found, median is 0
- } else if (len % 2 === 1) {
- median = numbers[Math.floor(len / 2)];
- } else {
- var mid1 = numbers[len / 2 - 1];
- var mid2 = numbers[len / 2];
- median = (mid1 + mid2) / 2;
- }
- var calcMedian = Math.ceil(median * 100) / 100;
- // Round up to the next full decimal place.
- if (!$(".league-panel-header .post-draft-league-header .name").text().includes('Guillotine')) {
- $(matchupTitleContainer).append(' (<b>Weekly Median</b>: ' + calcMedian + ')');
- }
- // $("div.matchup-row div.roster-score-and-projection-matchup div.score").each(
- // function () {
- // const scoreText = $(this).text().trim();
- // if (scoreText > calcMedian) {
- // $(this).addClass('score-over-median');
- // $(this).append('<b class="score-over-median">☑</b>');
- // }
- // }
- // );
- }