From 7e21fbdf05f1840e00ab4f46ed48e349bcb5a40b Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 11:35:51 +0200 Subject: [PATCH 1/4] #6 Changed " to ' --- enhancements/animeRequests.js | 12 ++++++------ utils/colors.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index d51f342..1fa6827 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -7,20 +7,20 @@ registerScript(node => { }); function changeFollowedStarColor(node) { - const starIcon = "star"; + const starIcon = 'star'; // find stars - let followedItems = Array.from(node.querySelectorAll("i")).filter(i => i.innerText.trim() === starIcon); + let followedItems = Array.from(node.querySelectorAll('i')).filter(i => i.innerText.trim() === starIcon); // change color followedItems.forEach(item => item.style.color = aniBlue); } function changeOwnBorderColor(node) { - const targetTagName = "MD-LIST-ITEM"; // tagName is upper case + const targetTagName = 'MD-LIST-ITEM'; // tagName is upper case let updateFunc = item => { - let profileLink = item.querySelectorAll("a[href*='/profile/']:not([href='/profile/false'])"); + let profileLink = item.querySelectorAll('a[href*="/profile/"]:not([href="/profile/false"])'); if (profileLink.length > 0) { item.style.borderColor = aniBlue @@ -32,9 +32,9 @@ function changeOwnBorderColor(node) { updateFunc(node); } else { // find items -> all - let requestItems = node.querySelectorAll("md-list-item"); + let requestItems = node.querySelectorAll('md-list-item'); - // change border color if profile link is not "false" + // change border color if profile link is not 'false' requestItems.forEach(item => { updateFunc(item); }); diff --git a/utils/colors.js b/utils/colors.js index a3c864b..536b09f 100644 --- a/utils/colors.js +++ b/utils/colors.js @@ -1 +1 @@ -const aniBlue = "#348fff"; \ No newline at end of file +const aniBlue = '#348fff'; \ No newline at end of file -- 2.43.5 From 199c9db5c5f03de158dbeaf0ac49dfe30720d53d Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 11:39:09 +0200 Subject: [PATCH 2/4] #6 Remove unknown users --- enhancements/animeRequests.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index 1fa6827..839a581 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -3,6 +3,7 @@ registerScript(node => { if (isHtmlElement(node)) { changeFollowedStarColor(node); changeOwnBorderColor(node); + removeUnknownUsers(node); } }); @@ -28,6 +29,31 @@ function changeOwnBorderColor(node) { } // are we target tag? + if (node.tagName === targetTagName) { + updateFunc(node); + } else { + // find items -> all + let requestItems = node.querySelectorAll('md-list-item'); + + // change border color if profile link is not 'false' + requestItems.forEach(item => { + updateFunc(item); + }); + } +} + +function removeUnknownUsers(node) { + const targetTagName = 'MD-LIST-ITEM'; // tagName is upper case + + let updateFunc = item => { + let upperDiv = node.querySelector('[layout-align="start center"][flex]') + let lowerDiv = upperDiv.parentElement.nextElementSibling; + + let anime = lowerDiv.innerText; + upperDiv.innerHTML = `${anime}`; + lowerDiv.innerHTML = ' '; + } + if (node.tagName === targetTagName) { updateFunc(node); } else { -- 2.43.5 From 2b08f5a5596890831ea2827a30ef0622d6448276 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 11:42:11 +0200 Subject: [PATCH 3/4] #6 Remember user for own requests --- enhancements/animeRequests.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index 839a581..3f55c2d 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -46,12 +46,28 @@ function removeUnknownUsers(node) { const targetTagName = 'MD-LIST-ITEM'; // tagName is upper case let updateFunc = item => { + // find user profile link -> own request + let profileLink = item.querySelectorAll('a[href*="/profile/"]:not([href="/profile/false"])'); + + // find divs let upperDiv = node.querySelector('[layout-align="start center"][flex]') let lowerDiv = upperDiv.parentElement.nextElementSibling; + // remember Data let anime = lowerDiv.innerText; + let profileData = upperDiv.innerHTML; + + // exchange data upperDiv.innerHTML = `${anime}`; - lowerDiv.innerHTML = ' '; + + // add user note if own request + if (profileLink.length > 0) { + lowerDiv.innerHTML = profileData; + } + // remove if foreign request. + else { + lowerDiv.innerHTML = ' '; + } } if (node.tagName === targetTagName) { -- 2.43.5 From 7e703ec1c35e7677b2833cb06fa2a19ce9c4b373 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 11:55:02 +0200 Subject: [PATCH 4/4] #6 Add border as horizontal seperator --- enhancements/animeRequests.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index 3f55c2d..f03e7ea 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -2,7 +2,7 @@ registerScript(node => { // run the scripts if (isHtmlElement(node)) { changeFollowedStarColor(node); - changeOwnBorderColor(node); + changeBorderColor(node); removeUnknownUsers(node); } }); @@ -17,15 +17,19 @@ function changeFollowedStarColor(node) { followedItems.forEach(item => item.style.color = aniBlue); } -function changeOwnBorderColor(node) { +function changeBorderColor(node) { const targetTagName = 'MD-LIST-ITEM'; // tagName is upper case let updateFunc = item => { let profileLink = item.querySelectorAll('a[href*="/profile/"]:not([href="/profile/false"])'); + // highlight left border for own request if (profileLink.length > 0) { item.style.borderColor = aniBlue } + + // add border as horizontal seperator + item.style.borderBottom = "1px solid rgba(155,155,155, 0.2)"; } // are we target tag? @@ -35,7 +39,7 @@ function changeOwnBorderColor(node) { // find items -> all let requestItems = node.querySelectorAll('md-list-item'); - // change border color if profile link is not 'false' + // update borders requestItems.forEach(item => { updateFunc(item); }); -- 2.43.5