Merge pull request #29 from Serraniel/feature/#20-horizontal-separator-for-lists

Feature/#20 horizontal separator for lists
This commit is contained in:
Daniel 2020-08-05 11:30:56 +02:00 committed by GitHub
commit 89fa458b4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 6 deletions

View file

@ -2,7 +2,7 @@ registerScript(node => {
// run the scripts // run the scripts
if (isHtmlElement(node)) { if (isHtmlElement(node)) {
changeFollowedStarColor(node); changeFollowedStarColor(node);
changeBorderColor(node); changeBorderColorOwnRequests(node);
removeUnknownUsers(node); removeUnknownUsers(node);
} }
}, "/requests"); }, "/requests");
@ -17,7 +17,7 @@ function changeFollowedStarColor(node) {
followedItems.forEach(item => item.style.color = aniBlue); followedItems.forEach(item => item.style.color = aniBlue);
} }
function changeBorderColor(node) { function changeBorderColorOwnRequests(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 => {
@ -27,9 +27,6 @@ function changeBorderColor(node) {
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?

28
enhancements/lists.js Normal file
View file

@ -0,0 +1,28 @@
registerScript(node => {
// run the scripts
if (isHtmlElement(node)) {
addListHorizontalSeparators(node)
}
}, ".*");
function addListHorizontalSeparators(node) {
const targetTagName = 'MD-LIST-ITEM'; // tagName is upper case
let updateFunc = item => {
// add border as horizontal seperator
item.style.borderBottom = "1px solid rgba(155,155,155, 0.2)";
}
// are we target tag?
if (node.tagName === targetTagName) {
updateFunc(node);
} else {
// find items -> all
let requestItems = node.querySelectorAll('md-list-item');
// update borders
requestItems.forEach(item => {
updateFunc(item);
});
}
}

View file

@ -22,7 +22,8 @@
], ],
"js": [ "js": [
"enhancements/quickSearch.js", "enhancements/quickSearch.js",
"enhancements/animeRequests.js" "enhancements/animeRequests.js",
"enhancements/lists.js"
], ],
"run_at": "document_end" "run_at": "document_end"
} }