From a2f267b080ef775ea62a5f32a547612aa482f009 Mon Sep 17 00:00:00 2001 From: TheArchons Date: Mon, 26 Jan 2026 15:09:56 -0500 Subject: Add initial implementation of Unhook NG extension with manifest, popup, and content scripts --- manifest.json | 36 +++++++++++++ popup.html | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ popup.js | 48 +++++++++++++++++ unhook.js | 34 ++++++++++++ 4 files changed, 284 insertions(+) create mode 100644 manifest.json create mode 100644 popup.html create mode 100644 popup.js create mode 100644 unhook.js diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..4554270 --- /dev/null +++ b/manifest.json @@ -0,0 +1,36 @@ +{ + "manifest_version": 2, + "name": "Unhook NG", + "version": "1", + + "description": "New version of Unhook. Block Youtube Distractions.", + + "icons": { + "48": "icons/unhook.jpg" + }, + + "permissions": [ + "storage" + ], + + "browser_action": { + "default_icon": "icons/unhook.jpg", + "default_title": "Unhook NG", + "default_popup": "popup.html" + }, + + "content_scripts": [ + { + "matches": ["*://*.youtube.com/*"], + "js": ["unhook.js"] + } + ], + "browser_specific_settings": { + "gecko": { + "id": "@unhookng", + "data_collection_permissions": { + "required": ["none"] + } + } + } +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..e6b4ed4 --- /dev/null +++ b/popup.html @@ -0,0 +1,166 @@ + + + + + + + +

Unhook NG

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..816f785 --- /dev/null +++ b/popup.js @@ -0,0 +1,48 @@ +const toggles = [ + 'hideHomeFeed', + 'hideVideoSidebar', + 'hideRecommended', + 'hideLiveChat', + 'hidePlaylist', + 'hideFundraiser', + 'hideEndScreenFeed', + 'hideEndScreenCards', + 'hideShorts', + 'hideComments', + 'hideProfilePhotos', + 'hideMixes', + 'hideMerchTickets', + 'hideVideoInfo', + 'hideButtonsBar', + 'hideChannel', + 'hideDescription', + 'hideTopHeader', + 'hideNotifications', + 'hideInaptSearch', + 'hideExploreTrending', + 'hideMoreFromYT', + 'hideSubscriptions', + 'disableAutoplay', + 'disableAnnotations' +]; + +// Load saved settings +browser.storage.local.get(toggles).then((result) => { + toggles.forEach((id) => { + const checkbox = document.getElementById(id); + if (checkbox) { + checkbox.checked = result[id] !== false; + } + }); +}); + +// Save settings on change +document.addEventListener('change', (e) => { + if (e.target.type !== 'checkbox') return; + + const id = e.target.id; + const checked = e.target.checked; + const settings = { [id]: checked }; + + browser.storage.local.set(settings); +}); 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(); +}); -- cgit v1.3.1