You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
TamperMonkeyScript/archive/auto_claim_sepolia.js

105 lines
3.8 KiB

// ==UserScript==
// @name Sepolia Faucet Monitor and Button Clicker
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Monitor the value of a specific element, and click buttons in a loop when the value is greater than or equal to 2
// @author Jack
// @match https://sepolia-faucet.pk910.de/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 目标元素的CSS选择器
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';
const firstButtonSelector = 'body > div.faucet-wrapper > div > div > div > div.faucet-body > div > div.faucet-actions.center > button';
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';
const maxFaucetValue = 2.49;
// 发送消息到 Gotify
function sendMessageToGotify(title = "按钮点击通知", message = "第二个按钮已点击") {
const gotifyUrl = "https://gotify.erhe.top/message?token=A9KF--mx_12PjSu";
const payload = {
message: message,
title: title,
priority: 5
};
fetch(gotifyUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(response => {
if (response.ok) {
console.log("消息发送成功");
} else {
console.error(`消息发送失败,状态码: ${response.status}`);
}
})
.catch(error => {
console.error(`请求出现异常: ${error}`);
});
}
// 监控函数
function monitorElement() {
// 获取目标元素
const valueElement = document.querySelector(valueElementSelector);
// 如果元素存在,则提取浮点数部分
if (valueElement) {
const valueText = valueElement.textContent;
const floatValue = parseFloat(valueText);
// 如果浮点数大于等于 2,则进入死循环点击按钮
if (!isNaN(floatValue) && floatValue >= maxFaucetValue) {
console.log(`Value is ${floatValue}, entering loop to click buttons...`);
clickButtonsLoop();
} else {
console.log(`Value is ${floatValue}`);
}
} else {
console.log('Target value element not found.');
}
}
// 点击按钮循环函数
function clickButtonsLoop() {
// 点击第一个按钮
const firstButton = document.querySelector(firstButtonSelector);
if (firstButton) {
firstButton.click();
}
// 点击第二个按钮
const secondButton = document.querySelector(secondButtonSelector);
if (secondButton) {
secondButton.click();
// 第二个按钮点击后发送消息
sendMessageToGotify();
}
// 继续循环
setTimeout(clickButtonsLoop, 1000);
}
// 隐藏图片函数
function hideImage() {
// 使用 XPath 查找元素
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;
if (imageElement) {
imageElement.style.display = 'none';
} else {
console.log('Target image element not found.');
}
}
setTimeout(hideImage, 2000);
// 设置一个死循环,每隔一秒执行一次监控函数
setInterval(monitorElement, 1000);
})();