fix(Turntable): fad-heart sometimes incorrect

This commit is contained in:
Grason Chan 2021-11-15 23:24:15 +08:00
parent fc78c50ab5
commit f2ef742cde

View File

@ -247,20 +247,29 @@ window.addEventListener("load", rotateTurntable = () => {
const nowPlayingBarLeft = document.querySelector(".main-nowPlayingBar-left"); const nowPlayingBarLeft = document.querySelector(".main-nowPlayingBar-left");
const heartHiddenObserver = new MutationObserver(mutationsList => { const heartHiddenObserver = new MutationObserver(mutationsList => {
const targetMutation = mutationsList[mutationsList.length - 1]; mutationsLoop:
for (const mutation of mutationsList) {
for (const addedNode of targetMutation.addedNodes) { for (const addedNode of mutation.addedNodes) {
if ( if (
addedNode.matches('svg[class]') addedNode.matches('svg[class]')
|| ||
addedNode.matches('button[class^="main-addButton-button"]') addedNode.matches('button[class^="main-addButton-button"]')
) handleFadHeart(); ) {
handleFadHeart();
break mutationsLoop;
}
} }
for (const removedNode of targetMutation.removedNodes) { for (const removedNode of mutation.removedNodes) {
if ( if (
removedNode.matches('button[class^="main-addButton-button"]') removedNode.matches('button[class^="main-addButton-button"]')
) handleFadHeart(); ) {
handleFadHeart();
break mutationsLoop;
}
}
} }
}); });
heartHiddenObserver.observe(nowPlayingBarLeft, { heartHiddenObserver.observe(nowPlayingBarLeft, {