Feature/#6 requests page remove empty user #10
|
@ -2,29 +2,34 @@ registerScript(node => {
|
||||||
// run the scripts
|
// run the scripts
|
||||||
if (isHtmlElement(node)) {
|
if (isHtmlElement(node)) {
|
||||||
changeFollowedStarColor(node);
|
changeFollowedStarColor(node);
|
||||||
changeOwnBorderColor(node);
|
changeBorderColor(node);
|
||||||
|
removeUnknownUsers(node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function changeFollowedStarColor(node) {
|
function changeFollowedStarColor(node) {
|
||||||
const starIcon = "star";
|
const starIcon = 'star';
|
||||||
|
|
||||||
// find stars
|
// 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
|
// change color
|
||||||
followedItems.forEach(item => item.style.color = aniBlue);
|
followedItems.forEach(item => item.style.color = aniBlue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeOwnBorderColor(node) {
|
function changeBorderColor(node) {
|
||||||
const targetTagName = "MD-LIST-ITEM"; // tagName is upper case
|
const targetTagName = 'MD-LIST-ITEM'; // tagName is upper case
|
||||||
|
|
||||||
let updateFunc = item => {
|
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"])');
|
||||||
|
|
||||||
|
// highlight left border for own request
|
||||||
if (profileLink.length > 0) {
|
if (profileLink.length > 0) {
|
||||||
item.style.borderColor = aniBlue
|
item.style.borderColor = aniBlue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add border as horizontal seperator
|
||||||
|
item.style.borderBottom = "1px solid rgba(155,155,155, 0.2)";
|
||||||
}
|
}
|
||||||
|
|
||||||
// are we target tag?
|
// are we target tag?
|
||||||
|
@ -32,9 +37,50 @@ function changeOwnBorderColor(node) {
|
||||||
updateFunc(node);
|
updateFunc(node);
|
||||||
} else {
|
} else {
|
||||||
// find items -> all
|
// 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"
|
// update borders
|
||||||
|
requestItems.forEach(item => {
|
||||||
|
updateFunc(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = `<b>${anime}</b>`;
|
||||||
|
|
||||||
|
// add user note if own request
|
||||||
|
if (profileLink.length > 0) {
|
||||||
|
lowerDiv.innerHTML = profileData;
|
||||||
|
}
|
||||||
|
// remove if foreign request.
|
||||||
|
else {
|
||||||
|
lowerDiv.innerHTML = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 => {
|
requestItems.forEach(item => {
|
||||||
updateFunc(item);
|
updateFunc(item);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
const aniBlue = "#348fff";
|
const aniBlue = '#348fff';
|
Loading…
Reference in a new issue