Sankaku Beta Auto Log in

Auto logs in if not logged in

ของเมื่อวันที่ 31-08-2021 ดู เวอร์ชันล่าสุด

  1. // ==UserScript==
  2. // @name Sankaku Beta Auto Log in
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description Auto logs in if not logged in
  6. // @author Roboapple
  7. // @match https://beta.sankakucomplex.com/*
  8. // @match https://login.sankakucomplex.com/*
  9. // @icon https://www.google.com/s2/favicons?domain=sankakucomplex.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. //checks if the user is on the login page
  15. if((document.URL).includes("login")){
  16. setInterval(function(){ LogIn();}, 250);
  17. return;
  18. } else{
  19. console.log(document.URL);}
  20.  
  21. 'use strict';
  22. console.log("Active");
  23. //slight delays are added to account for load time
  24. setTimeout(() => {AutoLogIn();}, 200);
  25.  
  26. })();
  27.  
  28. function AutoLogIn(){
  29. if(document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6")){
  30.  
  31. console.log(document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6").length);
  32.  
  33. for (let i = 0; i < document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6").length; i++) {
  34. if(document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6")[i].ariaLabel == "Open menu"){
  35. document.getElementsByClassName("MuiButtonBase-root-102 MuiIconButton-root-94 jss5 jss6")[i].click();
  36. setTimeout(() => {TestForLoggedOut();}, 200);
  37. }
  38. }
  39. }
  40. }
  41.  
  42. function TestForLoggedOut(){
  43. //checks if the user is logged in
  44. if(document.getElementsByClassName("MuiTypography-root-163 jss148 MuiTypography-body1-165")[0].textContent == "Log in"){
  45. document.getElementsByClassName("jss154")[0].click();
  46. } else {
  47. setTimeout(() => {document.getElementsByClassName("MuiBackdrop-root")[0].click();}, 200);
  48. }
  49. }
  50.  
  51. function LogIn(){
  52. for (let i = 0; i < document.getElementsByClassName("MuiButton-label").length; i++) {
  53. if(document.getElementsByClassName("MuiButton-label")[i].textContent == "Log In"){
  54.  
  55. //this delay is longer due to wierd log in bug
  56. setTimeout(() => {document.getElementsByClassName("MuiButton-label")[i].click();}, 1000);
  57.  
  58. //wierd bug still occuring, trying a rload to see if fix
  59. setTimeout(() => {location.reload();}, 1500);
  60.  
  61. }
  62. }
  63. }