LinuxDo Connect Auto-Click

Automatically clicks the "允许" (Allow) button on LinuxDo OAuth authorization pages

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         LinuxDo Connect Auto-Click
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Automatically clicks the "允许" (Allow) button on LinuxDo OAuth authorization pages
// @author       neo
// @match        https://connect.linux.do/oauth2/authorize*
// @grant        none
// @run-at       document-end
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    console.log('[LinuxDo Auto-Click] Script loaded');

    // Function to find and click the approve button
    function clickApproveButton() {
        // Try multiple selectors to ensure we find the button
        const selectors = [
            'a.bg-red-500.hover\\:bg-red-600.text-white.font-bold.py-3.px-5.rounded',
            'body > div:nth-child(3) > a.bg-red-500',
            'a[href*="/oauth2/approve/"]'
        ];

        for (const selector of selectors) {
            const button = document.querySelector(selector);

            if (button && button.textContent.includes('允许')) {
                console.log('[LinuxDo Auto-Click] Found approve button:', button);

                // Add a small delay to ensure page is fully rendered
                setTimeout(() => {
                    button.click();
                    console.log('[LinuxDo Auto-Click] Clicked approve button');
                }, 100);

                return true;
            }
        }

        console.log('[LinuxDo Auto-Click] Approve button not found');
        return false;
    }

    // Try to click immediately
    if (!clickApproveButton()) {
        // If not found, wait for DOM changes
        const observer = new MutationObserver((mutations, obs) => {
            if (clickApproveButton()) {
                obs.disconnect();
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });

        // Stop observing after 5 seconds
        setTimeout(() => {
            observer.disconnect();
            console.log('[LinuxDo Auto-Click] Stopped observing after timeout');
        }, 5000);
    }
})();