|
立刻注册账号,享受更清爽的界面!
您需要 登录 才可以下载或查看,没有账号?注册
×
不知道为啥我一直44,在想道是不是卡的问题,我用的infini ,号也是是五六年的老号,经常用,等夜晚试试换bybit看看
隔壁论坛的大佬说是玄学,有的人infini成功了的。gcp分为aistudio和vertexai,其中aistudio是大部分人使用的
看样子是共用300美金,总共是1000赠金的vertexai和300的初始送的,我是看别的佬友帖子图片显示的
- // ==UserScript==
- // [url=home.php?mod=space&uid=4014]@name[/url] Google Cloud 注册流程自动化
- // @namespace http://tampermonkey.net/
- // @version 2.0
- // @description 自动点击"同意並繼續",然后"免費試用",如果出现"確定"则刷新重试。
- // @author Your Name
- // @match https://console.cloud.google.com/freetrial/signup/*
- // @grant GM_setValue
- // @grant GM_getValue
- // @run-at document-idle
- // ==/UserScript==
- (function() {
- 'use strict';
- // --- 配置 ---
- const XPATH_BUTTON_AGREE = "//button[.//span[normalize-space(.)='同意並繼續']]"; // 第一个按钮
- const XPATH_BUTTON_FREE_TRIAL = "//button[.//span[normalize-space(.)='免費試用']]"; // 第二个按钮
- const XPATH_BUTTON_CONFIRM = "//button[.//span[normalize-space(.)='確定']]"; // 第三个按钮 (检查用)
- const WAIT_TIMEOUT_MS = 30000; // 等待按钮出现的最大时间 (毫秒, 30秒)
- const POST_CLICK_DELAY_MIN_MS = 1000; // 点击后等待的最小时间 (毫秒)
- const POST_CLICK_DELAY_MAX_MS = 2000; // 点击后等待的最大时间 (毫秒)
- const CONFIRM_CHECK_TIMEOUT_MS = 5000; // 点击免费试用后,检查确定按钮出现的时间窗口 (毫秒, 5秒)
- // 使用 GM_* 函数来持久化运行状态,以便刷新后能自动重启
- const STORAGE_KEY_RUNNING = 'googleCloudAutoClickerRunning';
- let isRunning = false; // 当前脚本是否激活运行
- let controlButton = null; // 控制按钮的引用
- // --- 帮助函数 ---
- function log(message) {
- console.log(`[AutoClicker] ${message}`);
- }
- function logWarn(message) {
- console.warn(`[AutoClicker] ${message}`);
- }
- function logError(message) {
- console.error(`[AutoClicker] ${message}`);
- }
- // 等待函数
- function wait(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- // 获取随机延迟
- function getRandomDelay(min = POST_CLICK_DELAY_MIN_MS, max = POST_CLICK_DELAY_MAX_MS) {
- return Math.random() * (max - min) + min;
- }
- // 查找元素,带超时和可见性检查
- async function findElement(xpath, timeout = WAIT_TIMEOUT_MS) {
- log(`查找元素 (超时 ${timeout / 1000}s): ${xpath}`);
- const startTime = Date.now();
- while (Date.now() - startTime < timeout) {
- if (!isRunning) return null; // 如果中途停止了,返回 null
- try {
- const result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
- const element = result.singleNodeValue;
- // 检查元素是否存在且可见 (offsetParent !== null 是一个常用但不完美的检查)
- if (element && element.offsetParent !== null) {
- log(`元素找到: ${xpath}`);
- return element;
- }
- } catch (error) {
- logError(`查找元素时 XPath 出错: ${xpath} - ${error}`);
- return null; // XPath 错误,停止查找
- }
- await wait(250); // 每 250ms 检查一次
- }
- logWarn(`查找元素超时 (${timeout / 1000}s): ${xpath}`);
- return null; // 超时未找到
- }
- // 仅检查元素是否存在,不长时间等待
- function checkElementExists(xpath) {
- try {
- const result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
- return result.singleNodeValue !== null;
- } catch (error) {
- logError(`检查元素存在性时 XPath 出错: ${xpath} - ${error}`);
- return false;
- }
- }
- // 安全点击元素 (包括尝试 JS 点击)
- function clickElement(element, elementName) {
- try {
- log(`尝试点击 '${elementName}'...`);
- element.click();
- log(`'${elementName}' 点击成功。`);
- return true;
- } catch (e) {
- logError(`点击 '${elementName}' 时出错: ${e}`);
- logWarn(`尝试使用 JS 点击 '${elementName}'...`);
- try {
- element.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
- log(`'${elementName}' JS 点击成功。`);
- return true;
- } catch (jsE) {
- logError(`JS 点击 '${elementName}' 也失败: ${jsE}`);
- return false;
- }
- }
- }
- // 刷新页面
- function refreshPage() {
- log("准备刷新页面...");
- if (isRunning) { // 只有在脚本激活状态下才执行刷新
- log("正在刷新...");
- // 在刷新前确保状态已保存为 true (如果 stopLoop 没有被意外调用)
- GM_setValue(STORAGE_KEY_RUNNING, true);
- setTimeout(() => window.location.reload(), 500); // 短暂延迟后刷新
- } else {
- logWarn("脚本已停止,取消刷新。");
- }
- }
- // --- 主要工作流程 ---
- async function mainWorkflow() {
- if (!isRunning) return;
- log("=== 开始新流程 ===");
- // --- 步骤 1: 点击 "同意並繼續" ---
- const buttonAgree = await findElement(XPATH_BUTTON_AGREE);
- if (!buttonAgree) {
- logError("找不到 '同意並繼續' 按钮。可能是页面结构变化或未加载。停止流程。");
- stopLoop(); // 停止,不刷新,让用户检查
- alert("自动点击器:找不到 '同意並繼續' 按钮,脚本已停止。");
- return;
- }
- if (!clickElement(buttonAgree, "同意並繼續")) {
- logError("点击 '同意並繼續' 失败。停止流程。");
- stopLoop();
- alert("自动点击器:点击 '同意並繼續' 失败,脚本已停止。");
- return;
- }
- // --- 步骤 2: 等待并点击 "免費試用" ---
- const buttonFreeTrial = await findElement(XPATH_BUTTON_FREE_TRIAL);
- if (!buttonFreeTrial) {
- logError(`'免費試用' 按钮未在 ${WAIT_TIMEOUT_MS / 1000} 秒内出现。刷新页面重试...`);
- refreshPage(); // 未找到则刷新重试
- return;
- }
- if (!clickElement(buttonFreeTrial, "免費試用")) {
- logError("点击 '免費試用' 失败。刷新页面重试...");
- refreshPage(); // 点击失败也刷新重试
- return;
- }
- // --- 步骤 3: 点击后等待 1-2 秒 ---
- const delay = getRandomDelay();
- log(`等待 ${delay.toFixed(0)} 毫秒...`);
- await wait(delay);
- if (!isRunning) return; // 检查是否在等待期间被停止
- // --- 步骤 4: 检查 "確定" 按钮是否在短时间内出现 ---
- log(`检查 '確定' 按钮是否在 ${CONFIRM_CHECK_TIMEOUT_MS / 1000} 秒内出现...`);
- let confirmButtonFound = false;
- const checkStartTime = Date.now();
- while (Date.now() - checkStartTime < CONFIRM_CHECK_TIMEOUT_MS) {
- if (!isRunning) return; // 检查是否在等待期间被停止
- if (checkElementExists(XPATH_BUTTON_CONFIRM)) {
- log("'確定' 按钮已找到!符合预期,准备刷新页面重新开始。");
- confirmButtonFound = true;
- break;
- }
- await wait(200); // 短暂等待再次检查
- }
- // --- 步骤 5: 根据是否找到 "確定" 按钮决定操作 ---
- if (confirmButtonFound) {
- // 如果找到了 "確定",说明流程按预期进行到了需要刷新的步骤
- refreshPage();
- } else {
- // 如果在检查时间内 *没有* 找到 "確定" 按钮
- logWarn(`在 ${CONFIRM_CHECK_TIMEOUT_MS / 1000} 秒内未检测到 '確定' 按钮。这可能意味着流程卡住或有变化。将刷新页面重试。`);
- // 即使没找到,也按你的要求刷新重试
- refreshPage();
- }
- }
- // --- 控制逻辑 ---
- function startLoop() {
- if (isRunning) {
- log("流程已经在运行中。");
- return;
- }
- log("=== 启动自动流程 ===");
- isRunning = true;
- GM_setValue(STORAGE_KEY_RUNNING, true); // 保存状态
- if (controlButton) {
- controlButton.textContent = '停止流程 (运行中)';
- controlButton.style.backgroundColor = '#dc3545';
- }
- mainWorkflow(); // 启动流程
- }
- function stopLoop() {
- if (!isRunning && GM_getValue(STORAGE_KEY_RUNNING, false) === false) {
- log("流程并未运行。");
- return; // 如果已经是停止状态,则不执行任何操作
- }
- log("=== 停止自动流程 ===");
- isRunning = false;
- GM_setValue(STORAGE_KEY_RUNNING, false); // 保存状态
- if (controlButton) {
- controlButton.textContent = '开始自动流程';
- controlButton.style.backgroundColor = '#28a745';
- }
- // 不需要清除延时,因为 async 函数中的 await 会在 isRunning 变为 false 时自然退出循环
- }
- // --- 创建控制按钮 ---
- function createControlButton() {
- if (document.getElementById('autoClickerControlButton')) return; // 防止重复创建
- controlButton = document.createElement('button');
- controlButton.id = 'autoClickerControlButton';
- controlButton.style.position = 'fixed';
- controlButton.style.bottom = '20px';
- controlButton.style.right = '20px';
- controlButton.style.zIndex = '9999';
- controlButton.style.padding = '10px 15px';
- controlButton.style.color = 'white';
- controlButton.style.border = 'none';
- controlButton.style.borderRadius = '5px';
- controlButton.style.cursor = 'pointer';
- controlButton.style.fontSize = '14px';
- controlButton.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
- // 初始化按钮状态
- if (GM_getValue(STORAGE_KEY_RUNNING, false)) {
- controlButton.textContent = '停止流程 (运行中)';
- controlButton.style.backgroundColor = '#dc3545';
- } else {
- controlButton.textContent = '开始自动流程';
- controlButton.style.backgroundColor = '#28a745';
- }
- controlButton.addEventListener('click', () => {
- // 读取当前存储的状态,以防万一 isRunning 变量状态不一致
- if (GM_getValue(STORAGE_KEY_RUNNING, false)) {
- stopLoop();
- } else {
- startLoop();
- }
- });
- document.body.appendChild(controlButton);
- log("控制按钮已创建。");
- }
- // --- 脚本入口 ---
- log("脚本加载。");
- createControlButton(); // 创建按钮
- // 检查是否应该在页面加载后自动启动
- if (GM_getValue(STORAGE_KEY_RUNNING, false)) {
- log("检测到上次运行时脚本处于激活状态,自动启动流程。");
- startLoop();
- } else {
- log("脚本当前处于停止状态。请点击按钮启动。");
- }
- })();
复制代码 |
|