// ==UserScript== // @name New Userscript VHOO-3 // @namespace https://docs.scriptcat.org/ // @version 0.1.0 // @description try to take over the world! // @author You // @match 输入校园网网址 // @grant none // @noframes // ==/UserScript== (function() { 'use strict'; // Your code here... })();// ==UserScript== // @name New Userscript VHOO-3 // @namespace https://docs.scriptcat.org/ // @version 0.1.0 // @description try to take over the world! // @author You // @match 输入校园网网址 // @grant none // @noframes // ==/UserScript== (function() { 'use strict'; // ================= 配置区 ================= const CONFIG = { username: "账号", // 账号 password: "密码", // 密码 maxRetry: 3, // 33 retryDelay: 2000 // 2000 }; // =========================================== // 1. 自动填充并点击的函数 function doLogin() { console.log("⏳ 正在尝试登录..."); // 填充账号 (通常第一个文本框) let userInputs = document.querySelectorAll('input[type="text"], input[type="tel"]'); if(userInputs.length > 0) { userInputs[0].value = CONFIG.username; // 触发一下输入事件,防止网站检测不到 userInputs[0].dispatchEvent(new Event('input', { bubbles: true })); } // 填充密码 let passInputs = document.querySelectorAll('input[type="password"]'); if(passInputs.length > 0) { passInputs[0].value = CONFIG.password; passInputs[0].dispatchEvent(new Event('input', { bubbles: true })); } // 点击登录按钮 let btn = Array.from(document.querySelectorAll('button, input[type="button"], span')).find(el => el.innerText.trim() === '登录' || el.value === '登录' ); if (btn) { btn.click(); console.log("✅ 已点击登录按钮"); return true; } else { console.log("❌ 未找到登录按钮"); return false; } } // 2. 检测是否已经登录成功 function checkStatus() { // 简单的判断逻辑:如果页面上有“下线”或者“余额”等字眼,说明已经登录了 // 或者检测页面是否跳转了 if (document.body.innerText.includes("下线") || document.body.innerText.includes("余额")) { console.log("🎉 已经登录过了,无需操作"); return true; } return false; } // 3. 主程序 function main() { if (checkStatus()) return; // 如果已登录,直接结束 let success = doLogin(); // 如果点击失败,或者点击后没反应,尝试重试 if (!success) { let count = 0; let timer = setInterval(() => { count++; console.log(`🔄 第 ${count} 次重试...`); if (doLogin() || count >= CONFIG.maxRetry) { clearInterval(timer); } }, CONFIG.retryDelay); } } // 页面加载完成后执行 window.addEventListener('load', main); })();