fix: detect the upgrade btn using the icon (#2364)

This commit is contained in:
Angelos Bouklis
2024-08-23 01:13:55 +03:00
committed by GitHub
parent b12e2f607c
commit c5c191492e

View File

@ -172,10 +172,19 @@ async function onApiLoaded() {
// Remove upgrade button
if (window.mainConfig.get('options.removeUpgradeButton')) {
const itemsSelector = 'ytmusic-guide-section-renderer #items';
let selector = 'ytmusic-guide-entry-renderer:last-child';
const upgradeBtnIcon = document.querySelector<SVGGElement>('iron-iconset-svg[name="yt-sys-icons"] #youtube_music_monochrome');
if (upgradeBtnIcon) {
const path = upgradeBtnIcon.firstChild as SVGPathElement;
const data = path.getAttribute('d')!.substring(0, 15);
selector = `ytmusic-guide-entry-renderer:has(> tp-yt-paper-item > yt-icon path[d^="${data}"])`;
}
const styles = document.createElement('style');
styles.innerHTML = `ytmusic-guide-section-renderer #items ytmusic-guide-entry-renderer:last-child {
display: none;
}`;
styles.textContent = `${itemsSelector} ${selector} { display: none; }`;
document.head.appendChild(styles);
}