Feature/#7 core logic detect page change and refresh #8
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
});
|
Loading…
Reference in a new issue