change to new lyrics even if lyrics tab was already selected

This commit is contained in:
Araxeus
2022-01-29 11:35:18 +02:00
parent 900c44d9c0
commit 60bb5b861d
2 changed files with 23 additions and 16 deletions

View File

@ -50,22 +50,12 @@ module.exports = () => {
};
}
checkLyricsContainer();
tabs.lyrics.onclick = () => {
const tabContainer = document.querySelector("ytmusic-tab-renderer");
const observer = new MutationObserver((_, observer) => {
const lyricsContainer = document.querySelector(
'[page-type="MUSIC_PAGE_TYPE_TRACK_LYRICS"] > ytmusic-message-renderer'
);
if (lyricsContainer) {
observer.disconnect();
lyricsContainer.innerHTML = `<div id="contents" class="style-scope ytmusic-section-list-renderer genius-lyrics">
${lyrics}
<yt-formatted-string class="footer style-scope ytmusic-description-shelf-renderer">Source&nbsp;: Genius</yt-formatted-string>
</div>`;
tabs.lyrics.removeAttribute("disabled");
tabs.lyrics.removeAttribute("aria-disabled");
}
checkLyricsContainer(() => observer.disconnect());
});
observer.observe(tabContainer, {
attributes: true,
@ -73,5 +63,25 @@ module.exports = () => {
subtree: true,
});
};
function checkLyricsContainer(callback = () => {}) {
const lyricsContainer = document.querySelector(
'[page-type="MUSIC_PAGE_TYPE_TRACK_LYRICS"] > ytmusic-message-renderer'
);
if (lyricsContainer) {
callback();
setLyrics(lyricsContainer)
}
}
function setLyrics(lyricsContainer){
lyricsContainer.innerHTML = `<div id="contents" class="style-scope ytmusic-section-list-renderer description ytmusic-description-shelf-renderer genius-lyrics">
${lyrics}
<yt-formatted-string class="footer style-scope ytmusic-description-shelf-renderer">Source&nbsp;: Genius</yt-formatted-string>
</div>`;
tabs.lyrics.removeAttribute("disabled");
tabs.lyrics.removeAttribute("aria-disabled");
}
});
};

View File

@ -9,7 +9,4 @@
#contents.genius-lyrics, .description {
font-size: 1.1vw !important;
text-align: center !important;
line-height: 1.4;
font-family: Roboto,Noto Naskh Arabic UI,Arial,sans-serif;
font-weight: 400;
}