diff options
Diffstat (limited to 'unhook.js')
| -rw-r--r-- | unhook.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/unhook.js b/unhook.js new file mode 100644 index 0000000..05c073f --- /dev/null +++ b/unhook.js @@ -0,0 +1,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(); +}); |
