auto_claim_sepolia.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // ==UserScript==
  2. // @name Sepolia Faucet Monitor and Button Clicker
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description Monitor the value of a specific element, and click buttons in a loop when the value is greater than or equal to 2
  6. // @author Jack
  7. // @match https://sepolia-faucet.pk910.de/*
  8. // @grant none
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12. // 目标元素的CSS选择器
  13. const valueElementSelector = 'body > div.faucet-wrapper > div > div > div > div.faucet-body > div > div.pow-status-container > div > div.row.pow-status-top > div:nth-child(1) > div.status-value';
  14. const firstButtonSelector = 'body > div.faucet-wrapper > div > div > div > div.faucet-body > div > div.faucet-actions.center > button';
  15. const secondButtonSelector = 'body > div.faucet-wrapper > div > div > div > div.faucet-body > div > div > div:nth-child(2) > div:nth-child(4) > div > div > button';
  16. const maxFaucetValue = 2.49;
  17. // 发送消息到 Gotify
  18. function sendMessageToGotify(title = "按钮点击通知", message = "第二个按钮已点击") {
  19. const gotifyUrl = "https://gotify.erhe.top/message?token=A9KF--mx_12PjSu";
  20. const payload = {
  21. message: message,
  22. title: title,
  23. priority: 5
  24. };
  25. fetch(gotifyUrl, {
  26. method: 'POST',
  27. headers: {
  28. 'Content-Type': 'application/json'
  29. },
  30. body: JSON.stringify(payload)
  31. })
  32. .then(response => {
  33. if (response.ok) {
  34. console.log("消息发送成功");
  35. } else {
  36. console.error(`消息发送失败,状态码: ${response.status}`);
  37. }
  38. })
  39. .catch(error => {
  40. console.error(`请求出现异常: ${error}`);
  41. });
  42. }
  43. // 监控函数
  44. function monitorElement() {
  45. // 获取目标元素
  46. const valueElement = document.querySelector(valueElementSelector);
  47. // 如果元素存在,则提取浮点数部分
  48. if (valueElement) {
  49. const valueText = valueElement.textContent;
  50. const floatValue = parseFloat(valueText);
  51. // 如果浮点数大于等于 2,则进入死循环点击按钮
  52. if (!isNaN(floatValue) && floatValue >= maxFaucetValue) {
  53. console.log(`Value is ${floatValue}, entering loop to click buttons...`);
  54. clickButtonsLoop();
  55. } else {
  56. console.log(`Value is ${floatValue}`);
  57. }
  58. } else {
  59. console.log('Target value element not found.');
  60. }
  61. }
  62. // 点击按钮循环函数
  63. function clickButtonsLoop() {
  64. // 点击第一个按钮
  65. const firstButton = document.querySelector(firstButtonSelector);
  66. if (firstButton) {
  67. firstButton.click();
  68. }
  69. // 点击第二个按钮
  70. const secondButton = document.querySelector(secondButtonSelector);
  71. if (secondButton) {
  72. secondButton.click();
  73. // 第二个按钮点击后发送消息
  74. sendMessageToGotify();
  75. }
  76. // 继续循环
  77. setTimeout(clickButtonsLoop, 1000);
  78. }
  79. // 隐藏图片函数
  80. function hideImage() {
  81. // 使用 XPath 查找元素
  82. const imageElement = document.evaluate('/html/body/div[2]/div/div/div/div[3]/div/div[1]/div/div[1]/div/img', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  83. if (imageElement) {
  84. imageElement.style.display = 'none';
  85. } else {
  86. console.log('Target image element not found.');
  87. }
  88. }
  89. setTimeout(hideImage, 2000);
  90. // 设置一个死循环,每隔一秒执行一次监控函数
  91. setInterval(monitorElement, 1000);
  92. })();