Add new entries to PTW/PTR

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

目前为 2022-05-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         Add new entries to PTW/PTR
// @namespace    ChangeAddBehavior
// @version      7
// @description  Any new entries that you add to your list will added to your Plan To Watch/Read list.
// @author       hacker09
// @include      /^https:\/\/myanimelist\.net\/((anime|manga|people)(id=)?(\.php\?id=)?)(\/)?([\d]+)?/
// @include      /^https:\/\/myanimelist\.net\/(anime|manga)(\/)(genre|producer)(\/)([\d]+)(\/).*/
// @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
// @run-at       document-end
// @grant        none
// ==/UserScript==

(async function() {
  'use strict';
  const token = document.head.querySelector("[name='csrf_token']").content; //Creates a variable to hold the actual csrf_token

  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
    document.querySelector("#myinfo_status.btn-user-status-add-list.js-form-user-status.js-form-user-status-btn.myinfo_addtolist").href = 'javascript:void(0);'
    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

    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
    { //Starts the onclick function
      setTimeout(function() { //Wait the entry be added to the user list
        document.querySelector("#myinfo_status").value = '6'; //Set the entry as plan to watch, in a way that the user can see
        document.querySelector("#myinfo_status").dataset.class = 'plantowatch'; //Change the selection box to grey
      }, 900); //Finishes the settimout function
    } //Finishes the onclick function
  } //Finishes the if condition

  if (document.querySelector('a.Lightbox_AddEdit[class*="button_add"]') !== null) { //If there's an entry that is not on the user list
    var cssdefault = 'margin-left: 5px;'; //Creates a new global variable
    var cssmove = 'margin-left: 5px; background-color: lightcyan;'; //Creates a new global variable
    var cssout = 'margin-left: 5px; background-color: unset;'; //Creates a new global variable

    if (location.href.match('producer') !== null && document.querySelector(".on").className.match('tile') !== null) //If the user is on a producer page and if the 1st view mode is enabled
    { //Starts the if condition
      cssdefault = 'font-size: smaller; display: block; margin-left: -45px; top: -35px; color: white; background-color: rgba(50,50,50,.95);'; //Change the css
      cssmove = 'font-size: smaller; display: block; margin-left: -45px; top: -35px; color: black; background-color: #fff;'; //Changes the css
      cssout = 'font-size: smaller; display: block; margin-left: -45px; top: -35px; color: white; background-color: rgba(50,50,50,.95);'; //Changes the css
    } //Finishes the if condition

    document.querySelectorAll('a.Lightbox_AddEdit[class*="button_add"]').forEach(async function(el, i) { //For each entry that is not on the user list
      el.insertAdjacentHTML('afterEnd', `<a id="QAdd${i}" style="${cssdefault}" href="javascript:void(0);">Quick Add</a>`); //Add a quick add button

      document.querySelector("#QAdd" + i).onclick = function() { //When the quick add button is clicked
        var parameters = ['anime', 'num_watched_episodes']; //Creates an array having the anime fetch parameters
        if (el.href.match('/manga/') !== null) //If the entry is manga
        { //Starts the if condition
          parameters = ['manga', 'num_read_volumes\":0,\"num_read_chapters']; //Change the parameters array having the manga fetch parameters
        } //Finishes the if condition

        fetch(`https://myanimelist.net/ownlist/${parameters[0]}/add.json`, { //Fetch
          "body": `{\"${parameters[0]}_id\":${el.href.match(/[\d]+/)[0]},\"status\":6,\"score\":0,\"${parameters[1]}\":0,\"csrf_token\":\"${token}\"}`,
          "method": "POST"
        }); //Finishes fetching

        el.innerText = 'PLAN'; //Set the entry as plan, in a way that the user can see
        el.className = 'Lightbox_AddEdit button_edit ga-click btn-anime-watch-status js-anime-watch-status button plantowatch'; //Change the selection box to grey
      } //Finishes the onlick function

      document.querySelector("#QAdd" + i).onmousemove = function() { //Set the css for the button when the mouse is hovering the button
        document.querySelector("#QAdd" + i).style = cssmove; //Change the element color
      }; //Finishes the css for the button when the mouse is hovering the button
      document.querySelector("#QAdd" + i).onmouseout = function() {
        document.querySelector("#QAdd" + i).style = cssout; //Set the css for the button when the mouse is not hovering the button
      }; //Set the css for the button when the mouse is leaves the button

    }) //Finishes the foreach loop
  } //Finishes the if condition
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址