Lottery Ticket Generator

Generates 6 random numbers

  1. // ==UserScript==
  2. // @name Lottery Ticket Generator
  3. // @namespace neopets
  4. // @version 2020.01.18.2
  5. // @description Generates 6 random numbers
  6. // @match http://www.neopets.com/games/lottery.phtml
  7. // @require https://code.jquery.com/jquery-3.5.1.min.js
  8. // ==/UserScript==
  9.  
  10. $("form[action='process_lottery.phtml'] table").css({"width" : "auto"}).find("tbody tr").append(`&nbsp;<td style="padding:10px;"><button id="randomTicket" type="button">Random</button></td>`);
  11.  
  12. const genNum = (min, max) => Math.floor(Math.random() * max) + min;
  13.  
  14. const genTicket = () => {
  15. let ticket = [];
  16. for (let i = 0; i < 6; i++) {
  17. let randomNumber = genNum(1, 30);
  18. while (ticket.includes(randomNumber)) {
  19. randomNumber = genNum(1, 30);
  20. }
  21. ticket.push(randomNumber);
  22. }
  23. ticket.sort((a, b) => a - b);
  24. return ticket;
  25. };
  26.  
  27. $("#randomTicket").on("click", function (event) {
  28. event.preventDefault();
  29. const ticket = genTicket();
  30. $("form[action='process_lottery.phtml'] table input").each(function (index, element) {
  31. $(element).val(ticket[index]);
  32. });
  33. }).click();

QingJ © 2025

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