From 604db7a723e31ee97f5f11c7e17caf2b7c07c200 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Sat, 25 Apr 2020 22:43:36 +0200 Subject: [PATCH 1/2] #1 Change border color of own requests --- enhancements/animeRequests.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index 2844115..3423382 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -1,6 +1,7 @@ const starIcon = "star"; executeAfterPreload(changeFollowedStarColor); +executeAfterPreload(changeOwnBorderColor); function changeFollowedStarColor() { // find stars @@ -8,4 +9,18 @@ function changeFollowedStarColor() { // change color followedItems.forEach(item => item.style.color = aniBlue); +} + +function changeOwnBorderColor() { + // find items -> all + let requestItems = document.querySelectorAll("md-list-item"); + + // change border color if profile link is not "false" + requestItems.forEach(item => { + let profileLink = item.querySelectorAll("a[href*='/profile/']:not([href='/profile/false'])"); + + if (profileLink.length > 0) { + item.style.borderColor = aniBlue + } + }); } \ No newline at end of file From 5c8a2d45fbe2e2cf8797d2d9f48bd9e8aa3d4ef2 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Sat, 25 Apr 2020 23:23:13 +0200 Subject: [PATCH 2/2] #1 Fix for lateloading in the list --- enhancements/animeRequests.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index 3423382..50ab210 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -1,7 +1,23 @@ const starIcon = "star"; +const scripts = [ + changeFollowedStarColor, + changeOwnBorderColor, +] -executeAfterPreload(changeFollowedStarColor); -executeAfterPreload(changeOwnBorderColor); +executeAfterPreload(initScripts); + +function initScripts() { + // run the scripts + runScripts(); + + // because of late loading in the request list we have to run the codes each time the list changes + document.querySelector("md-list").addEventListener("DOMNodeInserted", event => runScripts(event), false); +} + +function runScripts() { + scripts.forEach(script => script()); + console.log("DDS") +} function changeFollowedStarColor() { // find stars