blob: 05c073fe873d6d44dc1b016e22478d95052a110d (
plain)
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
|
// Single stylesheet for all hiding rules
let styleElement = null;
function applyStyles(settings) {
if (!styleElement) {
styleElement = document.createElement('style');
styleElement.id = 'unhook-styles';
document.head.appendChild(styleElement);
}
const rules = [];
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; }');
if (settings.hidePlaylist) rules.push('#playlist { display: none !important; }');
if (settings.hideFundraiser) rules.push('#donation-shelf { display: none !important; }');
styleElement.textContent = rules.join('\n');
}
async function main() {
const settings = await browser.storage.local.get(null);
applyStyles(settings);
}
// Content scripts run after DOM is ready by default, so call main directly
main();
// Listen for storage changes and reapply all settings
browser.storage.onChanged.addListener(() => {
main();
});
|