Better Buttons to Change The Status Of Animes/Mangas And To Add Scores

This script removes the dropdown selection of the options Reading/Watching,Completed,Plan To Read/Watch and Dropped, and does the same for the Score button, making a bit easier and faster to select what you want.The script also adds a button to delete the anime/manga entry of your list, and adds a button to give the same score + set the whole Franchise as "Watching".

当前为 2021-12-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better Buttons to Change The Status Of Animes/Mangas And To Add Scores
  3. // @namespace betterbuttonstomal2
  4. // @version 1.0.6
  5. // @description This script removes the dropdown selection of the options Reading/Watching,Completed,Plan To Read/Watch and Dropped, and does the same for the Score button, making a bit easier and faster to select what you want.The script also adds a button to delete the anime/manga entry of your list, and adds a button to give the same score + set the whole Franchise as "Watching".
  6. // @author hacker09
  7. // @include /^https:\/\/myanimelist\.net\/((anime|manga)(id=)?(\.php\?id=)?)(\/)?([\d]+)?/
  8. // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var $ = window.jQuery; //Defines That The Symbol $ Is A jQuery
  16. var animeid = location.pathname.match(/\d+/)[0]; //Get the anime id
  17. var token = document.head.querySelector("[name='csrf_token']").content; //Get the user csrf token
  18. document.querySelectorAll("#myinfo_status")[1].size = "5"; //Set the size for the Status button
  19. document.querySelectorAll("#myinfo_status")[1].setAttribute("style", "font-size: 13.2px; background-image: none; overflow: hidden;"); //Set the css for the status button
  20. document.querySelectorAll("#myinfo_score")[1].size = "11"; //Set the size for the Score button
  21. document.querySelectorAll("#myinfo_score > option:nth-child(1)")[1].innerText = 'Reset Score'; //Change the text "selection" to Reset Score
  22. document.querySelectorAll("#myinfo_score")[1].setAttribute("style", "background-image: none; overflow: hidden; padding : 5px; width: 100px;"); //Set the css for the score button
  23. //*****************************************************************************************************************************************************
  24. var DeleteBTN = document.createElement("input"); //Create a input element
  25. document.querySelectorAll("#myinfo_status")[1].parentElement.appendChild(DeleteBTN); //Show the delete button
  26. $(DeleteBTN).attr({ //Set the attributes
  27. value: "Delete", //Add the value Delete to the button
  28. id: "DeleteBTN", //Add the id DeleteBTN to the button
  29. class: "inputButton ml8 delete_submit", //Add a class to the button
  30. type: "button", //Add the type to the button
  31. style: "margin-left: 30px!important;" //Set the css to the button
  32. }); //Finishing setting the attributes
  33. if (window.location.pathname.split('/')[1] === 'anime') { //If the user is on an anime page
  34. var entrytype = 'anime'; //Set the variable as anime
  35. document.querySelector("div.di-ib.form-user-episode.ml8").setAttribute("style", "width: 125px;"); //Set the css for the episodes element
  36. document.querySelectorAll("#myinfo_watchedeps")[1].setAttribute("style", "width: 25px;"); //Set the css for the episodes seen element
  37.  
  38. //*****************************************************************************************************************************************************
  39. var ScoreButton = document.createElement("input"); //Create a input element
  40. document.querySelectorAll("#myinfo_status")[1].parentElement.appendChild(ScoreButton); //Show the Score button
  41. $(ScoreButton).attr({ //Set the attributes
  42. value: "Score+Add Franchise", //Add the value Score to the button
  43. id: "ScoreBTN", //Add the id ScoreBTN to the button
  44. class: "inputButton ml8 delete_submit", //Add a class to the button
  45. type: "button", //Add the type to the button
  46. style: "margin-left: 30px!important;" //Set the css to the button
  47. }); //Finishing setting the attributes
  48. document.querySelector("div.di-ib.form-user-episode.ml8").setAttribute("style", "width: 125px;"); //Set the css for the episodes element
  49. document.querySelectorAll("#myinfo_watchedeps")[1].setAttribute("style", "width: 25px;"); //Set the css for the episodes seen element
  50. document.querySelector("#ScoreBTN").addEventListener("click", (async function() { //Add an advent listener to the Score button that will score and set as "Watching" the whole franchise when clicked
  51. if (document.querySelector("#myinfo_score").value === '0') //If the actual score of the anime entry is 0
  52. { //Start the if condition
  53. alert('You must first give a score for this entry, then the script will give that same score and add the entire franchise as watching.'); //Show a message
  54. return; //Stop the script from executing
  55. } //Finishes the if condition
  56.  
  57. const response = await fetch('https://api.allorigins.win/raw?url=https://chiaki.site/?/tools/watch_order/id/' + animeid); //Fetch
  58. const html = await response.text(); //Gets the fetch response
  59. var ChiakiDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
  60.  
  61. if (confirm("If you've already added this entire franchise to your anime list, press OK.")) { //Ask a question to the user
  62. var FetchPage = "https://myanimelist.net/ownlist/anime/edit.json"; //If the user have already added the entire franchise to his anime list
  63. } else { //Starts the else condition
  64. FetchPage = "https://myanimelist.net/ownlist/anime/add.json"; //If the user doesn't have added the entire franchise on his anime list
  65. } //Starts the finishes condition
  66.  
  67. var TotalLinks = ChiakiDocument.querySelectorAll("span.uk-text-muted.uk-text-small > a:nth-child(1)"); //Creates a variable to loop though the elements after
  68. for (var i = 0; i < TotalLinks.length; i++) { //Starts the for condition
  69. async function AddScore() //Creates a function to Score + set as "Watching" the Franchise
  70. { //Starts the function
  71. const response = await fetch(FetchPage, { //Fetches the page
  72. "headers": {
  73. "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  74. },
  75. "body": "{\"anime_id\":" + TotalLinks[i].href.match(/\d+/)[0] + ",\"status\":1,\"score\":" + document.querySelector("#myinfo_score").value + ",\"num_watched_episodes\":0,\"csrf_token\":\"" + token + "\"}",
  76. "method": "POST"
  77. }); //Finishes the fetch
  78. } //Finishes the async function
  79. if (TotalLinks[i].href.match(/\d+/)[0] !== animeid) //If the fetched chiaki.site anime id isn't the same as the actual page anime id
  80. { //Starts if condition
  81. AddScore(); //Starts the async AddScore function
  82. } //Finishes the if condition
  83. } //Finishes the for condition
  84.  
  85. alert('Done!!!\nThe Whole Franchise was scored with ' + document.querySelector("#myinfo_score").value + ' and was added to your watching anime list!'); //Shows a message
  86. })); //Finishes the advent listener
  87.  
  88. //*****************************************************************************************************************************************************
  89. } else { //Starts the else condition
  90. var entrytype = 'manga'; //Set the variable as manga
  91. } //Finishes the else condition
  92. document.querySelector("#DeleteBTN").addEventListener("click", (async function() { //Add an advent listener to the delete button that will delete the anime of the user list when clicked
  93. await fetch("https://myanimelist.net/ownlist/" + entrytype + "/" + animeid + "/delete", {
  94. "headers": {
  95. "content-type": "application/x-www-form-urlencoded"
  96. },
  97. "body": "csrf_token=" + token + "",
  98. "method": "POST"
  99. }); //Finishes the fetch request
  100. location.reload(); //Reload the page after the user deleted the anime of his list
  101. })); //Finish the async function and the advent listener
  102. })();