jack 10 miesięcy temu
rodzic
commit
2420bc5c62
6 zmienionych plików z 171 dodań i 14 usunięć
  1. 3 1
      .gitignore
  2. 6 4
      Readme.mk
  3. BIN
      __pycache__/main.cpython-310.pyc
  4. 0 9
      docker-compose.yaml
  5. 57 0
      main.go
  6. 105 0
      scripts/auto_claim_sepolia.js

+ 3 - 1
.gitignore

@@ -1,2 +1,4 @@
 # 忽略 macOS 系统生成的 .DS_Store 文件
-.DS_Store
+.DS_Store
+.idea
+.vscode

+ 6 - 4
Readme.mk

@@ -1,10 +1,12 @@
+油猴插件填写例子
+
 // ==UserScript==
-// @name         sosovalue 半自动点击
+// @name         脚本名称
 // @namespace    http://tampermonkey.net/
 // @version      1.6
-// @description  检测并点击页面中的按钮
+// @description  脚本简介
 // @author       Jack
-// @match        https://sosovalue.com/*/*
-// @require      http://192.168.31.28:5000/sosovalue_execute.user.js
+// @match        https://目标网站(需要监控网站).com/*/*
+// @require      http://服务ip:服务端口/scripts/your_script.js
 // @grant        none
 // ==/UserScript==

BIN
__pycache__/main.cpython-310.pyc


+ 0 - 9
docker-compose.yaml

@@ -1,9 +0,0 @@
-services:
-  nginx:
-    image: nginx:latest
-    container_name: tampermonkey-nginx
-    ports:
-      - "5000:80"
-    volumes:
-      - ./scripts:/usr/share/nginx/html/scripts
-    restart: always

+ 57 - 0
main.go

@@ -0,0 +1,57 @@
+package main
+
+import (
+	"fmt"
+	"log"
+	"net/http"
+	"os"
+	"path/filepath"
+)
+
+const scriptsDir = "scripts"
+
+func main() {
+	// 确保脚本目录存在
+	if _, err := os.Stat(scriptsDir); os.IsNotExist(err) {
+		os.Mkdir(scriptsDir, os.ModePerm)
+	}
+
+	// 提供脚本下载
+	http.HandleFunc("/scripts/", func(w http.ResponseWriter, r *http.Request) {
+		if r.Method == http.MethodGet {
+			fileName := filepath.Base(r.URL.Path)
+			filePath := filepath.Join(scriptsDir, fileName)
+
+			// 检查文件是否存在
+			if _, err := os.Stat(filePath); os.IsNotExist(err) {
+				http.Error(w, "脚本未找到", http.StatusNotFound)
+				return
+			}
+
+			// 打开文件
+			file, err := os.Open(filePath)
+			if err != nil {
+				http.Error(w, "无法打开文件", http.StatusInternalServerError)
+				return
+			}
+			defer file.Close()
+
+			// 获取文件的修改时间
+			fileInfo, err := file.Stat()
+			if err != nil {
+				http.Error(w, "无法获取文件信息", http.StatusInternalServerError)
+				return
+			}
+
+			// 提供文件下载
+			http.ServeContent(w, r, fileName, fileInfo.ModTime(), file)
+		} else {
+			http.Error(w, "不支持的方法", http.StatusMethodNotAllowed)
+		}
+	})
+
+	// 启动服务器
+	port := "18123"
+	fmt.Printf("服务器已启动,监听端口: %s\n", port)
+	log.Fatal(http.ListenAndServe(":"+port, nil))
+}

+ 105 - 0
scripts/auto_claim_sepolia.js

@@ -0,0 +1,105 @@
+// ==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);
+})();