mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
change to new lyrics even if lyrics tab was already selected
This commit is contained in:
@ -50,22 +50,12 @@ module.exports = () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkLyricsContainer();
|
||||||
|
|
||||||
tabs.lyrics.onclick = () => {
|
tabs.lyrics.onclick = () => {
|
||||||
const tabContainer = document.querySelector("ytmusic-tab-renderer");
|
const tabContainer = document.querySelector("ytmusic-tab-renderer");
|
||||||
const observer = new MutationObserver((_, observer) => {
|
const observer = new MutationObserver((_, observer) => {
|
||||||
const lyricsContainer = document.querySelector(
|
checkLyricsContainer(() => observer.disconnect());
|
||||||
'[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 : Genius</yt-formatted-string>
|
|
||||||
</div>`;
|
|
||||||
tabs.lyrics.removeAttribute("disabled");
|
|
||||||
tabs.lyrics.removeAttribute("aria-disabled");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
observer.observe(tabContainer, {
|
observer.observe(tabContainer, {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
@ -73,5 +63,25 @@ module.exports = () => {
|
|||||||
subtree: true,
|
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 : Genius</yt-formatted-string>
|
||||||
|
</div>`;
|
||||||
|
tabs.lyrics.removeAttribute("disabled");
|
||||||
|
tabs.lyrics.removeAttribute("aria-disabled");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,7 +9,4 @@
|
|||||||
#contents.genius-lyrics, .description {
|
#contents.genius-lyrics, .description {
|
||||||
font-size: 1.1vw !important;
|
font-size: 1.1vw !important;
|
||||||
text-align: center !important;
|
text-align: center !important;
|
||||||
line-height: 1.4;
|
|
||||||
font-family: Roboto,Noto Naskh Arabic UI,Arial,sans-serif;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user