diff options
| author | Alexander Li <github@thearchons.xyz> | 2026-01-26 18:48:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-26 18:48:53 -0500 |
| commit | 78271568ac082ffab8239cf5c0ff06590e13d85d (patch) | |
| tree | f6bbf7a3414e9a84705bcb14ce918d9cd57736a2 | |
| parent | a4548634f185bbaa277d781f8c7cc664d10f0b28 (diff) | |
Update manifest to version 3 and improve popup checkbox functionality (#1)
Update manifest to version 3 and improve popup checkbox functionality
| -rw-r--r-- | manifest.json | 6 | ||||
| -rw-r--r-- | popup.html | 44 | ||||
| -rw-r--r-- | popup.js | 8 | ||||
| -rw-r--r-- | unhook.js | 8 |
4 files changed, 36 insertions, 30 deletions
diff --git a/manifest.json b/manifest.json index 5da8e94..fd62545 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "Unhook NG", - "version": "1", + "version": "1.1", "description": "Hide YouTube related videos, shorts, comments, suggestions wall, homepage recommendations, trending, and other distractions.", @@ -13,7 +13,7 @@ "storage" ], - "browser_action": { + "action": { "default_icon": "icons/unhook.png", "default_title": "Unhook NG", "default_popup": "popup.html" @@ -46,102 +46,102 @@ <h3>Unhook NG</h3> <label> - <input type="checkbox" id="hideHomeFeed" checked> + <input type="checkbox" id="hideHomeFeed"> Hide Home Feed </label> <label class="sub"> - <input type="checkbox" id="redirectToSubscriptions" checked> + <input type="checkbox" id="redirectToSubscriptions"> Redirect To Subscriptions </label> <label> - <input type="checkbox" id="hideVideoSidebar" checked> + <input type="checkbox" id="hideVideoSidebar"> Hide Video Sidebar </label> <label class="sub"> - <input type="checkbox" id="hideRecommended" checked> + <input type="checkbox" id="hideRecommended"> Hide Recommended </label> <label class="sub"> - <input type="checkbox" id="hideLiveChat" checked> + <input type="checkbox" id="hideLiveChat"> Hide Live Chat </label> <label class="sub"> - <input type="checkbox" id="hidePlaylist" checked> + <input type="checkbox" id="hidePlaylist"> Hide Playlist </label> <label class="sub"> - <input type="checkbox" id="hideFundraiser" checked> + <input type="checkbox" id="hideFundraiser"> Hide Fundraiser </label> <label> - <input type="checkbox" id="hideEndScreenCards" checked> + <input type="checkbox" id="hideEndScreenCards"> Hide End Screen Cards </label> <label> - <input type="checkbox" id="hideShorts" checked> + <input type="checkbox" id="hideShorts"> Hide Shorts </label> <label> - <input type="checkbox" id="hideComments" checked> + <input type="checkbox" id="hideComments"> Hide Comments </label> <label class="sub"> - <input type="checkbox" id="hideProfilePhotos" checked> + <input type="checkbox" id="hideProfilePhotos"> Hide Profile Photos </label> <label> - <input type="checkbox" id="hideMixes" checked> + <input type="checkbox" id="hideMixes"> Hide Mixes </label> <label> - <input type="checkbox" id="hideMerch" checked> + <input type="checkbox" id="hideMerch"> Hide Merch </label> <label> - <input type="checkbox" id="hideVideoInfo" checked> + <input type="checkbox" id="hideVideoInfo"> Hide Video Info </label> <label class="sub"> - <input type="checkbox" id="hideButtonsBar" checked> + <input type="checkbox" id="hideButtonsBar"> Hide Buttons Bar </label> <label class="sub"> - <input type="checkbox" id="hideChannel" checked> + <input type="checkbox" id="hideChannel"> Hide Channel </label> <label class="sub"> - <input type="checkbox" id="hideDescription" checked> + <input type="checkbox" id="hideDescription"> Hide Description </label> <label> - <input type="checkbox" id="hideTopHeader" checked> + <input type="checkbox" id="hideTopHeader"> Hide Top Header </label> <label class="sub"> - <input type="checkbox" id="hideNotifications" checked> + <input type="checkbox" id="hideNotifications"> Hide Notifications </label> <label> - <input type="checkbox" id="hideExplore" checked> + <input type="checkbox" id="hideExplore"> Hide Explore </label> <label> - <input type="checkbox" id="hideMoreFromYT" checked> + <input type="checkbox" id="hideMoreFromYT"> Hide More from YouTube </label> <label> - <input type="checkbox" id="hideSubscriptions" checked> + <input type="checkbox" id="hideSubscriptions"> Hide Subscriptions </label> @@ -1,3 +1,5 @@ +const browserAPI = globalThis.browser || globalThis.chrome; + const toggles = [ 'hideHomeFeed', 'redirectToSubscriptions', @@ -24,11 +26,11 @@ const toggles = [ ]; // Load saved settings -browser.storage.local.get(toggles).then((result) => { +browserAPI.storage.local.get(toggles).then((result) => { toggles.forEach((id) => { const checkbox = document.getElementById(id); if (checkbox) { - checkbox.checked = result[id] !== false; + checkbox.checked = result[id] === true; } }); }); @@ -41,5 +43,5 @@ document.addEventListener('change', (e) => { const checked = e.target.checked; const settings = { [id]: checked }; - browser.storage.local.set(settings); + browserAPI.storage.local.set(settings); }); @@ -1,3 +1,6 @@ +// Chrome/Firefox compatibility +const browserAPI = globalThis.browser || globalThis.chrome; + // Single stylesheet for all hiding rules let styleElement = null; @@ -56,7 +59,8 @@ function applyStyles(settings) { } async function main() { - const settings = await browser.storage.local.get(null); + // Chrome/Firefox compatibility + const settings = await browserAPI.storage.local.get(null); applyStyles(settings); } @@ -64,7 +68,7 @@ async function main() { main(); // Listen for storage changes and reapply all settings -browser.storage.onChanged.addListener(() => { +browserAPI.storage.onChanged.addListener(() => { main(); }); |
