MALFunction - "Fix" ERRORS on MAL + Text AutoSaver

When MAL bugs showing ERROR messages or is blank and doesn't load the script reloads the page until MAL is successfully loaded... The script also AutoSaves any text that you are writing on MAL so that you will never again lose an UnSubmitted text!

// ==UserScript==
// @name         MALFunction - "Fix" ERRORS on MAL + Text AutoSaver
// @namespace    MALFunction
// @version      1.0.7
// @description  When MAL bugs showing ERROR messages or is blank and doesn't load the script reloads the page until MAL is successfully loaded... The script also AutoSaves any text that you are writing on MAL so that you will never again lose an UnSubmitted text!
// @author       hacker
// @match        https://myanimelist.net/*
// @icon         https://www.google.com/s2/favicons?domain=myanimelist.net
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-end
// ==/UserScript==
(function() {
  'use strict';
  if ((document.querySelector("body").innerHTML.length < 3100 && document.body.innerText.search('Please click "Submit" to verify that you are not a bot.') === -1) || (document.querySelector("title").innerText === "500 Internal Server Error" || document.querySelector("title").innerText === "504 Gateway Time-out" || document.querySelector("title").innerText === "ERROR: The request could not be satisfied")) {
    location.reload(); //Reloads the page
  } //Finishes the if condition

  if (document.body.innerText.search('Please click "Submit" to verify that you are not a bot.') > -1) {
    setTimeout(function() { //Starts the setTimeout function when the "website finishes loading"
      document.querySelector("#reform").requestSubmit(); //Auto "click on the submit button"
    }, 0); //Finishes the setTimeout function

    setTimeout(function() { //Starts the setTimeout function after 15 secs, and reload the page to see if we are already able to use MAL or if we need to resubmit again
      location.reload(); //Reloads the page
    }, 15000); //Finishes the setTimeout function
  } //Finishes the if condition

  var SpanElements = document.querySelectorAll("span"); //Get all span elements on the page
  for (var i = SpanElements.length; i--;) { //For every single span element
    if (SpanElements[i].style.fontSize !== undefined) { //Check if the element has the font-size css attribute
      if (parseInt(SpanElements[i].style.fontSize) > 1000) { //If the element has the font-size css attribute and the font-size css value is bigger than 1000%
        SpanElements[i].style.fontSize = '1000%'; //Change the span element font-size css attribute to be only 1000%
      } //Finishes the if condition
    } //Finishes the if condition
  } //Finishes the for condition

  if (location.href.match('https://myanimelist.net/profile/') !== null || location.href.match('comtocom.php') !== null) //If the url is an profile or comments page
  { //Starts the if condition
    var ProfileComments = document.querySelectorAll('div[id*="comtext"]'); //Get all span elements on the page
    for (i = ProfileComments.length; i--;) { //For every single span element
      ProfileComments[i].setAttribute('style', 'overflow:hidden !important;');
    } //Finishes the for condition
  } //Finishes the if condition

  if (location.href.match('login.php') === null) //If the url ISN'T the mal login page
  { //Starts the if condition
    document.body.onkeyup = function() { //Detects when the user is writing on the page
      var FocusedElementText = document.activeElement.value; //Save the actual focused element to a variable
      if (FocusedElementText !== '' && FocusedElementText !== undefined) //If the focused element contains text and is not = undefined
      { //Starts the if condition
        GM_setValue("Recovered text", FocusedElementText); //Save the text that is being written
      } //Finishes the if condition
    }; //Finishes the onkeypress advent listener

    window.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
      if (e.button === 1 && document.activeElement.value !== undefined) { //Starts the if condition If the middle mouse button was clicked and the focused element is not = undefined
        document.activeElement.value = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
        e.preventDefault(); //Prevent the default middle button action from executing
      } //Finishes the if condition
    }); //Finishes the mousedown advent listener
  } //Finishes the if condition
})();