Guess the Weight of the Marrow: Randomizer

Adds a button to generate a random number between 200 and 800 and fill the input field.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Guess the Weight of the Marrow: Randomizer
// @namespace   KumaLandro - guess-the-weight-of-the-marrow-randomizer
// @match       https://www.neopets.com/medieval/guessmarrow.phtml*
// @grant       none
// @version     1.0
// @author      Kuma
// @description Adds a button to generate a random number between 200 and 800 and fill the input field.
// ==/UserScript==

(function() {
    'use strict';

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

    var inputField = document.querySelector('input[name="guess"]');

    function setRandomNumber() {
        var randomNumber = getRandomNumber(200, 800);
        inputField.value = randomNumber.toString();
    }

    var button = document.createElement('button');
    button.textContent = 'Randomize';
    button.style.marginRight = '10px';

    button.addEventListener('click', function(event) {
        event.preventDefault(); // Prevent the form from submitting
        setRandomNumber();
    });

    inputField.parentNode.insertBefore(button, inputField);

    setRandomNumber();
})();