GC - Lottomatic

Generate lotto numbers with minimal overlap

  1. // ==UserScript==
  2. // @name GC - Lottomatic
  3. // @version 0.1.1
  4. // @description Generate lotto numbers with minimal overlap
  5. // @author wibreth
  6. // @namespace neopets
  7. // @match https://www.grundos.cafe/games/lottery/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // ==/UserScript==
  11.  
  12. // based on https://www.andrew.cmu.edu/user/kmliu/neopets/lottery.html with permission
  13.  
  14. (function() {
  15. 'use strict';
  16. /* globals $:false */
  17.  
  18. var numbers = GM_getValue("numbers", "");
  19.  
  20. function shuffle(o)
  21. {
  22. for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  23. return o;
  24. };
  25.  
  26. function leaf(a,b)
  27. {
  28. var res = new Array();
  29. for(var i=0; i<a.length; i++)
  30. {
  31. res[i*2] = a[i];
  32. res[i*2+1] = b[i];
  33. }
  34. return res;
  35. };
  36.  
  37. function generate() {
  38. var arr = new Array();
  39. for(var i=0; i<30; i++)
  40. arr[i] = i+1;
  41.  
  42. var arr1 = shuffle(arr);
  43. var arr2 = leaf( arr1.slice(0,15), arr1.slice(15,30) )
  44. var arr3 = leaf( arr2.slice(0,15), arr2.slice(15,30) )
  45. var arr4 = leaf( arr3.slice(0,15), arr3.slice(15,30) )
  46. var marr = arr1.concat(arr2,arr3,arr4);
  47.  
  48. numbers = new Array();
  49. for(i=0; i<20; i++)
  50. numbers[i] = [marr[6*i], marr[6*i+1], marr[6*i+2], marr[6*i+3], marr[6*i+4], marr[6*i+5]];
  51. GM_setValue('numbers', numbers);
  52. populate();
  53. };
  54.  
  55. function refresh() {
  56. $('.tickets').remove();
  57. numbers = [];
  58. generate();
  59. };
  60.  
  61. function populate() {
  62. var radiodiv = $('<div class="tickets" style="font-size: 0.8em">');
  63. numbers.forEach((ticket, idx) => {
  64. radiodiv.append(`<div><input type="radio" id="${idx+1}" name="ticket" value="${idx}">
  65. <label for="${idx+1}">${idx+1}: ${ticket.join(', ')}</label></div>`);
  66. });
  67. $('#lotto-sprite-container').append(radiodiv);
  68. $('.tickets input').change(function() {
  69. var ticket = numbers[$(this).val()];
  70. $('input[name="one"]').val(ticket[0]);
  71. $('input[name="two"]').val(ticket[1]);
  72. $('input[name="three"]').val(ticket[2]);
  73. $('input[name="four"]').val(ticket[3]);
  74. $('input[name="five"]').val(ticket[4]);
  75. $('input[name="six"]').val(ticket[5]);
  76. });
  77. $('label').click(function() {
  78. let id = $(this).prop("for");
  79. $("#" + id).click();
  80. });
  81. }
  82.  
  83. $('document').ready( function() {
  84. $('.center form:last-child() .half-width').addClass('flex-column');
  85. var refreshbtn = $('<a>⭮</a>')
  86. refreshbtn.click(function() {
  87. refresh();
  88. });
  89. $('#lotto-sprite-container').append(refreshbtn);
  90.  
  91. if (!numbers)
  92. generate();
  93. else
  94. populate();
  95. });
  96. })();

QingJ © 2025

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