Series Highlighter - MAL

Highlights entries that already exist on your MAL lists

当前为 2021-07-22 提交的版本,查看 最新版本

作者
hacker09
评分
0 0 0
版本
0.17
创建于
2021-04-09
更新于
2021-07-22
大小
10.8 KB
许可证
暂无
适用于

// ==UserScript==
// @name Series Highlighter - MAL (new)
// @namespace MALHighlither
// @version 0.16
// @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 TDorTR = 'tr'; //Create an tr element variable
var NotFirstEl = ''; //Creates a new variable
var url = location.pathname; //Create a new global variable to detect the url
document.head.insertAdjacentHTML('beforeend', '

'); //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); //Start HighLighting 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); //Start HighLighting 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', '

'); //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', '

'); //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', '

'); //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 && url.match(/reviews.php|recommendations.php|\/character|shared.php|people/) !== null) //If there's at least 1 anime on the user list in the current page, and if the current page is one of these pages
{ //Starts the if condition

if (url.match(/recommendations.php/) !== null) //If the user is on the recommendations page
{ //Starts the if condition
TDorTR = 'td'; //Make the tr element be an td element on the recommendations page
} //Finishes the if condition

if (url.match(/\/character|people/) !== null) //If the user is on the character or people pages
{ //Starts the if condition
NotFirstEl = ':not(:first)'; //Do not highlight the first tr element on the character/people pages
} //Finishes the if condition

for (var i = OnUserLists.length; i--;) { //Starts the for condition
var ElementStyle = OnUserLists[i].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/') !== null && OnUserLists[i].parentElement.parentElement.tagName !== 'TR') { //If the current opened page is the people page and if the 2 parentElement is not an TR element. (The user doesn't have MALSync installed)
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 (url.match('reviews.php') !== null) { //If the current opened page is the reviews page
//The user doesn't have MALSync installed
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 === 'Completed') //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(/Plan to Watch|Plan to Read/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].title.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].title; //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') //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') //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

$('div.video-list-outer-vertical,div.list.di-t.w100,li.ranking-unit,div.seasonal-anime.js-seasonal-anime'+TDorTR+NotFirstEl).each(function(){
if($(this).text().match(/PTW|PTR|PLAN/)) {
$(this).css('background-color', GM_getValue('PTW/PTR'))[0]; //Add the background color to all entries that's on the user list
}
if($(this).text().match(/CW|CR|Watching|Reading/gi)) {
$(this).css('background-color', GM_getValue('Watching/Reading')[0]); //Add the background color to all entries that's on the user list
}
});
//reviews.php element div.borderDark
$('div.video-list-outer-vertical:contains(CMPL),div.list.di-t.w100:contains(CMPL),li.ranking-unit:contains(CMPL),div.seasonal-anime.js-seasonal-anime:contains(CMPL),'+TDorTR+':contains(CMPL")'+NotFirstEl).css('background-color', GM_getValue('Completed'))[0]; //Add the background color to all entries that's on the user list
$('div.video-list-outer-vertical:contains(DROP),div.list.di-t.w100:contains(DROP),li.ranking-unit:contains(DROP),div.seasonal-anime.js-seasonal-anime:contains(DROP),'+TDorTR+':contains(DROP")'+NotFirstEl).css('background-color', GM_getValue('Dropped'))[0]; //Add the background color to all entries that's on the user list
$('div.video-list-outer-vertical:contains(HOLD),div.list.di-t.w100:contains(HOLD),li.ranking-unit:contains(HOLD),div.seasonal-anime.js-seasonal-anime:contains(HOLD),'+TDorTR+':contains(HOLD")'+NotFirstEl).css('background-color', GM_getValue('On-Hold'))[0]; //Add the background color to all entries that's on the user list
} //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或关注我们的公众号极客氢云获取最新地址