GC - Gormball character selector and prize logger

Remembers your last played character and up to 100 prizes

当前为 2022-12-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GC - Gormball character selector and prize logger
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.2
  5. // @description Remembers your last played character and up to 100 prizes
  6. // @author wibreth
  7. // @match https://www.grundos.cafe/games/gormball/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_addStyle
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. /* globals $:false */
  17.  
  18. GM_addStyle('#prize-list {\
  19. max-width: 200px;\
  20. font-size: .8em;\
  21. max-height: 200px;\
  22. overflow: auto;\
  23. border: 1px solid #000;\
  24. position: absolute;\
  25. background: #fff;\
  26. padding: 5px 5px 5px 35px;\
  27. z-index: 3;\
  28. right: 0;\
  29. }\
  30. #prize-list-btn, #clear-list-btn {\
  31. float: right;\
  32. margin-top: -6px;\
  33. }\
  34. #page_content > p {\
  35. position: relative;\
  36. }');
  37.  
  38.  
  39. $('document').ready(() => {
  40. let listLoaded = false;
  41. let listVisible = false;
  42.  
  43. // log prizes
  44. if ($('strong:contains("Your Prize")').length != 0) { //win page
  45. let prizeList = GM_getValue("prizeList", []);
  46. if (prizeList.push($('.mt-1 strong').text()) > 100) // max of 100 items stored
  47. prizeList.shift();
  48. GM_setValue("prizeList", prizeList);
  49. }
  50.  
  51. // show prizes
  52. let showbtn = $('<input type="button" id="prize-list-btn" value="Show Prize Log">');
  53. showbtn.click(() => {
  54. if (listVisible) {
  55. $('#prize-list').hide();
  56. listVisible = false;
  57. return;
  58. }
  59. if (listLoaded) {
  60. $('#prize-list').show();
  61. listVisible = true;
  62. return;
  63. }
  64. let prizeList = GM_getValue("prizeList", []);
  65. let $prizeList = $('<ol id="prize-list">');
  66. if (!prizeList.length)
  67. $prizeList.append('<li>none!</li>');
  68. for (const prize of prizeList)
  69. $prizeList.append(`<li>${prize}</li>`);
  70. $('#page_content > p').append($prizeList);
  71. listLoaded = true;
  72. listVisible = true;
  73. });
  74. let clearbtn = $('<input type="button" id="clear-list-btn" value="Clear Prize Log">');
  75. clearbtn.click((e) => {
  76. if (!confirm("Are you sure you want to clear the prize log?")) {
  77. e.preventDefault();
  78. return;
  79. }
  80. if (listLoaded)
  81. $('#prize-list').empty();
  82. GM_setValue("prizeList", []);
  83. });
  84. $('#page_content > p:first-of-type').append(showbtn);
  85. $('#page_content > p:first-of-type').append(clearbtn);
  86.  
  87.  
  88. if ($('img[src$="gorm.gif"]').length == 0)
  89. return; //not on the character select page
  90.  
  91. let playerDD = GM_getValue("playerDD", 1); //default Thyassa
  92. $('#playerDD').val(playerDD);
  93.  
  94. $('#playerDD').change(function() {
  95. playerDD = $(this).val();
  96. GM_setValue("playerDD", playerDD);
  97. });
  98.  
  99. });
  100. })();