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-02-04 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Better Buttons to Change The Status Of Animes/Mangas And To Add Scores
// @namespace    betterbuttonstomal2
// @version      1.0.2
// @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".
// @author       hacker09
// @include      /^https:\/\/myanimelist\.net\/anime\/[\d]+(\/.*)?/
// @include      /^https:\/\/myanimelist\.net\/manga\/[\d]+(\/.*)?/
// @icon         https://www.google.com/s2/favicons?domain=myanimelist.net
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
  'use strict';
  var $ = window.jQuery; //Defines That The Symbol $ Is A jQuery
  var animeid = location.pathname.match(/\d+/)[0]; //Get the anime id
  var token = document.head.querySelector("[name='csrf_token']").content; //Get the user csrf token
  document.querySelectorAll("#myinfo_status")[1].size = "5"; //Set the size for the Status button
  document.querySelectorAll("#myinfo_status")[1].setAttribute("style", "font-size: 13.2px; background-image: none; overflow: hidden;"); //Set the css for the status button
  document.querySelectorAll("#myinfo_score")[1].size = "11"; //Set the size for the Score button
  document.querySelectorAll("#myinfo_score > option:nth-child(1)")[1].innerText = 'Reset Score'; //Change the text "selection" to Reset Score
  document.querySelectorAll("#myinfo_score")[1].setAttribute("style", "background-image: none; overflow: hidden; padding : 5px; width: 100px;"); //Set the css for the score button
  //*****************************************************************************************************************************************************
  var DeleteBTN = document.createElement("input"); //Create a input element
  document.querySelectorAll("#myinfo_status")[1].parentElement.appendChild(DeleteBTN); //Show the delete button
  $(DeleteBTN).attr({ //Set the attributes
    value: "Delete", //Add the value Delete to the button
    id: "DeleteBTN", //Add the id DeleteBTN to the button
    class: "inputButton ml8 delete_submit", //Add a class to the button
    type: "button", //Add the type to the button
    style: "margin-left: 30px!important;" //Set the css to the button
  }); //Finishing setting the attributes
  if (window.location.pathname.split('/')[1] === 'anime') { //If the user is on an anime page
    var entrytype = 'anime'; //Set the variable as anime
    document.querySelector("div.di-ib.form-user-episode.ml8").setAttribute("style", "width: 125px;"); //Set the css for the episodes element
    document.querySelectorAll("#myinfo_watchedeps")[1].setAttribute("style", "width: 25px;"); //Set the css for the episodes seen element

    //*****************************************************************************************************************************************************
    var ScoreButton = document.createElement("input"); //Create a input element
    document.querySelectorAll("#myinfo_status")[1].parentElement.appendChild(ScoreButton); //Show the Score button
    $(ScoreButton).attr({ //Set the attributes
      value: "Score Franchise", //Add the value Delete to the button
      id: "ScoreBTN", //Add the id ScoreBTN to the button
      class: "inputButton ml8 delete_submit", //Add a class to the button
      type: "button", //Add the type to the button
      style: "margin-left: 30px!important;" //Set the css to the button
    }); //Finishing setting the attributes
    document.querySelector("div.di-ib.form-user-episode.ml8").setAttribute("style", "width: 125px;"); //Set the css for the episodes element
    document.querySelectorAll("#myinfo_watchedeps")[1].setAttribute("style", "width: 25px;"); //Set the css for the episodes seen element
    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
      if (document.querySelector("#myinfo_score").value === '0') //If the actual score of the anime entry is 0
      { //Start the if condition
        alert('You must first give an score to this entry, then the script will give this same score to the whole franchise'); //Show a message
        return; //Stop the script from executing
      } //Finishes the if condition
      var ChiakiDocument; //Creates a new global variable
      async function GetChiakiDocument() //Creates a function to Get the Chiaki page
      { //Starts the function
        const response = await fetch('https://api.allorigins.win/raw?url=https://chiaki.site/?/tools/watch_order/id/' + animeid); //Fetch
        const html = await response.text(); //Gets the fetch response
        ChiakiDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response

        var TotalLinks = ChiakiDocument.querySelectorAll("span.uk-text-muted.uk-text-small > a"); //Creates a variable to loop though the elements after
        for (var i = 0; i < TotalLinks.length; i++) { //Starts the for condition
          async function AddScore() //Creates a function to Score + set as "Watching" the Franchise
          { //Starts the function
            const response = await fetch('https://myanimelist.net/ownlist/anime/add.json', {
              "headers": {
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
              },
              "body": "{\"anime_id\":" + TotalLinks[i].href.match(/\d+/)[0] + ",\"status\":1,\"score\":" + document.querySelector("#myinfo_score").value + ",\"num_watched_episodes\":0,\"csrf_token\":\"" + token + "\"}",
              "method": "POST"
            }); //Finishes the fetch
          } //Finishes the async function
          AddScore(); //Starts the async AddScore function
        } //Finishes the for condition

      } //Finishes the GetChiakiDocument function
      GetChiakiDocument(); //Starts the GetChiakiDocument function
      alert('Done!!!\nThe Whole Franchise was scored with ' + document.querySelector("#myinfo_score").value + ' !'); //Show a message
    })); //Finish the advent listener

    //*****************************************************************************************************************************************************
  } else {
    var entrytype = 'manga'; //Set the variable as manga
  } //Finishes the else condition
  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
    await fetch("https://myanimelist.net/ownlist/" + entrytype + "/" + animeid + "/delete", {
      "headers": {
        "content-type": "application/x-www-form-urlencoded"
      },
      "body": "csrf_token=" + token + "",
      "method": "POST"
    }); //Finishes the fetch request
    location.reload(); //Reload the page after the user deleted the anime of his list
  })); //Finish the async function and the advent listener
})();