TMVN Squad BP WA XP

Upgrade from ASI in Squad Overview script

目前为 2020-10-11 提交的版本。查看 最新版本

// ==UserScript==
// @name        TMVN Squad BP WA XP
// @version     1
// @description	Upgrade from ASI in Squad Overview script
// @namespace   https://trophymanager.com
// @include     https://trophymanager.com/club/*/squad/*
// @include     https://trophymanager.com/club/*/squad/*
// @include     https://trophymanager.com/club/%20/squad/
// @grant		none
// ==/UserScript==

function collect() {
	var ret = {};
	var len = arguments.length;
	for (var i = 0; i < len; i++) {
		for (var p in arguments[i]) {
			if (arguments[i].hasOwnProperty(p)) {
				ret[p] = arguments[i][p];
			}
		}
	}
	return ret;
}

var new_player_array = [];
var team_b_id = "";

$.ajaxSetup({
	async: false
});

$.post("/ajax/players_get_select.ajax.php", {
	"type": "change",
	"club_id": SUBPAGE
}, function (data) {

	data = JSON.parse(data);
	new_player_array = data.post;

});

function objectLength(obj) {
	var result = 0;
	for (var prop in obj) {
		if (obj.hasOwnProperty(prop)) {
			result++;
		}
	}
	return result;
}

$("#player_table tr:eq(0)")[0].childNodes[5].innerHTML = 'Recommend';
$("#player_table tr:eq(0)").append('<th>BP</th><th>WA</th><th>XP</th>');
var count = 0;
var countU21 = 0;
var totalBankPrice = 0;
var totalBankPriceU21 = 0;
var totalWage = 0;
var totalWageU21 = 0;
var totalASI = 0;
var totalASIU21 = 0;
var totalXP = 0;
var totalXPU21 = 0;

$("#player_table tr > .text_fade > div").not(".text_fade_overlay").find("a[player_link]").each(function () {

	player_link = $(this).attr("player_link");
	if (new_player_array[player_link] == null && team_b_id === "") {

		console.log("finding team b id");

		$.post("https://trophymanager.com/ajax/players_get_info.ajax.php", {
			"player_id": player_link,
			"type": "history",
			"show_non_pro_graphs": false
		}, function (data) {

			data = JSON.parse(data);
			team_b_id = data.table.nat[0].klub_id;
		});

		$.post("/ajax/players_get_select.ajax.php", {
			"type": "change",
			"club_id": team_b_id
		}, function (data) {

			data = JSON.parse(data);
			new_player_array = collect(new_player_array, data.post);
		});

	}

	current_player_info = new_player_array[player_link];

	parent_select = $(this).parent().parent().parent();

	let pow = Math.pow;
	let bp = 0;
	if (current_player_info.fp === "GK") {
		bp = (current_player_info.asi * 500 * pow((300 / (Number(current_player_info.age) * 12 + Number(current_player_info.month))), 2.5)) * 0.75;
	} else {
		bp = (current_player_info.asi * 500 * pow((300 / (Number(current_player_info.age) * 12 + Number(current_player_info.month))), 2.5));
	}
	parent_select.append('<td>' + (bp / 1000000).toFixed(2) + '</td>');
	parent_select.append('<td>' + Math.round(current_player_info.wage / 1000) + '</td>');
	parent_select.append('<td>' + current_player_info.rutine + '</td>');

	if (Number(current_player_info.age) > 21) {
		count++;
	} else {
		countU21++;
	}
	if (Number(current_player_info.age) > 21) {
		totalBankPrice += bp;
	} else {
		totalBankPriceU21 += bp;
	}
	if (Number(current_player_info.age) > 21) {
		totalWage += Number(current_player_info.wage);
	} else {
		totalWageU21 += Number(current_player_info.wage);
	}
	if (Number(current_player_info.age) > 21) {
		totalASI += current_player_info.asi;
	} else {
		totalASIU21 += current_player_info.asi;
	}
	if (Number(current_player_info.age) > 21) {
		totalXP += Number(current_player_info.rutine);
	} else {
		totalXPU21 += Number(current_player_info.rutine);
	}
});

$('div.column3_a')[0].childNodes[3].childNodes[3].childNodes[2].childNodes[1].innerHTML +=
'<br>' +
'Total BP (M): ' + (totalBankPrice / 1000000).toFixed(2) + '<br>' +
'Total Wage: ' + totalWage.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Total ASI: ' + totalASI.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Total XP: ' + totalXP.toFixed(1) + '<br>' +
'<br>' +
'Average BP (M): ' + (totalBankPrice / 1000000 / count).toFixed(2) + '<br>' +
'Average Wage: ' + Math.round(totalWage / count).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Average ASI: ' + (totalASI / count).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Average XP: ' + (totalXP / count).toFixed(1) + '<br>';

$('div.column3_a')[0].childNodes[3].childNodes[3].childNodes[6].childNodes[1].innerHTML +=
'<br>' +
'Total BP (M): ' + (totalBankPriceU21 / 1000000).toFixed(2) + '<br>' +
'Total Wage: ' + totalWageU21.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Total ASI: ' + totalASIU21.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Total XP: ' + totalXPU21.toFixed(1) + '<br>' +
'<br>' +
'Average BP (M): ' + (totalBankPriceU21 / 1000000 / count).toFixed(2) + '<br>' +
'Average Wage: ' + Math.round(totalWageU21 / count).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Average ASI: ' + (totalASIU21 / count).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '<br>' +
'Average XP: ' + (totalXPU21 / count).toFixed(1) + '<br>';

$.ajaxSetup({
	async: true
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址