MALFunction - "Fix" ERRORS on MAL + Text AutoSaver

When MAL bugs showing ERROR messages or is blank and don'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!

התקן את הסקריפט?
סקריפטים מומלצים של יוצר זה

אולי תאהב גם את Better Buttons To Edit Anime/Manga Information.

התקן את הסקריפט
  1. // ==UserScript==
  2. // @name MALFunction - "Fix" ERRORS on MAL + Text AutoSaver
  3. // @namespace MALFunction
  4. // @version 34
  5. // @description When MAL bugs showing ERROR messages or is blank and don'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 used to bypass the mal character counter
  15. (function() {
  16. 'use strict';
  17. setTimeout(() => { //Starts the setTimeout function
  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. }, 500); //Finishes the setTimeout function
  22.  
  23. 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] !== '') {
  24. history.back(); //Go Back
  25. } //Finishes the if condition
  26.  
  27. setTimeout(function() { //Starts the setTimeout function when the "website finishes loading"
  28. if (document.querySelector("#amzn-captcha-verify-button") !== null) { //If the verify screen is shown
  29. document.querySelector("#amzn-captcha-verify-button").click(); //Click on Begin
  30. } //Finishes the if condition
  31. }, 1000); //Finishes the setTimeout function
  32.  
  33. var SpanElements = document.querySelectorAll("span"); //Get all span elements on the page
  34. for (var i = SpanElements.length; i--;) { //For every single span element
  35. if (SpanElements[i].style.fontSize !== undefined) { //Check if the element has the font-size CSS attribute
  36. 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%
  37. SpanElements[i].style.fontSize = '1000%'; //Change the span element font-size CSS attribute to be only 1000%
  38. } //Finishes the if condition
  39. } //Finishes the if condition
  40. } //Finishes the for condition
  41.  
  42. if (location.href.match('https://myanimelist.net/profile/') !== null || location.href.match('comtocom.php') !== null) //If the URL is an profile or comments page
  43. { //Starts the if condition
  44. var ProfileComments = document.querySelectorAll('div[id*="comtext"]'); //Get all span elements on the page
  45. for (i = ProfileComments.length; i--;) { //For every single span element
  46. ProfileComments[i].setAttribute('style', 'overflow:hidden !important;');
  47. } //Finishes the for condition
  48. } //Finishes the if condition
  49.  
  50. if (location.href.match('login.php') === null) //If the URL ISN'T the mal login page
  51. { //Starts the if condition
  52. setTimeout(() => { //Starts the setTimeout function
  53. if (document.querySelector(".sceditor-toolbar") !== null) //If the user is anywhere that has the MAL BBCode editor ToolBar (forum topic or PM pages)
  54. { //Starts the if condition
  55. document.querySelectorAll(".sceditor-toolbar").forEach(function(el) { //For the top and bottom New reply text boxes on forum topics
  56. el.nextSibling.contentWindow.document.body.onkeyup = function() { //Detects when the user is writing on the page
  57. 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
  58. { //Starts the if condition
  59. GM_setValue("Recovered text", this.innerText); //Save the text that is being written
  60. } //Finishes the if condition
  61. }; //Finishes the onkeypress event listener
  62.  
  63. el.nextSibling.contentWindow.document.body.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
  64. if (e.button === 1) { //Starts the if condition If the middle mouse button was clicked and the focused element is not = undefined
  65. this.innerText = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
  66. e.preventDefault(); //Prevent the default middle button action from executing
  67. } //Finishes the if condition
  68. }); //Finishes the mousedown event listener
  69. }); //Finishes the ForEach loop
  70. } //Finishes the if condition
  71. }, 1500); //Finishes the setTimeout function
  72.  
  73. document.body.onkeyup = function() { //Detects when the user is writing on the page
  74. 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
  75. { //Starts the if condition
  76. GM_setValue("Recovered text", document.activeElement.value); //Save the text that is being written
  77. } //Finishes the if condition
  78. }; //Finishes the onkeypress event listener
  79.  
  80. window.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
  81. 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
  82. document.activeElement.value = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
  83. e.preventDefault(); //Prevent the default middle button action from executing
  84. } //Finishes the if condition
  85. }); //Finishes the mousedown event listener
  86. } //Finishes the if condition
  87. })();