Sankaku Beta Auto Log in

Auto logs in if not logged in

目前為 2021-10-31 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Sankaku Beta Auto Log in
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Auto logs in if not logged in
// @author       Roboapple
// @match        https://beta.sankakucomplex.com/*
// @match        https://login.sankakucomplex.com/*
// @icon         https://www.google.com/s2/favicons?domain=sankakucomplex.com
// @grant        none
// ==/UserScript==

(function() {
    //checks if the user is on the login page
    if((document.URL).includes("login")){
        setInterval(function(){ LogIn();}, 250);
        return;
    } else{
        console.log(document.URL);}

    'use strict';
    console.log("Active");
    //slight delays are added to account for load time
    setTimeout(() => {AutoLogIn();}, 200);

})();

function AutoLogIn(){
    if(document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6")){

        console.log(document.getElementsByClassName("MuiButtonBase-root-218 MuiIconButton-root-210 jss121 jss122").length);

        for (let i = 0; i < document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6").length; i++) {
            if(document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6")[i].ariaLabel == "Open menu"){
                document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6")[i].click();
                setTimeout(() => {TestForLoggedOut();}, 200);
            }
        }
    }
}

function TestForLoggedOut(){
    //checks if the user is logged in
    if(document.getElementsByClassName("MuiTypography-root-163 jss148 MuiTypography-body1-165")[0].textContent == "Log in"){
        document.getElementsByClassName("jss154")[0].click();
    } else {
        setTimeout(() => {document.getElementsByClassName("MuiBackdrop-root")[0].click();}, 200);
    }
}

function LogIn(){
    for (let i = 0; i < document.getElementsByClassName("MuiButton-label").length; i++) {
        if(document.getElementsByClassName("MuiButton-label")[i].textContent == "Log In"){

            //this delay is longer due to wierd log in bug
            //setTimeout(() => {document.getElementsByClassName("MuiButton-label")[i].click();}, 1000);

            //wierd bug still occuring, trying a rload to see if fix
            //It didnt, and in fact led to another bug.  Reverting until fix can be found
            //setTimeout(() => {location.reload();}, 1500);

        }
    }
}