From 2b08f5a5596890831ea2827a30ef0622d6448276 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 11:42:11 +0200 Subject: [PATCH] #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) {