Auto Fill Player Ratings with Custom Ranges and Auto-Click

Automatically fill player rating input boxes with random numbers within specified ranges and click on each input box to validate them.

Verzia zo dňa 22.08.2024. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Auto Fill Player Ratings with Custom Ranges and Auto-Click
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Automatically fill player rating input boxes with random numbers within specified ranges and click on each input box to validate them.
// @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
// ==/UserScript==

(function() {
    'use strict';

    function getRandomNumber(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function updateAllMinMaxInputs(globalMin, globalMax) {
        const minBoxes = document.querySelectorAll('input.min-range');
        const maxBoxes = document.querySelectorAll('input.max-range');

        minBoxes.forEach(minBox => minBox.value = globalMin);
        maxBoxes.forEach(maxBox => maxBox.value = globalMax);
    }

    function addGlobalRangeInputs() {
        const globalContainer = document.createElement('div');
        globalContainer.style.display = 'flex';
        globalContainer.style.alignItems = 'center';
        globalContainer.style.margin = '10px 0';
        globalContainer.style.padding = '10px';
        globalContainer.style.backgroundColor = '#f8f9fa';
        globalContainer.style.border = '1px solid #ddd';

        const globalMinBox = document.createElement('input');
        globalMinBox.type = 'number';
        globalMinBox.placeholder = 'Global Min';
        globalMinBox.value = '0';
        globalMinBox.style.marginRight = '10px';
        globalMinBox.style.width = '100px';

        const globalMaxBox = document.createElement('input');
        globalMaxBox.type = 'number';
        globalMaxBox.placeholder = 'Global Max';
        globalMaxBox.value = '99';
        globalMaxBox.style.marginRight = '10px';
        globalMaxBox.style.width = '100px';

        globalContainer.appendChild(globalMinBox);
        globalContainer.appendChild(globalMaxBox);

        document.body.insertBefore(globalContainer, document.body.firstChild);

        globalMinBox.addEventListener('input', function() {
            const globalMin = parseInt(globalMinBox.value) || 0;
            const globalMax = parseInt(globalMaxBox.value) || 99;
            updateAllMinMaxInputs(globalMin, globalMax);
        });

        globalMaxBox.addEventListener('input', function() {
            const globalMin = parseInt(globalMinBox.value) || 0;
            const globalMax = parseInt(globalMaxBox.value) || 99;
            updateAllMinMaxInputs(globalMin, globalMax);
        });
    }

    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) {
                const rangeContainer = document.createElement('div');
                rangeContainer.style.display = 'flex';
                rangeContainer.style.alignItems = 'center';
                rangeContainer.style.marginBottom = '5px';

                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';

                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';

                rangeContainer.appendChild(minBox);
                rangeContainer.appendChild(maxBox);



                ratingDiv.parentNode.insertBefore(rangeContainer, ratingDiv);


            }
        });
    }

    function addHeightWeightInputs() {
        const container = document.createElement('div');
        container.style.display = 'flex';
        container.style.alignItems = 'center';
        container.style.margin = '10px 0';
        container.style.padding = '10px';
        container.style.backgroundColor = '#f8f9fa';
        container.style.border = '1px solid #ddd';

        const heightMinBox = document.createElement('input');
        heightMinBox.type = 'number';
        heightMinBox.placeholder = 'Height Min (inches)';
        heightMinBox.value = '60';
        heightMinBox.style.marginRight = '10px';
        heightMinBox.style.width = '150px';

        const heightMaxBox = document.createElement('input');
        heightMaxBox.type = 'number';
        heightMaxBox.placeholder = 'Height Max (inches)';
        heightMaxBox.value = '80';
        heightMaxBox.style.marginRight = '10px';
        heightMaxBox.style.width = '150px';

        const weightMinBox = document.createElement('input');
        weightMinBox.type = 'number';
        weightMinBox.placeholder = 'Weight Min (lbs)';
        weightMinBox.value = '160';
        weightMinBox.style.marginRight = '10px';
        weightMinBox.style.width = '150px';

        const weightMaxBox = document.createElement('input');
        weightMaxBox.type = 'number';
        weightMaxBox.placeholder = 'Weight Max (lbs)';
        weightMaxBox.value = '400';
        weightMaxBox.style.marginRight = '10px';
        weightMaxBox.style.width = '150px';

        container.appendChild(heightMinBox);
        container.appendChild(heightMaxBox);
        container.appendChild(weightMinBox);
        container.appendChild(weightMaxBox);

        document.body.insertBefore(container, document.body.firstChild);

        const randomizeButton = document.createElement('button');
        randomizeButton.textContent = 'Randomize Height & Weight';
        randomizeButton.style.display = 'block';
        randomizeButton.style.margin = '10px 0';
        randomizeButton.style.padding = '10px';
        randomizeButton.style.backgroundColor = '#28a745';
        randomizeButton.style.color = '#fff';
        randomizeButton.style.border = 'none';
        randomizeButton.style.cursor = 'pointer';
        container.appendChild(randomizeButton);

        randomizeButton.addEventListener('click', function() {
            const heightMin = parseInt(heightMinBox.value) || 60;
            const heightMax = parseInt(heightMaxBox.value) || 80;
            const weightMin = parseInt(weightMinBox.value) || 160;
            const weightMax = parseInt(weightMaxBox.value) || 400;

            const heightSlider = document.querySelector('input[type="range"]#heightSlider');
            const weightSlider = document.querySelector('input[type="range"]#weightSlider');

            if (heightSlider) {
                heightSlider.value = getRandomNumber(heightMin, heightMax);
                // Trigger input and change events
                heightSlider.dispatchEvent(new Event('input', { bubbles: true }));
                heightSlider.dispatchEvent(new Event('change', { bubbles: true }));
            }

            if (weightSlider) {
                weightSlider.value = getRandomNumber(weightMin, weightMax);
                // Trigger input and change events
                weightSlider.dispatchEvent(new Event('input', { bubbles: true }));
                weightSlider.dispatchEvent(new Event('change', { bubbles: true }));
            }

            // Optionally set focus, though this doesn't trigger events
            heightSlider.focus();
            weightSlider.focus();

            heightSlider.click();


        });
    }

                    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);

                button.addEventListener('click', function() {
                    addRangeInputs();

                    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;
                            const validMin = Math.max(0, min);
                            const validMax = Math.min(99, max);
                            if (validMin <= validMax) {
                                inputBox.value = getRandomNumber(validMin, validMax);

                                // Click on the input box to trigger any associated event
                                inputBox.focus();
                                // Simulate pressing "Enter" to validate the input
                                const event = new KeyboardEvent('keydown', {
                                    key: 'Enter',
                                    code: 'Enter',
                                    keyCode: 13,
                                    bubbles: true,
                                });
                                inputBox.dispatchEvent(event);

                            }
                        }
                    });
                });



    addGlobalRangeInputs();
    addRangeInputs();
    addHeightWeightInputs();

})();