OnlineligaFriendlyInfo

Zusatzinfos für Friendlies für www.onlineliga.de (OFA)

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/424583/919418/OnlineligaFriendlyInfo.js

  1. /*jshint esversion: 8, multistr: true */
  2. /* globals waitForKeyElements */
  3.  
  4. // ==UserScript==
  5. // @name OnlineligaFriendlyInfo
  6. // @namespace https://gf.qytechs.cn/de/users/577453
  7. // @version 0.1.0
  8. // @license LGPLv3
  9. // @description Zusatzinfos für Friendlies für www.onlineliga.de (OFA)
  10. // @author KnutEdelbert
  11. // @match https://www.onlineliga.de
  12. // @require https://gf.qytechs.cn/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
  13. // @grant unsafeWindow
  14. // ==/UserScript==
  15. (function() {
  16. 'use strict';
  17.  
  18. var $ = $ || window.jQuery;
  19.  
  20. async function showTeamInfo(){
  21. let userId;
  22. const parentDiv = this.parentNode;
  23. const offerRow = parentDiv.parentNode.parentNode;
  24. const spanClick = $(parentDiv).find('span.ol-team-name').attr("onclick");
  25. const userIdMatch = spanClick.match(/{\s*'?userId'?\s*:\s*(\d+)\s*}/);
  26. let lineup11Value = 0;
  27. let lineupAllValue = 0;
  28.  
  29. function euroValue(val){
  30. return `${new Intl.NumberFormat('de-DE').format(val)} €`;
  31. }
  32.  
  33. function getData(url){ return $.get(url); }
  34.  
  35. if (userIdMatch){
  36. userId = userIdMatch[1];
  37. const teamData = await getData(`/team/overview/squad?userId=${userId}`);
  38. const teamValue = $(teamData).find('span.bandarole-team-value > span.pull-right').text();
  39. const teamRows = $(teamData).filter('div.team-overview-squad-row');
  40. const teamSize = teamRows.length;
  41. const playerValues = [];
  42. teamRows.each(function(){
  43. const row = $(this);
  44. const playerValue = parseInt(row.find('div.col-md-3.col-lg-3.col-sm-6.col-xs-6.text-right').text().trim().replace(/\./g,''),10) || 0;
  45. playerValues.push(playerValue);
  46. const lineupState = row.find('span.ol-player-squad-display.pull-right');
  47. if (lineupState.length > 0){
  48. if (!$($(lineupState)[0]).hasClass('player-substitute-display')){
  49. lineup11Value += playerValue;
  50. }
  51. lineupAllValue += playerValue;
  52. }
  53. });
  54. const friendly11Value = euroValue(lineup11Value);
  55. const friendlyAllValue = euroValue(lineupAllValue);
  56. const teamValueInt = parseInt(teamValue.replace(/\./g,''),10);
  57. const top11Value = playerValues.sort((a,b) => b - a).slice(0,11).reduce((a, b) => a + b, 0);
  58. const friendlyPercent = Math.round((lineup11Value/teamValueInt) * 100);
  59.  
  60. const average11Value = Math.round(lineup11Value/11);
  61. const averageTeam = Math.round(teamValueInt/teamSize);
  62.  
  63. $(`<div style="font-size:12px;margin-left:20px;"> \
  64. <span style="white-space:nowrap;" title="Durchschnitt MW Aufstellung">${euroValue(average11Value)}/</span> \
  65. <span style="white-space:nowrap;" title="% v. Top 11 (MW)">${Math.round(lineup11Value/top11Value*100)}%</span> \
  66. <br/><span style="white-space:nowrap;" title="Durchschnitt MW Team">${euroValue(averageTeam)}/</span> \
  67. <span style="white-space:nowrap;" title="% v. MW Team">${Math.round(lineup11Value/teamValueInt*100)}%</span> \
  68. </div>`).appendTo($(offerRow).children().eq(1));
  69.  
  70. }
  71. }
  72.  
  73. function run(){
  74. $("div#olFriendlyRequestsContent").on('click','span.user-badge',showTeamInfo);
  75. }
  76.  
  77. function init(){
  78. waitForKeyElements (
  79. "div#olFriendlyRequestsContent",
  80. run
  81. );
  82. }
  83. init();
  84.  
  85. })();

QingJ © 2025

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