-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathunhook.js
More file actions
122 lines (116 loc) · 3.61 KB
/
Copy pathunhook.js
File metadata and controls
122 lines (116 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// ═══════════════════════════════════
// superlevels: YouTube Unhook
// Based on remove-youtube-suggestions
// ═══════════════════════════════════
(() => {
const STYLE_ID = "sl-unhook";
const FEATURE_CSS = {
homepage: `
/* Homepage: hide feed entirely */
ytd-browse[page-subtype="home"] #contents.ytd-rich-grid-renderer,
ytd-browse[page-subtype="home"] ytd-rich-grid-renderer,
ytd-browse[page-subtype="home"] #primary > ytd-rich-grid-renderer,
ytd-browse[page-subtype="home"] ytd-rich-section-list-renderer,
ytd-browse[page-subtype="home"] #header,
ytd-browse[page-subtype="home"] .ytd-browse-chips-wrapper {
display: none !important;
}
/* Black homepage background with message */
ytd-browse[page-subtype="home"] #primary {
display: flex !important;
justify-content: center;
align-items: center;
min-height: 60vh;
}
ytd-browse[page-subtype="home"] #primary::before {
content: 'Focus Mode — Use the search bar';
font-size: 20px;
color: #444;
font-family: 'YouTube Sans', 'Roboto', sans-serif;
font-weight: 500;
}
/* Trending / Explore feed */
ytd-browse[page-subtype="trending"] #contents {
display: none !important;
}
/* Homepage chips / categories bar */
#chips-wrapper.ytd-feed-filter-chip-bar-renderer,
ytd-feed-filter-chip-bar-renderer {
display: none !important;
}
`,
sidebar: `
/* Sidebar suggestions on video pages */
#secondary.ytd-watch-flexy,
ytd-watch-next-secondary-results-renderer,
#related {
display: none !important;
}
/* "For You" / recommendation shelves */
ytd-rich-shelf-renderer {
display: none !important;
}
`,
endscreen: `
/* End screen suggestions & cards */
.ytp-ce-element,
.ytp-endscreen-content,
.ytp-suggestion-set,
.ytp-cards-teaser,
.ytp-ce-covering-overlay,
.ytp-ce-element-show {
display: none !important;
}
`,
shorts: `
/* Shorts shelf */
ytd-rich-shelf-renderer[is-shorts],
ytd-reel-shelf-renderer {
display: none !important;
}
`,
wider: `
/* Make video player wider without sidebar */
ytd-watch-flexy[flexy][is-two-columns_] #primary.ytd-watch-flexy {
max-width: 100% !important;
}
`,
};
const DEFAULT_FEATURES = {
homepage: true,
sidebar: true,
endscreen: true,
shorts: true,
wider: true,
};
function buildCSS(features) {
return Object.keys(FEATURE_CSS)
.filter((key) => features[key] !== false)
.map((key) => FEATURE_CSS[key])
.join("\n");
}
function apply(enabled, features) {
const existing = document.getElementById(STYLE_ID);
if (!enabled) {
if (existing) existing.remove();
return;
}
const css = buildCSS(features || DEFAULT_FEATURES);
if (existing) {
existing.textContent = css;
return;
}
const style = document.createElement("style");
style.id = STYLE_ID;
style.textContent = css;
(document.head || document.documentElement).appendChild(style);
}
chrome.storage.local.get(["unhook_enabled", "unhook_features"], (data) => {
apply(data.unhook_enabled !== false, data.unhook_features);
});
chrome.runtime.onMessage.addListener((msg) => {
if (msg.type === "unhook_toggle") {
apply(msg.enabled, msg.features);
}
});
})();