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-03-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MALFunction - "Fix" ERRORS on MAL + Text AutoSaver
  3. // @namespace MALFunction
  4. // @version 1.0.6
  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) {
  17. location.reload(); //Reloads the page
  18. }
  19. if (document.body.innerText.search('Please click "Submit" to verify that you are not a bot.') > -1) {
  20. setTimeout(function() {
  21. document.querySelector("button.g-recaptcha").click();
  22. }, 1000); //Auto click on the submit button
  23. }
  24. if (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") {
  25. location.reload(); //Reloads the page
  26. }
  27.  
  28. var SpanElements = document.querySelectorAll("span"); //Get all span elements on the page
  29. for (var i = SpanElements.length; i--;) { //For every single span element
  30. if (SpanElements[i].style.fontSize !== undefined) { //Check if the element has the font-size css attribute
  31. 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%
  32. SpanElements[i].style.fontSize = '1000%'; //Change the span element font-size css attribute to be only 1000%
  33. } //Finishes the if condition
  34. } //Finishes the if condition
  35. } //Finishes the for condition
  36.  
  37. if (location.href.match('https://myanimelist.net/profile/') !== null || location.href.match('comtocom.php') !== null) //If the url is an profile or comments page
  38. { //Starts the if condition
  39. var ProfileComments = document.querySelectorAll('div[id*="comtext"]'); //Get all span elements on the page
  40. for (i = ProfileComments.length; i--;) { //For every single span element
  41. ProfileComments[i].setAttribute('style', 'overflow:hidden !important;');
  42. } //Finishes the for condition
  43. } //Finishes the if condition
  44.  
  45. if (location.href.match('login.php') === null) //If the url ISN'T the mal login page
  46. { //Starts the if condition
  47. document.body.onkeyup = function() { //Detects when the user is writing on the page
  48. var FocusedElementText = document.activeElement.value; //Save the actual focused element to a variable
  49. if (FocusedElementText !== '' && FocusedElementText !== undefined) //If the focused element contains text and is not = undefined
  50. { //Starts the if condition
  51. GM_setValue("Recovered text", FocusedElementText); //Save the text that is being written
  52. } //Finishes the if condition
  53. }; //Finishes the onkeypress advent listener
  54.  
  55. window.addEventListener('mousedown', function(e) { //Detects when the user middle clicks on the page
  56. 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
  57. document.activeElement.value = GM_getValue("Recovered text"); //Add the text that the script recovered previously to the element that is actually focused
  58. e.preventDefault(); //Prevent the default middle button action from executing
  59. } //Finishes the if condition
  60. }); //Finishes the mousedown advent listener
  61. } //Finishes the if condition
  62. })();