Chatgpt login button clicker

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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');