Greasy Fork is available in English.

Add new entries to PTW/PTR

Any new entries that you add to your list will be added to your Plan To Watch/Read list.

Skript installieren?
Vom Ersteller vorgeschlagenes Skript

Ihnen könnte auch Better Related Anime/Manga Reader gefallen.

Skript installieren
  1. // ==UserScript==
  2. // @name Add new entries to PTW/PTR
  3. // @namespace ChangeAddBehavior
  4. // @version 13
  5. // @description Any new entries that you add to your list will be added to your Plan To Watch/Read list.
  6. // @author hacker09
  7. // @match https://myanimelist.net/*/season*
  8. // @match https://myanimelist.net/anime.php?q=*
  9. // @match https://myanimelist.net/watch/episode*
  10. // @match https://myanimelist.net/watch/promotion*
  11. // @include /^https:\/\/myanimelist\.net\/(anime|manga)(\/)(genre|producer|magazine)(\/)([\d]+)(\/).*/
  12. // @include /^https:\/\/myanimelist\.net\/(anime|manga|stacks)(id=)?(\.php\?id=)?(\/?\d+)?\/?(?!.*\/).*(\?q=.*&cat=anime|manga)?$/
  13. // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  14. // @grant GM_registerMenuCommand
  15. // @run-at document-end
  16. // ==/UserScript==
  17.  
  18. setTimeout((async function() {
  19. 'use strict';
  20. if (document.querySelector("#myinfo_status.btn-user-status-add-list.js-form-user-status.js-form-user-status-btn.myinfo_addtolist") !== null) { //If the entry is not on the user list
  21. document.querySelector("#myinfo_status.btn-user-status-add-list.js-form-user-status.js-form-user-status-btn.myinfo_addtolist").href = 'javascript:void(0);'
  22. document.querySelector("#myinfo_status.btn-user-status-add-list.js-form-user-status.js-form-user-status-btn.myinfo_addtolist").dataset.value = 6; //Add it as PTW
  23.  
  24. document.querySelector("#myinfo_status.btn-user-status-add-list.js-form-user-status.js-form-user-status-btn.myinfo_addtolist").onclick = function() //When the Add button is clicked
  25. { //Starts the onclick function
  26. setTimeout(function() { //Wait the entry be added to the user list
  27. document.querySelector("#myinfo_status").value = '6'; //Set the entry as plan to watch, in a way that the user can see
  28. document.querySelector("#myinfo_status").dataset.class = 'plantowatch'; //Change the selection box to grey
  29. }, 900); //Finishes the settimout function
  30. }; //Finishes the onclick function
  31. } //Finishes the if condition
  32.  
  33. if (document.querySelector('a.Lightbox_AddEdit[class*="button_add"]') !== null) { //If there's an entry that is not on the user list
  34. var cssdefault = 'margin-left: 5px;'; //Creates a new global variable
  35. var cssmovein = 'margin-left: 5px; background-color: lightcyan;'; //Creates a new global variable
  36. var cssout = 'margin-left: 5px; background-color: unset'; //Creates a new global variable
  37.  
  38. GM_registerMenuCommand("Add All Entries", function() { //Creates a new function
  39. var UserInput = prompt('1 Watching\n2 Completed\n3 On-Hold\n4 Dropped\n5 PTW\n*Write only your choice number and click OK'); //Gets the user input
  40.  
  41. switch (UserInput) { //Detect the user choice
  42. case '1': //If the user choose option 1
  43. UserInput = '1'; //Change the variable value
  44. break; //Stop executing the switch statement
  45. case '2': //If the user choose option 2
  46. UserInput = '2'; //Change the variable value
  47. break; //Stop executing the switch statement
  48. case '3': //If the user choose option 3
  49. UserInput = '3'; //Change the variable value
  50. break; //Stop executing the switch statement
  51. case '4': //If the user choose option 4
  52. UserInput = '4'; //Change the variable value
  53. break; //Stop executing the switch statement
  54. case '5': //If the user choose option 5
  55. UserInput = '6'; //Change the variable value
  56. break; //Stop executing the switch statement
  57. } //Ends the switch statement
  58.  
  59. var Counter = 0; //Create a new counter variable
  60. document.querySelectorAll('a.Lightbox_AddEdit[class*="button_add"]').forEach(async function(el) { //ForEach MAL entry link
  61. const parameters = el.href.match('/manga/') !== null ? ['manga', 'num_read_volumes\":0,\"num_read_chapters'] : ['anime', 'num_watched_episodes']; //Creates an array having the anime/manga fetch parameters
  62. fetch(`https://myanimelist.net/ownlist/${parameters[0]}/add.json`, { //Fetch
  63. "body": `{\"${parameters[0]}_id\":${el.href.match(/[\d]+/)[0]},\"status\":${UserInput},\"score\":0,\"${parameters[1]}\":0,\"csrf_token\":\"${document.head.querySelector("[name='csrf_token']").content}\"}`,
  64. "method": "POST"
  65. }) //Finishes the Fetch
  66. .then(response => { //After the fetch finished
  67. Counter += 1; //Increase the counter by 1
  68. if (Counter === document.querySelectorAll('a.Lightbox_AddEdit[class*="button_add"]').length) //If the Counter is equal to the amount of fetched links
  69. { //Starts the if condition
  70. location.reload(); //Reloads the page after adding is completed
  71. } //Finishes the if condition
  72. }); //Finishes the then statement
  73. }); //Finishes the ForEach loop
  74. }); //Adds an option to the menu and finishes the function
  75.  
  76. if (location.href.match(/producer|stacks/) !== null && document.querySelector(".tile.on") !== null) //If the user is on a producer page and if the 1st view mode is enabled
  77. { //Starts the if condition
  78. cssdefault = 'font-size: smaller; display: block; margin-left: -45px; top: -35px; color: white; background-color: rgba(50,50,50,.95);'; //Change the css
  79. cssmovein = 'font-size: smaller; display: block; margin-left: -45px; top: -35px; color: black; background-color: #fff;'; //Changes the css
  80. cssout = cssdefault; //Changes the css
  81. } //Finishes the if condition
  82.  
  83. document.querySelectorAll('a.Lightbox_AddEdit[class*="button_add"]').forEach(async function(el, i) { //For each entry that is not on the user list
  84.  
  85. if (location.href.match(/episode|promotion/) !== null) //If the user is on the episodes page
  86. { //Starts the if condition
  87. cssdefault += 'float: right!important;'; //Change the css
  88. cssmovein += 'float: right!important;'; //Changes the css
  89. cssout = cssdefault; //Changes the css
  90. el.parentElement.insertAdjacentHTML('beforeEnd', `<a id="QAdd${i}" style="${cssdefault}" href="javascript:void(0);">Quick Add</a>`); //Add a quick add button
  91. } //Finishes the if condition
  92. else //If the user is not on the episodes page
  93. { //Starts the else condition
  94. el.parentElement.insertAdjacentHTML('beforeEnd', `<a id="QAdd${i}" style="${cssdefault}" href="javascript:void(0);">Quick Add</a>`); //Add a quick add button
  95. } //Finishes else if condition
  96.  
  97. document.querySelector("#QAdd" + i).onclick = function() { //When the quick add button is clicked
  98. const parameters = el.href.match('/manga/') !== null ? ['manga', 'num_read_volumes\":0,\"num_read_chapters'] : ['anime', 'num_watched_episodes']; //Creates an array having the anime/manga fetch parameters
  99.  
  100. fetch(`https://myanimelist.net/ownlist/${parameters[0]}/add.json`, { //Fetch
  101. "body": `{\"${parameters[0]}_id\":${el.href.match(/[\d]+/)[0]},\"status\":6,\"score\":0,\"${parameters[1]}\":0,\"csrf_token\":\"${document.head.querySelector("[name='csrf_token']").content}\"}`,
  102. "method": "POST"
  103. }); //Finishes fetching
  104.  
  105. el.innerText = 'PLAN'; //Set the entry as plan, in a way that the user can see
  106. el.className = location.href.match(/episode|promotion/) === null ? 'Lightbox_AddEdit button_edit ga-click btn-anime-watch-status js-anime-watch-status button plantowatch' : 'Lightbox_AddEdit button_edit ga-click fl-r ml4 plantowatch'; //Change the selection box to grey
  107. }; //Finishes the onlick function
  108.  
  109. document.querySelector("#QAdd" + i).onmousemove = function() { //Set the css for the button when the mouse is hovering over the button
  110. document.querySelector("#QAdd" + i).style = cssmovein; //Change the element color
  111. }; //Finishes the css for the button when the mouse is hovering over the button
  112. document.querySelector("#QAdd" + i).onmouseout = function() {
  113. document.querySelector("#QAdd" + i).style = cssout; //Set the css for the button when the mouse is not hovering the button
  114. }; //Set the css for the button when the mouse is leaving the button
  115.  
  116. }); //Finishes the foreach loop
  117. } //Finishes the if condition
  118. }), 0)();