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!

当前为 2021-04-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MALFunction - "Fix" ERRORS on MAL + Text AutoSaver
  3. // @namespace MALFunction
  4. // @version 1.0.9
  5. // @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!
  6. // @author hacker
  7. // @match https://myanimelist.net/*
  8. // @icon https://www.google.com/s2/favicons?domain=myanimelist.net
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. if ((document.querySelector("body").innerHTML.length < 3100 && document.body.innerText.search('Please click "Submit" to verify that you are not a bot.') === -1) || (document.title.match(/500 Internal Server Error|504 Gateway Time-out|ERROR: The request could not be satisfied/) !== null)) {
  17. location.reload(); //Reloads the page
  18. } //Finishes the if condition
  19.  
  20. if (document.title.match('400 Bad Request') !== null || document.body.innerText.search('400 Invalid recaptcha') > -1) {
  21. window.history.back(); //Go Back
  22. } //Finishes the if condition
  23.  
  24. if (document.body.innerText.search('Please click "Submit" to verify that you are not a bot.') > -1) {
  25. setTimeout(function() { //Starts the setTimeout function when the "website finishes loading"
  26. document.querySelector("#reform").requestSubmit(); //Auto "click on the submit button"
  27. }, 0); //Finishes the setTimeout function
  28.  
  29. setTimeout(function() { //Starts the setTimeout function after 20 secs, and reload the page to see if we are already able to use MAL or if we need to resubmit again
  30. location.reload(); //Reloads the page
  31. }, 20000); //Finishes the setTimeout function
  32. } //Finishes the if condition
  33.  
  34. var SpanElements = document.querySelectorAll("span"); //Get all span elements on the page
  35. for (var i = SpanElements.length; i--;) { //For every single span element
  36. if (SpanElements[i].style.fontSize !== undefined) { //Check if the element has the font-size css attribute
  37. 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%
  38. SpanElements[i].style.fontSize = '1000%'; //Change the span element font-size css attribute to be only 1000%
  39. } //Finishes the if condition
  40. } //Finishes the if condition
  41. } //Finishes the for condition
  42.  
  43. if (location.href.match('https://myanimelist.net/profile/') !== null || location.href.match('comtocom.php') !== null) //If the url is an profile or comments page
  44. { //Starts the if condition
  45. var ProfileComments = document.querySelectorAll('div[id*="comtext"]'); //Get all span elements on the page
  46. for (i = ProfileComments.length; i--;) { //For every single span element
  47. ProfileComments[i].setAttribute('style', 'overflow:hidden !important;');
  48. } //Finishes the for condition
  49. } //Finishes the if condition
  50.  
  51. if (location.href.match('login.php') === null) //If the url ISN'T the mal login page
  52. { //Starts the if condition
  53. document.body.onkeyup = function() { //Detects when the user is writing on the page
  54. var FocusedElementText = document.activeElement.value; //Save the actual focused element to a variable
  55. if (FocusedElementText !== '' && FocusedElementText !== undefined) //If the focused element contains text and is not = undefined
  56. { //Starts the if condition
  57. GM_setValue("Recovered text", FocusedElementText); //Save the text that is being written
  58. } //Finishes the if condition
  59. }; //Finishes the onkeypress advent listener
  60.  
  61. window.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
  62. 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
  63. document.activeElement.value = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
  64. e.preventDefault(); //Prevent the default middle button action from executing
  65. } //Finishes the if condition
  66. }); //Finishes the mousedown advent listener
  67. } //Finishes the if condition
  68. })();