From 07d2407d876f4c6cc274ef01d1130b0d80ed553e Mon Sep 17 00:00:00 2001 From: Alexander Li Date: Sun, 22 Mar 2026 19:12:03 -0400 Subject: Update manifest to version 3 and improve popup checkbox functionality (#2) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- manifest.json | 2 +- unhook.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index fd62545..210039c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Unhook NG", - "version": "1.1", + "version": "1.2", "description": "Hide YouTube related videos, shorts, comments, suggestions wall, homepage recommendations, trending, and other distractions.", diff --git a/unhook.js b/unhook.js index 1eb60df..5fe1d58 100644 --- a/unhook.js +++ b/unhook.js @@ -5,9 +5,10 @@ const browserAPI = globalThis.browser || globalThis.chrome; let styleElement = null; function applyStyles(settings) { + const path = window.location.pathname; + // Redirect homepage to subscriptions if (settings.redirectToSubscriptions) { - const path = window.location.pathname; if (path === '/' || path === '/feed/trending') { window.location.replace('https://www.youtube.com/feed/subscriptions'); return; @@ -22,7 +23,7 @@ function applyStyles(settings) { const rules = []; - if (settings.hideHomeFeed) rules.push('ytd-rich-grid-renderer { display: none !important; }'); + if (settings.hideHomeFeed && path === '/') rules.push('ytd-rich-grid-renderer { display: none !important; }'); if (settings.hideVideoSidebar) rules.push('#secondary { display: none !important; }'); if (settings.hideRecommended) rules.push('#related { display: none !important; }'); if (settings.hideLiveChat) rules.push('#chat-container { display: none !important; }'); @@ -53,7 +54,14 @@ function applyStyles(settings) { if (settings.hideMoreFromYT) rules.push('ytd-guide-section-renderer:has(a[title="YouTube Premium"]) { display: none !important; }'); // same as hideExplore but instead we only find sections with Subscriptions - if (settings.hideSubscriptions) rules.push('ytd-guide-section-renderer:has(a[title="Subscriptions"]) { display: none !important; }'); + if (settings.hideSubscriptions) { + // the not is because sometimes youtube puts subscriptions in a section with all the other links, so we don't want to hide that but instead we want to rely on the second rule + rules.push('ytd-guide-section-renderer:has(a#endpoint[title="Subscriptions"]):not(:has(a#endpoint[title="Home"])) { display: none !important; }'); + rules.push('a#endpoint[title="Subscriptions"] { display: none !important; }'); + if (path == '/feed/subscriptions') { + rules.push('ytd-rich-grid-renderer { display: none !important; }'); + } + } styleElement.textContent = rules.join('\n'); } -- cgit v1.3.1