Chatgpt login button clicker

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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');