virtualmanager.com - Show rating importance based on position

Important skills are highlighted with different colors to show their importance level (e.g., very high, high, medium, low, very low).

  1. // ==UserScript==
  2. // @name virtualmanager.com - Show rating importance based on position
  3. // @namespace https://greasyfork.org/en/users/884999-l%C3%A6ge-manden
  4. // @version 0.2
  5. // @description Important skills are highlighted with different colors to show their importance level (e.g., very high, high, medium, low, very low).
  6. // @author
  7. // @match https://www.virtualmanager.com/players/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=virtualmanager.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // Get the player's position from the document
  17. let positionElement = document.getElementsByClassName('position')[0];
  18. if (!positionElement) {
  19. console.error('Position element not found');
  20. return;
  21. }
  22. let position = positionElement.innerText;
  23. position = position.replace('Position', '').split(', ')[0].trim().toLowerCase();
  24. console.log(position);
  25.  
  26. // Map of positions to their respective importance ratings and elements
  27. const positionImportanceMap = {
  28. 'keeper': [
  29. { importance: 'Very high', element: 'Håndtering' },
  30. { importance: 'Very high', element: 'I luften' },
  31. { importance: 'Very high', element: 'Spring' },
  32. { importance: 'Very high', element: 'En mod en' },
  33. { importance: 'Medium', element: 'Hurtighed' },
  34. { importance: 'Medium', element: 'Acceleration' },
  35. { importance: 'Very low', element: 'Aflevering' },
  36. { importance: 'Very low', element: 'Udholdenhed' },
  37. { importance: 'Very low', element: 'Lederskab' },
  38. { importance: 'Very low', element: 'Kampånd' }
  39. ],
  40. 'forsvar': [
  41. { importance: 'Very high', element: 'Tackling' },
  42. { importance: 'Medium', element: 'Hovedstød' },
  43. { importance: 'Medium', element: 'Positionering' },
  44. { importance: 'High', element: 'Hurtighed' },
  45. { importance: 'High', element: 'Acceleration' },
  46. { importance: 'Very low', element: 'Aflevering' },
  47. { importance: 'Very low', element: 'Dribling' },
  48. { importance: 'Very low', element: 'Afslutning' },
  49. { importance: 'Low', element: 'Lederskab' }
  50. ],
  51. 'midtbane': [
  52. { importance: 'Very high', element: 'Aflevering' },
  53. { importance: 'Medium', element: 'Afslutning' },
  54. { importance: 'Very high', element: 'Dribling' },
  55. { importance: 'Very low', element: 'Tackling' },
  56. { importance: 'Very low', element: 'Dødboldsituationer' },
  57. { importance: 'Medium', element: 'Hurtighed' },
  58. { importance: 'Very low', element: 'Acceleration' },
  59. { importance: 'High', element: 'Udholdenhed' },
  60. { importance: 'Very low', element: 'Lederskab' },
  61. { importance: 'Medium', element: 'Kampånd' }
  62. ],
  63. 'angreb': [
  64. { importance: 'Medium', element: 'Aflevering' },
  65. { importance: 'Very high', element: 'Afslutning' },
  66. { importance: 'Very high', element: 'Dribling' },
  67. { importance: 'Very low', element: 'Tackling' },
  68. { importance: 'Low', element: 'Dødboldsituationer' },
  69. { importance: 'High', element: 'Hurtighed' },
  70. { importance: 'High', element: 'Acceleration' },
  71. { importance: 'Very low', element: 'Udholdenhed' },
  72. { importance: 'Low', element: 'Lederskab' },
  73. { importance: 'Low', element: 'Kampånd' }
  74. ]
  75. };
  76.  
  77. // Apply color based on importance for the current position
  78. if (positionImportanceMap[position]) {
  79. console.log(`Handling ${position} position`);
  80. positionImportanceMap[position].forEach(item => {
  81. ColorBasedOnImportance(item.importance, item.element);
  82. });
  83. } else {
  84. console.log('Unknown position');
  85. }
  86. })();
  87.  
  88. // Function to apply color based on importance
  89. function ColorBasedOnImportance(importance, element) {
  90. // Map of importance levels to their corresponding colors
  91. const colorMap = {
  92. 'Very low': '#ffffffcc', // rgb(255 255 255 / 80%)
  93. 'Low': '#c0d7c030', // rgb(192 215 192 / 48%)
  94. 'Medium': 'rgb(0 169 0 / 32%)', // rgb(116 167 116 / 48%)
  95. 'High': 'rgb(0 213 0 / 59%)', // rgb(60 187 60 / 48%)
  96. 'Very high': 'rgb(0 213 0 / 91%)' // rgb(0 141 0 / 48%)
  97. };
  98.  
  99. // Get all elements with the class 'label'
  100. let labels = document.getElementsByClassName('label');
  101. // Get the color corresponding to the importance level
  102. let color = colorMap[importance] || '#ffffffcc';
  103.  
  104. console.log('Importance: ' + importance);
  105. console.log('Element: ' + element);
  106.  
  107. // Iterate over the labels to find the matching element
  108. for (let item of labels) {
  109. if (item.innerText === element) {
  110. // Apply the color as a box shadow to the parent element
  111. item.parentElement.style.boxShadow = 'inset 0px -10px 30px 0px ' + color;
  112. console.log(item.parentElement.style.boxShadow);
  113. break;
  114. }
  115. }
  116. }