GC - BD Challengers Checklist

BD challengers checklist for Grundo's Cafe

  1. // ==UserScript==
  2. // @name GC - BD Challengers Checklist
  3. // @namespace https://www.grundos.cafe/
  4. // @version 1.1.1
  5. // @description BD challengers checklist for Grundo's Cafe
  6. // @author wibreth, soupfaerie, supercow64
  7. // @match https://www.grundos.cafe/~B/
  8. // @match https://www.grundos.cafe/~b/
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. const textToHTML = (text) => new DOMParser().parseFromString(text, "text/html");
  15.  
  16. /**
  17. * Analyse the HTML select element for a list of Challengers the user has collected.
  18. *
  19. * @param {Node} node The root node (default: document)
  20. * @returns {string[]} the list of Challengers as an array of basenames
  21. */
  22. const getCollectedChallengers = (node = doument) => {
  23. const allChallengers = Array.from(
  24. node.querySelectorAll(`.btn-link`)
  25. );
  26. return allChallengers.map((e) => e.textContent);
  27. };
  28.  
  29. /**
  30. * Returns a Promise that resolves to a listo f Challengers
  31. * the user has collected.
  32. *
  33. * @returns {string[]} list of collected Challengers
  34. */
  35. const getCollectedChallengersAsync = () =>
  36. fetch("/dome/1p/select/")
  37. .then((res) => res.text())
  38. .then(textToHTML)
  39. .then(getCollectedChallengers);
  40.  
  41. /**
  42. * Analyse the list of Challengers presented on the page ~milk.
  43. *
  44. * @param {*} node Node
  45. * @returns {{ node: Node, src: string}[]} an array of objects with two entries,
  46. * where `node` is the DOM node of the list element and `src` is the name
  47. * of the challenger
  48. */
  49. const getChallengersOnPage = (node = document) =>
  50. Array.from(node.querySelectorAll(".challenger")).map((e) => ({
  51. node: e,
  52. src: e.querySelector(".challengername").childNodes[0].textContent.trim()
  53. }));
  54.  
  55.  
  56. const html = `
  57. <h3 style="order:-3">Challengers You Are Missing</h3>
  58. <h3 style="order:-1">Challengers You Have Unlocked</h3>
  59. `;
  60.  
  61. function main(collectedChallengers) {
  62. const root = document.querySelector(".checklist");
  63. root.insertAdjacentHTML("beforeend", html);
  64.  
  65. if (collectedChallengers.length <= 0) {
  66. console.log('in battle!');
  67. document.querySelector(".hidden").classList.remove('hidden');
  68. return;
  69. }
  70. getChallengersOnPage().forEach(({ node, src }) => {
  71. if (!collectedChallengers.includes(src)) {
  72. node.classList.add('locked');
  73. }
  74. });
  75. }
  76.  
  77. getCollectedChallengersAsync().then(main);

QingJ © 2025

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