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!

当前为 2022-04-13 提交的版本,查看 最新版本

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