🏆 LINUX DO OAuth 自动点击 - 极简版

🎯 专为LINUX DO OAuth设计的自动点击助手 - 极简版

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         🏆 LINUX DO OAuth 自动点击 - 极简版
// @namespace    https://github.com/TechnologyStar/linuxdo-oauth-helper
// @version      1.0.0
// @description  🎯 专为LINUX DO OAuth设计的自动点击助手 - 极简版
// @author       Premium UI Designer
// @match        https://connect.linux.do/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 配置
    const CONFIG = {
        selectors: {
            approveButton: 'a.bg-red-500[href*="/oauth2/approve/"]'
        },
        autoClickDelay: 0 // 0秒延迟
    };

    // 日志工具
    function log(message) {
        console.log(`%c[OAuth自动点击] ${message}`, 'color: #10B981', new Date().toLocaleTimeString());
    }

    // 自动点击管理器
    class AutoClickManager {
        constructor() {
            this.hasClicked = false;
            log('自动点击管理器启动');
            this.init();
        }

        init() {
            setTimeout(() => {
                this.attemptAutoClick();
            }, CONFIG.autoClickDelay);
        }

        attemptAutoClick() {
            if (this.hasClicked) return;

            const approveButton = document.querySelector(CONFIG.selectors.approveButton);
            if (!approveButton) {
                log('未找到授权按钮');
                return;
            }

            log('找到授权按钮,准备自动点击');
            this.hasClicked = true;

            setTimeout(() => {
                log(`正在跳转到: ${approveButton.href}`);
                window.location.href = approveButton.href;
            }, 300);
        }
    }

    // 启动脚本
    function startScript() {
        log('OAuth自动点击助手启动');

        // 只在OAuth页面激活
        if (!window.location.pathname.includes('/oauth2/')) {
            log('当前不是OAuth页面,脚本待机');
            return;
        }

        log('检测到OAuth页面,启动自动点击功能');

        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', () => new AutoClickManager());
        } else {
            new AutoClickManager();
        }
    }

    startScript();
})();