// ==UserScript== // @name Auto Fill Player Ratings with Custom Ranges // @namespace http://tampermonkey.net/ // @version 0.2 // @description Automatically fill player rating input boxes with random numbers within specified ranges // @author tanguy // @match *://*.ea.com/games/ea-sports-college-football/team-builder/team-create/* // @icon https://i.imgur.com/9nq6Rpp.png // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Function to generate a random number between min and max (inclusive) function getRandomNumber(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } // Function to add min-max input boxes function addRangeInputs() { const forms = document.querySelectorAll('form.playerRating-item'); forms.forEach(form => { const ratingDiv = form.querySelector('div.playerRating-item--ranking'); const existingMinBox = form.querySelector('input.min-range'); const existingMaxBox = form.querySelector('input.max-range'); if (!existingMinBox && !existingMaxBox) { // Create container div for min and max boxes const rangeContainer = document.createElement('div'); rangeContainer.style.display = 'flex'; rangeContainer.style.alignItems = 'center'; rangeContainer.style.marginBottom = '5px'; // Create min input box const minBox = document.createElement('input'); minBox.type = 'number'; minBox.placeholder = 'Min'; minBox.className = 'input input--sm min-range'; minBox.value = '0'; minBox.style.marginRight = '5px'; minBox.style.width = '80px'; // Adjust width as needed // Create max input box const maxBox = document.createElement('input'); maxBox.type = 'number'; maxBox.placeholder = 'Max'; maxBox.className = 'input input--sm max-range'; maxBox.value = '99'; maxBox.style.marginRight = '5px'; maxBox.style.width = '80px'; // Adjust width as needed // Append min and max input boxes to the container rangeContainer.appendChild(minBox); rangeContainer.appendChild(maxBox); // Insert the container above the rating div ratingDiv.parentNode.insertBefore(rangeContainer, ratingDiv); } }); } // Create and insert the "Randomize Ratings" button const button = document.createElement('button'); button.textContent = 'Randomize Ratings'; button.style.display = 'block'; button.style.margin = '10px 0'; button.style.padding = '10px'; button.style.backgroundColor = '#007bff'; button.style.color = '#fff'; button.style.border = 'none'; button.style.cursor = 'pointer'; document.body.insertBefore(button, document.body.firstChild); // Event listener for the button click button.addEventListener('click', function() { // Ensure range inputs are added addRangeInputs(); // Select all the form elements containing the player ratings const forms = document.querySelectorAll('form.playerRating-item'); forms.forEach(form => { const inputBox = form.querySelector('input[type="number"].input.input--sm.no-arrows'); const minBox = form.querySelector('input.min-range'); const maxBox = form.querySelector('input.max-range'); if (inputBox && minBox && maxBox) { const min = parseInt(minBox.value) || 0; const max = parseInt(maxBox.value) || 99; // Ensure min and max are within valid bounds const validMin = Math.max(0, min); const validMax = Math.min(99, max); if (validMin <= validMax) { // Set the value of the input box to a random number between validMin and validMax inputBox.value = getRandomNumber(validMin, validMax); } } }); }); // Initial call to add range inputs addRangeInputs(); })();