Series Highlighter - MAL

Highlights entries that already exist on your MAL lists

目前为 2021-04-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         Series Highlighter - MAL
// @namespace    MALHighlither
// @version      0.2
// @description  Highlights entries that already exist on your MAL lists
// @author       hacker09
// @match        https://myanimelist.net/
// @include      /^https?:\/\/myanimelist\.net\/watch/
// @include      /^https?:\/\/myanimelist\.net\/top(anime|manga)\.php/
// @include      /^https?:\/\/myanimelist\.net\/(anime|manga)\.php\?.*\S=/
// @include      /^https?:\/\/myanimelist\.net\/(addtolist|recommendations)\.php/
// @include      /^https?:\/\/myanimelist\.net\/(anime|manga)\/\d+\/[^\/]+\/userrecs/
// @include      /^https?:\/\/myanimelist\.net\/(character|people)(\.php\?id=|\/)\d+/
// @include      /^https?:\/\/myanimelist\.net\/(anime|manga)\/(season|genre|producer|magazine)/
// @require      https://gf.qytechs.cn/scripts/21927-arrive-js/code/arrivejs.js
// @icon         http://i.imgur.com/b7Fw8oH.png
// @run-at       document-end
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
  'use strict';
  if (GM_getValue("Dropped") === undefined) { //If the variable doesn't exist yet define the variables
    GM_setValue('On-Hold', 'rgb(255 216 82 / 30%)'); //Set the On-Hold Color
    GM_setValue('PTW/PTR', 'rgb(144 144 144 / 30%)'); //Set the PTW/PTR Color
    GM_setValue('Dropped', 'rgb(255 142 144 / 30%)'); //Set the Dropped Color
    GM_setValue('Completed', 'rgb(155 184 253 / 30%)'); //Set the Completed Color
    GM_setValue('Watching/Reading', 'rgb(108 255 131 / 30%)'); //Set the Watching/Reading Color
  } //Finishes the if condition

  var url = window.location.pathname.split('/'); //Create a new global variable to detect the url
  document.head.insertAdjacentHTML('beforeend', '<style>.ranking-list td {background: none !important;}</style>'); //On topanime/manga pages remove the default background

  if (url[1] === "addtolist.php") //If the user is on the addtolist page
  { //Starts the if condition
    var OnUserLists; //Creates a new global variable

    document.querySelector("input.inputButton").addEventListener("click", function() { //When the search button is clicked
      setTimeout(function() { //Starts the settimeout function
        OnUserLists = document.querySelectorAll("a.btn-status-edit"); //Add all animes on the user list total number to a variable
        HighLight(); //Starts the HighLight function
      }, 1500); //Starts the HighLight function after 1.5 secs
    }); //Finishes the settimeout function
    document.querySelector("#maSearchText").addEventListener("keyup", function(event) { //When the user press Enter on the search box
      if (event.keyCode === 13) { //If the enter key was pressed
        setTimeout(function() { //Starts the settimeout function
          OnUserLists = document.querySelectorAll("a.btn-status-edit"); //Add all animes on the user list total number to a variable
          HighLight(); //Starts the HighLight function
        }, 1500); //Starts the HighLight function after 1.5 secs
      } //Finishes the if condition
    }); //Finishes the settimeout function
  } //Finishes the if condition

  if (document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)').length !== 0 && url[1] !== "addtolist.php" && document.querySelectorAll('.page-common .bgColor1').length !== 0) { //If the page has animes that are on the user list and is the url isn't the addtolist page and f the element '.page-common .bgColor1' exists
    document.head.insertAdjacentHTML('beforeend', '<style>.page-common .bgColor1 {background: unset;}</style>'); //Remove the default background
  } //Finishes the if condition

  new MutationObserver(function() { //If the next result page is auto loaded and added to the document body (If the user uses anything like the Endless MAL Script)
    HighLight(); //Starts the function HighLight
  }).observe(document.body, { //Defines the element and characteristics to be observed
    childList: true,
    subtree: true
  }); //Finishes the definitions that will be observed

  function HighLight() //Creates a new function function
  { //Starts the function

    if (document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)').length !== 0 && url[1] !== "addtolist.php" && document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)').length !== 0) { //If the page has animes that are on the user list and is the url isn't the addtolist page and if the page has animes that are on the user list
      OnUserLists = document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)'); //Add all animes on the user list total number to a variable
    } //Finishes the if condition

    for (var i = OnUserLists.length; i--;) { //Starts the for condition
      if (url[1] === 'addtolist.php') { //If the url is the addtolist page
        OnUserLists[i].parentElement.parentElement.style.backgroundColor = 'rgb(85 253 207 / 30%)'; //Add the same background color to all entries that's on the user list
      } //Finishes the if condition
      else //If the url is NOT the addtolist page
      { //Starts the else condition

        if (location.href === 'https://myanimelist.net/' || url[1].match(/anime.php|manga.php|watch|character|people|recommendations.php|topanime.php|topmanga.php/) !== null || url[2].match(/genre|producer|magazine/) !== null) { //If the current page is one of these pages
          var ElementStyle = OnUserLists[i].parentElement.parentElement.style; //Store the correct element to a variable to change it's background color later
        } //Finishes the if condition
        if (url[2] === 'season' || url[4] === 'userrecs') { //If the current opened page is the season or userrecs page
          ElementStyle = OnUserLists[i].parentElement.parentElement.parentElement.style; //Store the correct element to a variable to change it's background color later
        } //Finishes the if condition

        if (OnUserLists[i].title === 'On-Hold' || OnUserLists[i].className.match('on-hold') !== null) //If the link element title or classname "is" on-hold
        { //Starts the if condition
          ElementStyle.backgroundColor = GM_getValue('On-Hold'); //Change the element background color
        } //Finishes the if condition
        if (OnUserLists[i].title === 'Dropped' || OnUserLists[i].className.match('dropped') !== null) //If the link element title or classname "is" dropped
        { //Starts the if condition
          ElementStyle.backgroundColor = GM_getValue('Dropped'); //Change the element background color
        } //Finishes the if condition
        if (OnUserLists[i].title === 'Completed' || OnUserLists[i].className.match('completed') !== null) //If the link element title or classname "is" completed
        { //Starts the if condition
          ElementStyle.backgroundColor = GM_getValue('Completed'); //Change the element background color
        } //Finishes the if condition
        if (OnUserLists[i].title.match(/Watching|Reading/gi) !== null || OnUserLists[i].className.match(/Watching|Reading/gi) !== null) //If the link element title or classname "is" watching/reading
        { //Starts the if condition
          ElementStyle.backgroundColor = GM_getValue('Watching/Reading'); //Change the element background color
        } //Finishes the if condition
        if (OnUserLists[i].title.match(/Plan to Watch|Plan to Read/gi) !== null || OnUserLists[i].className.match(/plantowatch|plantoread/gi) !== null) //If the link element title or classname "is" plantowatch/plantoread
        { //Starts the if condition
          ElementStyle.backgroundColor = GM_getValue('PTW/PTR'); //Change the element background color
        } //Finishes the if condition

      } //Finishes the else condition
    } //Finishes the for condtiion
  } //Finishes the function HighLight
})();

QingJ © 2025

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