From 78271568ac082ffab8239cf5c0ff06590e13d85d Mon Sep 17 00:00:00 2001 From: Alexander Li Date: Mon, 26 Jan 2026 18:48:53 -0500 Subject: Update manifest to version 3 and improve popup checkbox functionality (#1) Update manifest to version 3 and improve popup checkbox functionality --- manifest.json | 6 +++--- popup.html | 44 ++++++++++++++++++++++---------------------- popup.js | 8 +++++--- 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" diff --git a/popup.html b/popup.html index 86b28d3..2845235 100644 --- a/popup.html +++ b/popup.html @@ -46,102 +46,102 @@

Unhook NG

diff --git a/popup.js b/popup.js index fd60ad0..756d1a0 100644 --- a/popup.js +++ b/popup.js @@ -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); }); diff --git a/unhook.js b/unhook.js index 4e2066a..1eb60df 100644 --- a/unhook.js +++ b/unhook.js @@ -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(); }); -- cgit v1.3.1