Sankaku Beta Auto Log in

Auto logs in if not logged in

2021-08-19 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         Sankaku Beta Auto Log in
// @namespace    http://tampermonkey.net/
// @version      1.2.1
// @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")){
        LogIn();
        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-102 MuiIconButton-root-94 jss5 jss6").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 {
        for (let i = 0; i < document.getElementsByClassName("MuiTypography-root-163 MuiListItemText-primary-210 MuiTypography-body1-165 MuiTypography-displayBlock-192").length; i++) {
            if(document.getElementsByClassName("MuiTypography-root-163 MuiListItemText-primary-210 MuiTypography-body1-165 MuiTypography-displayBlock-192")[i].textContent == "Browse posts"){
                setTimeout(() => {document.getElementsByClassName("MuiTypography-root-163 MuiListItemText-primary-210 MuiTypography-body1-165 MuiTypography-displayBlock-192")[i].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();}, 1200);
        }
    }
}