#7 Fixes in core and star coloring

This commit is contained in:
Serraniel 2020-07-29 11:14:38 +02:00
parent 3b145e2d4e
commit 3d309ae88a
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3
2 changed files with 10 additions and 5 deletions

View file

@ -1,5 +1,3 @@
const starIcon = "star";
registerScript(node => {
// run the scripts
if (isHtmlElement(node)) {
@ -9,8 +7,10 @@ registerScript(node => {
});
function changeFollowedStarColor(node) {
const starIcon = "star";
// find stars
let followedItems = Array.from(node.querySelectorAll("i")).filter(i => i.innerText == starIcon);
let followedItems = Array.from(node.querySelectorAll("i")).filter(i => i.innerText.trim() === starIcon);
// change color
followedItems.forEach(item => item.style.color = aniBlue);

View file

@ -4,15 +4,20 @@ function registerScript(func) {
__scripts.push(func);
}
function runScripts(node) {
__scripts.forEach(script => script(node));
}
let observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
for (let i = 0; i < mutation.addedNodes.length; i++) {
__scripts.forEach(script => script(mutation.addedNodes[i]));
runScripts(mutation.addedNodes[i]);
}
});
});
observer.observe(document.documentElement || document.body, {
childList: true,
subtree: true
subtree: true,
attributes: true
});