Chatgpt login button clicker

Refreshes the Chatgpt page until the login button appears, then clicks the button to log in automatically

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Chatgpt login button clicker
// @namespace    chatgpt-login-clicker
// @version      1
// @description  Refreshes the Chatgpt page until the login button appears, then clicks the button to log in automatically
// @match        https://chat.openai.com/auth/*
// @grant        none
// ==/UserScript==

// Set the maximum number of refresh attempts
var maxRefreshAttempts = 10;

// Set the minimum and maximum time intervals between refreshes in milliseconds
var minRefreshInterval = 500;
var maxRefreshInterval = 1500;

// Track the number of refresh attempts
var refreshAttempts = 0;

// Define a function to refresh the page
var refreshPage = function() {
    location.reload();
};

// Define a function to check for the login button
var checkForLoginButton = function() {
    var loginButtons = document.querySelectorAll('.btn.relative.btn-primary');
    var loginButton = Array.from(loginButtons).find(btn => btn.innerHTML.includes('Log in'));
    if (loginButton) {
        // Login button is visible, click it and stop refreshing
        loginButton.click();
        clearInterval(refreshIntervalId);
        console.log('Login button is visible, stopping refresh');
    } else {
        refreshAttempts++;
        if (refreshAttempts >= maxRefreshAttempts) {
            // Maximum refresh attempts reached, stop refreshing
            clearInterval(refreshIntervalId);
            console.log('Maximum refresh attempts reached, stopping refresh');
        } else {
            console.log('Login button not visible, refreshing page');
            var refreshInterval = Math.floor(Math.random() * (maxRefreshInterval - minRefreshInterval + 1) + minRefreshInterval);
            setTimeout(refreshPage, refreshInterval);
        }
    }
};

// Start the page refresh loop and store the interval ID in a variable
var refreshIntervalId = setInterval(checkForLoginButton, minRefreshInterval);

console.log('Chtgpt login clicker script loaded');