#7 Fixes in core and star coloring
This commit is contained in:
parent
3b145e2d4e
commit
3d309ae88a
2 changed files with 10 additions and 5 deletions
|
@ -1,5 +1,3 @@
|
||||||
const starIcon = "star";
|
|
||||||
|
|
||||||
registerScript(node => {
|
registerScript(node => {
|
||||||
// run the scripts
|
// run the scripts
|
||||||
if (isHtmlElement(node)) {
|
if (isHtmlElement(node)) {
|
||||||
|
@ -9,8 +7,10 @@ registerScript(node => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function changeFollowedStarColor(node) {
|
function changeFollowedStarColor(node) {
|
||||||
|
const starIcon = "star";
|
||||||
|
|
||||||
// find stars
|
// 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
|
// change color
|
||||||
followedItems.forEach(item => item.style.color = aniBlue);
|
followedItems.forEach(item => item.style.color = aniBlue);
|
||||||
|
|
|
@ -4,15 +4,20 @@ function registerScript(func) {
|
||||||
__scripts.push(func);
|
__scripts.push(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runScripts(node) {
|
||||||
|
__scripts.forEach(script => script(node));
|
||||||
|
}
|
||||||
|
|
||||||
let observer = new MutationObserver(mutations => {
|
let observer = new MutationObserver(mutations => {
|
||||||
mutations.forEach(mutation => {
|
mutations.forEach(mutation => {
|
||||||
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
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, {
|
observer.observe(document.documentElement || document.body, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true,
|
||||||
|
attributes: true
|
||||||
});
|
});
|
Loading…
Add table
Reference in a new issue