Series Highlighter - MAL

Highlights entries that already exist on your MAL lists

目前为 2021-12-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         Series Highlighter - MAL
// @namespace    MALHighlither
// @version      0.21
// @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/search/all*
// @include      /^https?:\/\/myanimelist\.net\/(animelist|mangalist)/
// @include      /^https?:\/\/myanimelist\.net\/top(anime|manga)\.php/
// @include      /^https?:\/\/myanimelist\.net\/(anime|manga)\.php\?.*\S=/
// @include      /^https?:\/\/myanimelist\.net\/(anime|manga)\/\d+\/[^\/]+\/userrecs/
// @include      /^https?:\/\/myanimelist\.net\/(character|people)(\.php\?id=|\/)\d+/
// @include      /^https?:\/\/myanimelist\.net\/(addtolist|recommendations|reviews|shared)\.php/
// @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';
  var url = location.pathname; //Create a new global variable to detect the url
  document.head.insertAdjacentHTML('beforeend', '<style>.ranking-list td {background: none !important;}</style>'); //On topanime/manga and shared.php pages remove the default background

  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('addtolist', 'rgb(85 253 207 / 30%)'); //Set the addtolist Color
    GM_setValue('Completed', 'rgb(155 184 253 / 30%)'); //Set the Completed Color
    GM_setValue('Watching/Reading', 'rgb(67 232 93 / 30%)'); //Set the Watching/Reading Color
    GM_setValue('AnimeList/MangaList', 'rgb(85 253 207 / 30%)'); //Set the Watching/Reading Color
  } //Finishes the if condition

  if (url.match('addtolist.php') !== null) //If the user is on the addtolist page
  { //Starts the if condition

    document.querySelector("input.inputButton").addEventListener("click", function() { //When the search button is clicked
      setTimeout(function() { //Starts the settimeout function
        $('tr:contains("Edit")').css('background-color', GM_getValue('addtolist'))[0]; //Add the same background color to all entries that's on the user list
      }, 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
          $('tr:contains("Edit")').css('background-color', GM_getValue('addtolist'))[0]; //Add the same background color to all entries that's on the user list
        }, 1500); //Starts the HighLight function after 1.5 secs
      } //Finishes the if condition
    }); //Finishes the settimeout function

    return; //Stop the script execution
  } //Finishes the if condition

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

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

    if (url.match(/animelist|mangalist/) !== null && document.body.innerHTML.match('sharedanime.php') !== null) { //If the url is on any animelist or mangalist and if it's not the user own anime/manga list
      document.head.insertAdjacentHTML('beforeend', '<style>td {background: none !important;}</style>'); //Remove the default background color on rows on classic lists
      $('tr:contains("Edit")').css('background-color', GM_getValue('AnimeList/MangaList'))[0]; //Add the same background color to all entries that's on the user list
      return; //Stop the script execution
    } //Finishes the if condition

    if (document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)').length !== 0) { //If the page has animes that are on the user list
      var OnUserLists = document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)'); //Add all animes on the user list total number to a variable

      if (url.match('shared.php') !== null) { //If the url is the shared page
        OnUserLists = document.querySelector("table").querySelectorAll('a.Lightbox_AddEdit:not(.button_add)'); //Add all shared animes on the user list total number to a variable
        document.head.insertAdjacentHTML('beforeend', '<style>td {background: none !important;}</style>'); //Remove the default background color on rows that both users gave the exact same score for the row entry on the shared.php page
      } //Finishes the if condition

    } //Finishes the if condition

    if (OnUserLists !== undefined) //If there's at least 1 anime on the user list in the current page
    { //Starts the if condition
      for (var i = OnUserLists.length; i--;) { //Starts the for condition
        var ElementStyle = OnUserLists[i].parentElement.parentElement.parentElement.style; //If the current opened page is the reviews.php, season or userrecs page, or if it's the people page and the user also has MALSync installed

        if (url.match('/people|anime.php/') !== null && OnUserLists[i].parentElement.parentElement.tagName === 'TR') { //If the current opened page is the people page or the anime.php and if the 2 parentElement is an TR element
          var ParentElement = true; //Define the variable as false because the user doesn't have MALSync installed
        } //Finishes the if condition

        if (location.href === 'https://myanimelist.net/' || url.match(/\/search\/all|recommendations.php|topanime.php|topmanga.php|shared.php|manga.php|\/watch|\/character|\/genre|\/producer|\/magazine/) !== null && document.querySelector("div.js-categories-seasonal.js-block-list.tile.mt16") === null || ParentElement === true) { //If the current page is one of these pages, and If the genre/producer/magazine page it's not on the block list view mode, or if it's the people page and the user doesn't have MALSync installed
          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 (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
          OnUserLists[i].innerText = 'CMPL'; //Change the text from edit to CMPL
          OnUserLists[i].style.backgroundColor = '#26448f'; //Change the edit button background color
          OnUserLists[i].style.color = 'white'; //Change the edit button text color
        } //Finishes the if condition

        if (OnUserLists[i].outerHTML.match(/Plan to Watch|Plan to Read|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
          OnUserLists[i].innerText = 'PLAN'; //Change the text from edit to PLAN
          OnUserLists[i].style.backgroundColor = '#c3c3c3'; //Change the edit button background color
          OnUserLists[i].style.color = 'white'; //Change the edit button text color
        } //Finishes the if condition

        if (OnUserLists[i].outerHTML.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
          OnUserLists[i].innerText = OnUserLists[i].outerHTML.match(/Reading/gi) !== null ? 'CR' : 'CW'; //Change the text from edit to the actual entry status
          OnUserLists[i].style.backgroundColor = '#2db039'; //Change the edit button background color
          OnUserLists[i].style.color = 'white'; //Change the edit button text 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
          OnUserLists[i].innerText = 'DROP'; //Change the text from edit to DROP
          OnUserLists[i].style.backgroundColor = '#a12f31'; //Change the edit button background color
          OnUserLists[i].style.color = 'white'; //Change the edit button text color
        } //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
          OnUserLists[i].innerText = 'HOLD'; //Change the text from edit to HOLD
          OnUserLists[i].style.backgroundColor = '#f1c83e'; //Change the edit button background color
          OnUserLists[i].style.color = 'white'; //Change the edit button text color
        } //Finishes the if condition

      } //Finishes the for condition
    } //Finishes the if condition
  } //Finishes the function HighLight

  window.onscroll = 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)
    if (window.scrollY * 1.2 >= document.querySelector('body').offsetHeight - window.innerHeight) { //When the bottom is almost reached
      setTimeout(function() { //Starts the settimeout function
        HighLight(); //Starts the HighLight function
      }, 1500); //Starts the HighLight function after 1.5 secs
    } //Finishes the if condition
  }; //Finishes the onscroll event listener

  window.onload = function() { //When the page finishes loading
    setTimeout(function() { //Starts the settimeout function
      HighLight(); //Starts the HighLight function
    }, 500); //Starts the HighLight function after half sec
  }; //Finishes the onscroll event listener
})();

QingJ © 2025

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