[GC] - Underwater Fishing Data Logger

Fishing rewards logging.

目前为 2024-02-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name [GC] - Underwater Fishing Data Logger
  3. // @namespace Grundo's Cafe
  4. // @match https://www.grundos.cafe/water/fishing/
  5. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.4/dist/jquery.min.js
  6. // @version 1.2.4
  7. // @license MIT
  8. // @author Cupkait
  9. // @icon https://i.imgur.com/4Hm2e6z.png
  10. // @description Fishing rewards logging.
  11. // ==/UserScript==
  12.  
  13. const getPetLevelsAsync = fetch("/quickref/")
  14. .then(response => {
  15. if (!response.ok) {
  16. throw new Error(`Network response was not ok: ${response.statusText}`);
  17. }
  18. return response.text();
  19. })
  20. .then(html => {
  21. const tempElement = document.createElement('div');
  22. tempElement.innerHTML = html;
  23. const petList = tempElement.querySelector('#quickref_petlist').children;
  24. const petLevels = {};
  25. $(petList).each(function () {
  26. const petrefName = $(this).find('a').eq(0).attr('href').match(/_name=(.*?)$/)[1];
  27. const petFishingLevel = $(this).find('span').eq(12).text().match(/Fishing : (.*?)$/)[1];
  28. petLevels[petrefName] = petFishingLevel;
  29. });
  30. return petLevels;
  31. })
  32. .catch(error => {
  33. console.error(error);
  34. });
  35. let confirmResults = document.createElement("div");
  36. confirmResults.innerHTML = "Pending...";
  37. confirmResults.id = "confirmResults";
  38. confirmResults.style.cssText = "color: green; text-align: center; link-color:green; font-size:14px; font-weight:bold;";
  39. let getAvatar = ' ';
  40. getPetLevelsAsync.then(petLevels => {
  41. const fishContent = document.querySelector('div#page_content > main');
  42. const welcomeText = fishContent.children[1].innerText;
  43. const patientText = fishContent.children[2].innerText;
  44. const petCount = document.querySelectorAll('main > div > div');
  45. const petName = document.querySelector('div#userinfo > a').href;
  46. let opts = {
  47. mode: "no-cors",
  48. referrer: "no-referrer",
  49. headers: {
  50. 'Content-Type': 'application/x-www-form-urlencoded',
  51. }
  52. };
  53. function avatarCheck() {
  54. const avatarContainer = document.querySelector('div#page_event');
  55. if (
  56. !avatarContainer.innerText.includes("Let's Get This Bread") &&
  57. !avatarContainer.innerText.includes("Fishing - Titanic Squid")
  58. ) {
  59. getAvatar = '';
  60. console.log("No avatar detected.");
  61. } else {
  62. console.log("Avatar detected.");
  63. if (avatarContainer.innerText.includes("Fishing - Titanic Squid")) {
  64. getAvatar = 'Skeith - Fishing - Titanic Squid';
  65. } else if (avatarContainer.innerText.includes("Let's Get This Bread")) {
  66. getAvatar = 'Let\'s Get This Bread';
  67. }
  68. console.log(`Avatar:`, getAvatar);
  69. }
  70. }
  71. if (welcomeText.startsWith('Welcome to the') || patientText.startsWith('Nothing!') || patientText.startsWith('Looks like')) {
  72. console.log("Nothing to log here... it looks like no one went fishing.");
  73. } else {
  74. if (petCount.length === 0) { // One Pet
  75. const content = $("#page_content");
  76. const userName = /user=(.*?)"/g.exec(document.body.innerHTML)[1];
  77. const petName = $("#userinfo a").eq(2).text();
  78. const coolDown = content.find("strong").eq(0).text();
  79. const itemName = fishContent.querySelector("img").alt;
  80. let petLevel = petLevels[petName] || ' ';
  81. let levelUp = '';
  82. try {
  83. levelUp = content.find("p").eq(2).text().match(/to (.*?)!/)[1];
  84. petLevel = !isNaN(levelUp) ? parseInt(levelUp, 10) - 1 : petLevel;
  85. } catch (error) {
  86. // DO NOTHING
  87. }
  88. fishContent.insertAdjacentElement('beforebegin', confirmResults);
  89. confirmResults.innerHTML = `Your fishing results have been <a href="https://lookerstudio.google.com/reporting/ec18c798-ee62-4a7d-8315-5569c8de5ef6" target="_blank">submitted</a>.`
  90. const logResponse = `https://docs.google.com/forms/d/e/1FAIpQLSdBhJS1NSxHCmy32BqH0DEdQRJci1IVPOWUFcaothsiZjXu-w/formResponse?usp=pp_url&entry.886049257=${userName}&entry.343654154=${petName}&entry.1922136733=${petLevel}&entry.693447328=${levelUp}&entry.881968876=${itemName}&entry.303510013=${coolDown}&entry.1110645895=${getAvatar}`;
  91. fetch(logResponse, opts);
  92. } else {
  93. $(".flex.center-items.big-gap").each(function () {
  94. const userName = /user=(.*?)"/g.exec(document.body.innerHTML)[1];
  95. const petName = $(this).find("strong").eq(0).text();
  96. const itemURL = $(this).find("img").eq(1).attr("src");
  97. const coolDown = $(this).find("strong").eq(1).text();
  98. const itemName = $(this).find("p").eq(0).text().match(/ a (.*?)!/)[1];
  99. let petLevel = petLevels[petName] || '';
  100. let levelUp = '';
  101. try {
  102. levelUp = $(this).find("p").eq(1).text().match(/to (.*?)!/)[1];
  103. petLevel = !isNaN(levelUp) ? parseInt(levelUp, 10) - 1 : petLevel;
  104. } catch (error) {
  105. // DO NOTHING
  106. }
  107. fishContent.insertAdjacentElement('beforebegin', confirmResults);
  108. confirmResults.innerHTML = `Your fishing results have been <a href="https://lookerstudio.google.com/reporting/ec18c798-ee62-4a7d-8315-5569c8de5ef6" target="_blank">submitted</a>.`
  109. const logResponse = `https://docs.google.com/forms/d/e/1FAIpQLSdBhJS1NSxHCmy32BqH0DEdQRJci1IVPOWUFcaothsiZjXu-w/formResponse?usp=pp_url&entry.886049257=${userName}&entry.343654154=${petName}&entry.1922136733=${petLevel}&entry.693447328=${levelUp}&entry.881968876=${itemName}&entry.303510013=${coolDown}&entry.1110645895=${getAvatar}`;
  110. fetch(logResponse, opts);
  111. });
  112. }
  113. }
  114. });

QingJ © 2025

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