Series Highlighter - MAL

Highlights entries that already exist on your MAL lists

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

// ==UserScript==
// @name         Series Highlighter - MAL
// @namespace    MALHighlither
// @version      0.12
// @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\/(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';
  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

  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 (url.match('shared.php') !== null) //If the user is on the shared.php page
  { //Starts the if condition
    document.head.insertAdjacentHTML('beforeend', '<style>td {background: none !important;}</style>'); //On the shared.php page remove the default background color on rows that both users gave the exact same score for the row entry
  } //Finishes the if condition

  if (url.match('addtolist.php') !== null) //If the user is on the addtolist page
  { //Starts the if condition
    var OnUserLists, ElementStyle; //Makes these variables global

    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.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 f 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 (document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)').length !== 0 && url.match('addtolist.php') === null) { //If the page has animes that are on the user list and if the url isn't the addtolist page
      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

    if (document.querySelectorAll('a.Lightbox_AddEdit:not(.button_add)').length !== 0 && url.match('addtolist.php') === null && url.match('shared.php') !== null) { //If the page has animes that are on the user list and if the url isn't the addtolist page and 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
    } //Finishes the if condition

    if (url.match(/animelist|mangalist/) !== null && document.body.innerText.search("Viewing Your Anime List") !== 0) { //If the url is on any animelist or mangalist and if it's not the user own anime/manga list
      OnUserLists = document.querySelectorAll("span.edit"); //Add all animes on the user list total number to a variable
    } //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
        if (url.match(/animelist|mangalist/) !== null && OnUserLists[i].innerText === 'Edit') { //If the url is an animelist or mangalist and if the row has the Edit button
          OnUserLists[i].parentElement.parentElement.parentElement.style.backgroundColor = GM_getValue('AnimeList/MangaList'); //Add the same background color to all entries that's on the user list
        } //Finishes the if condition

        if (url.match('addtolist.php') !== null) { //If the url is the addtolist page
          OnUserLists[i].parentElement.parentElement.style.backgroundColor = GM_getValue('addtolist'); //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 (url.match(/reviews.php|\/season|\/userrecs/) !== null) { //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 (location.href === 'https://myanimelist.net/' || url.match(/recommendations.php|topanime.php|topmanga.php|shared.php|anime.php|manga.php|\/watch|\/character|\/people|\/producer|\/magazine/) !== null) { //If the current page is one of these pages
            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 (location.href !== 'https://myanimelist.net/' && url.match(/\/genre|\/producer|\/magazine/) !== null && document.querySelector("div.js-categories-seasonal.js-block-list.tile.mt16") !== null) { //If the current page is one of these pages and if it's on the block list view mode
            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
            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
          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 === '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].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
            OnUserLists[i].innerText = 'CW/CR'; //Change the text from edit to CW/CR
            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.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
            OnUserLists[i].innerText = 'PTW/PTR'; //Change the text from edit to PTW/PTR
            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

        } //Finishes the else condition
      } //Finishes the for condtiion
    } //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
    HighLight(); //Starts the HighLight function
  }; //Finishes the onscroll event listener
})();

QingJ © 2025

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