aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest.json2
-rw-r--r--unhook.js14
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');
}