Skip to content

Commit

Permalink
fix: detect the upgrade btn using the icon (#2364)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjixWasTaken authored Aug 22, 2024
1 parent b12e2f6 commit c5c1914
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c5c1914

Please sign in to comment.