aboutsummaryrefslogtreecommitdiff
path: root/unhook.js
diff options
context:
space:
mode:
authorAlexander Li <github@thearchons.xyz>2026-03-22 19:12:03 -0400
committerGitHub <noreply@github.com>2026-03-22 19:12:03 -0400
commit07d2407d876f4c6cc274ef01d1130b0d80ed553e (patch)
tree622068898251d2bcfd703797d90ca45de66f522c /unhook.js
parent78271568ac082ffab8239cf5c0ff06590e13d85d (diff)
Update manifest to version 3 and improve popup checkbox functionality (#2)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'unhook.js')
-rw-r--r--unhook.js14
1 files changed, 11 insertions, 3 deletions
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');
}