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!

当前为 2023-04-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MALFunction - "Fix" ERRORS on MAL + Text AutoSaver
  3. // @namespace MALFunction
  4. // @version 33
  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. // @match https://myanimelist.net/*
  8. // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. // the text "ㅤㅤ" contains the right to left mark use to bypass mal character counter
  15. (function() {
  16. 'use strict';
  17. 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)) {
  18. location.reload(); //Reloads the page
  19. } //Finishes the if condition
  20.  
  21. 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] !== '') {
  22. window.history.back(); //Go Back
  23. } //Finishes the if condition
  24.  
  25. if (document.querySelector("div.display-verify") !== null) { //If the verify screen is shown
  26. setTimeout(function() { //Starts the setTimeout function when the "website finishes loading"
  27. document.querySelector("#reform").requestSubmit(); //Auto "click on the submit button"
  28. }, 0); //Finishes the setTimeout function
  29.  
  30. 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
  31. location.reload(); //Reloads the page
  32. }, 20000); //Finishes the setTimeout function
  33. } //Finishes the if condition
  34.  
  35. var SpanElements = document.querySelectorAll("span"); //Get all span elements on the page
  36. for (var i = SpanElements.length; i--;) { //For every single span element
  37. if (SpanElements[i].style.fontSize !== undefined) { //Check if the element has the font-size css attribute
  38. 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%
  39. SpanElements[i].style.fontSize = '1000%'; //Change the span element font-size css attribute to be only 1000%
  40. } //Finishes the if condition
  41. } //Finishes the if condition
  42. } //Finishes the for condition
  43.  
  44. if (location.href.match('https://myanimelist.net/profile/') !== null || location.href.match('comtocom.php') !== null) //If the url is an profile or comments page
  45. { //Starts the if condition
  46. var ProfileComments = document.querySelectorAll('div[id*="comtext"]'); //Get all span elements on the page
  47. for (i = ProfileComments.length; i--;) { //For every single span element
  48. ProfileComments[i].setAttribute('style', 'overflow:hidden !important;');
  49. } //Finishes the for condition
  50. } //Finishes the if condition
  51.  
  52. if (location.href.match('login.php') === null) //If the url ISN'T the mal login page
  53. { //Starts the if condition
  54. setTimeout(() => { //Starts the setTimeout function
  55. if (document.querySelector(".sceditor-toolbar") !== null) //If the user is anywhere that has the MAL BBCode editor ToolBar (forum topic or PM pages)
  56. { //Starts the if condition
  57. document.querySelectorAll(".sceditor-toolbar").forEach(function(el) { //For the top and bottom New reply text boxes on forum topics
  58. el.nextSibling.contentWindow.document.body.onkeyup = function() { //Detects when the user is writing on the page
  59. if (this.innerText !== '\n' && this.innerText !== undefined && document.activeElement.outerHTML.match(/"inputtext js-advancedSearchText"|"inputtext fl-l"/) === null) //If the focused element contains text and is not = undefined, and isn't the search bar
  60. { //Starts the if condition
  61. GM_setValue("Recovered text", this.innerText); //Save the text that is being written
  62. } //Finishes the if condition
  63. } //Finishes the onkeypress advent listener
  64.  
  65. el.nextSibling.contentWindow.document.body.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
  66. if (e.button === 1) { //Starts the if condition If the middle mouse button was clicked and the focused element is not = undefined
  67. this.innerText = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
  68. e.preventDefault(); //Prevent the default middle button action from executing
  69. } //Finishes the if condition
  70. }); //Finishes the mousedown advent listener
  71. }) //Finishes the ForEach loop
  72. } //Finishes the if condition
  73. }, 1500); //Finishes the setTimeout function
  74.  
  75. document.body.onkeyup = function() { //Detects when the user is writing on the page
  76. if (document.activeElement.value !== '' && document.activeElement.value !== undefined && document.activeElement.outerHTML.match(/"inputtext js-advancedSearchText"|"inputtext fl-l"|"autocomplete-input"/) === null) //If the focused element contains text and is not = undefined, and isn't the search bar or the Mentioner script search bar
  77. { //Starts the if condition
  78. GM_setValue("Recovered text", document.activeElement.value); //Save the text that is being written
  79. } //Finishes the if condition
  80. }; //Finishes the onkeypress advent listener
  81.  
  82. window.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
  83. 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
  84. document.activeElement.value = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
  85. e.preventDefault(); //Prevent the default middle button action from executing
  86. } //Finishes the if condition
  87. }); //Finishes the mousedown advent listener
  88. } //Finishes the if condition
  89. })();