diff --git a/FreeYT Extension/Resources/background.js b/FreeYT Extension/Resources/background.js index ee13f34..2a838d5 100644 --- a/FreeYT Extension/Resources/background.js +++ b/FreeYT Extension/Resources/background.js @@ -86,8 +86,8 @@ async function updateBadge() { if (chrome.declarativeNetRequest?.onRuleMatchedDebug) { chrome.declarativeNetRequest.onRuleMatchedDebug.addListener(async (info) => { try { - // Count only our redirect rules (1,2,3) - if ([1, 2, 3].includes(info?.rule?.ruleId)) { + // Count only our redirect rules (1-5) + if ([1, 2, 3, 4, 5].includes(info?.rule?.ruleId)) { await incrementRedirectCounter(); // Notify popup (if open) const ping = chrome.runtime.sendMessage({ type: "statsUpdated" }); diff --git a/FreeYT Extension/Resources/manifest.json b/FreeYT Extension/Resources/manifest.json index bccbbee..738c2cc 100644 --- a/FreeYT Extension/Resources/manifest.json +++ b/FreeYT Extension/Resources/manifest.json @@ -10,8 +10,7 @@ ], "host_permissions": [ "*://*.youtube.com/*", - "*://youtu.be/*", - "*://yout-ube.com/*" + "*://youtu.be/*" ], "icons": { "48": "images/icon-48.png", diff --git a/FreeYT Extension/Resources/rules.json b/FreeYT Extension/Resources/rules.json index c911859..23a3591 100644 --- a/FreeYT Extension/Resources/rules.json +++ b/FreeYT Extension/Resources/rules.json @@ -4,10 +4,12 @@ "priority": 1, "action": { "type": "redirect", - "redirect": { "regexSubstitution": "https://yout-ube.com/\\2" } + "redirect": { + "regexSubstitution": "https://www.youtube-nocookie.com/embed/\\1" + } }, "condition": { - "regexFilter": "^https?://([a-z0-9-]+\\.)?youtube\\.com/(.*)$", + "regexFilter": "^https?://(?:[a-z0-9-]+\\.)?youtube\\.com/watch\\?[^#]*v=([\\w-]{11})(?:[&#].*)?$", "resourceTypes": ["main_frame", "sub_frame"] } }, @@ -16,10 +18,12 @@ "priority": 1, "action": { "type": "redirect", - "redirect": { "regexSubstitution": "https://yout-ube.com/watch?v=\\1&\\2" } + "redirect": { + "regexSubstitution": "https://www.youtube-nocookie.com/embed/\\1" + } }, "condition": { - "regexFilter": "^https?://youtu\\.be/([\\w-]{11})\\?(.*)$", + "regexFilter": "^https?://(?:[a-z0-9-]+\\.)?youtube\\.com/shorts/([\\w-]{11})(?:\\?[^#]*)?$", "resourceTypes": ["main_frame", "sub_frame"] } }, @@ -28,10 +32,40 @@ "priority": 1, "action": { "type": "redirect", - "redirect": { "regexSubstitution": "https://yout-ube.com/watch?v=\\1" } + "redirect": { + "regexSubstitution": "https://www.youtube-nocookie.com/embed/\\1" + } }, "condition": { - "regexFilter": "^https?://youtu\\.be/([\\w-]{11})$", + "regexFilter": "^https?://youtu\\.be/([\\w-]{11})(?:\\?[^#]*)?$", + "resourceTypes": ["main_frame", "sub_frame"] + } + }, + { + "id": 4, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { + "regexSubstitution": "https://www.youtube-nocookie.com/embed/\\1" + } + }, + "condition": { + "regexFilter": "^https?://(?:[a-z0-9-]+\\.)?youtube\\.com/embed/([\\w-]{11})(?:\\?[^#]*)?$", + "resourceTypes": ["main_frame", "sub_frame"] + } + }, + { + "id": 5, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { + "regexSubstitution": "https://www.youtube-nocookie.com/embed/\\1" + } + }, + "condition": { + "regexFilter": "^https?://(?:[a-z0-9-]+\\.)?youtube\\.com/live/([\\w-]{11})(?:\\?[^#]*)?$", "resourceTypes": ["main_frame", "sub_frame"] } } diff --git a/README.md b/README.md index c9db8d0..1756a77 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,15 @@ FreeYT/ Defines extension permissions, background worker, toolbar action, and declarativeNetRequest rules. ### rules.json -Contains regex patterns for matching and redirecting YouTube URLs. All redirect rules use priority 1 and apply to youtube.com domains. +Implements the declarativeNetRequest redirects that make the extension useful. The five rules cover the most common YouTube entry points and convert them to their privacy-respecting embeds on `youtube-nocookie.com`: + +1. `youtube.com/watch` (including `m.youtube.com`) → `https://www.youtube-nocookie.com/embed/` +2. `youtube.com/shorts/` → `https://www.youtube-nocookie.com/embed/` +3. `youtu.be/` → `https://www.youtube-nocookie.com/embed/` +4. `youtube.com/embed/` → `https://www.youtube-nocookie.com/embed/` (ensures existing embeds shed tracking cookies) +5. `youtube.com/live/` → `https://www.youtube-nocookie.com/embed/` + +All rules target both `main_frame` and `sub_frame` resource types so that navigation, links, and inline iframes receive the same privacy upgrade. ### background.js Service worker that: