NitroMath Login Automation

Automate NitroMath login actions using Google Login. Works well with NitroMath Bot.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         NitroMath Login Automation
// @namespace    https://singdev.wixsite.com/sing-developments/
// @version      12.0
// @description  Automate NitroMath login actions using Google Login. Works well with NitroMath Bot.
// @author       Sing Developments
// @match        https://www.nitromath.com/*
// @grant        none
// ==/UserScript==

(function() {
    // Function to check the current URL and perform actions accordingly
    function checkURL() {
        if (window.location.href.includes('https://www.nitromath.com/login')) {
            // Redirect to the Google Login page.
            window.location.href = 'https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?client_id=530728710703.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fwww.nitromath.com%2Foauth%3Ftype%3Dgoogle&scope=openid%20profile%20email&response_type=code&service=lso&o2v=1&theme=glif&flowName=GeneralOAuthFlow';
            console.log('Logging In.');
            // Wait until the login page loads again
            var loginInterval = setInterval(function() {
                if (window.location.href.includes('https://www.nitromath.com/login')) {
                    clearInterval(loginInterval); // Stop checking
                    // Redirect to the Google Login page again
                    window.location.href = 'https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?client_id=530728710703.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fwww.nitromath.com%2Foauth%3Ftype%3Dgoogle&scope=openid%20profile%20email&response_type=code&service=lso&o2v=1&theme=glif&flowName=GeneralOAuthFlow';
                    console.log('Logging In Again.');
                }
            }, 1000); // Check every second
        } else if (window.location.href.includes('https://www.nitromath.com/garage')) {
            // If on the garage page, redirect to the race page.
            window.location.href = 'https://www.nitromath.com/play';
            console.log('Going to race from garage.');
        }
    }

    // Repeat the loop every 2 seconds
    setInterval(checkURL, 2000);
})();