diff --git a/background.js b/background.js deleted file mode 100644 index 68de4fa..0000000 --- a/background.js +++ /dev/null @@ -1,47 +0,0 @@ -/* eslint-disable no-undef */ -// https://stackoverflow.com/a/45985333 -function getBrowser() { - if (typeof chrome !== "undefined") { - if (typeof browser !== "undefined") { - return "Firefox"; - } else { - return "Chrome"; - } - } else { - return "Edge"; - } -} - -chrome.webRequest.onBeforeRequest.addListener( - function (details) { - if (getBrowser() == "Chrome") { - return { redirectUrl: chrome.runtime.getURL("cadmium-playercore-shim.js") }; - } - - /* Work around funky CORS behaviour on Firefox */ - else if (getBrowser() == "Firefox") { - let filter = browser.webRequest.filterResponseData(details.requestId); - let encoder = new TextEncoder(); - filter.onstop = () => { - fetch(browser.runtime.getURL("cadmium-playercore-shim.js")). - then(response => response.text()). - then(text => { - filter.write(encoder.encode(text)); - filter.close(); - }); - }; - return {}; - } - - else { - console.error("Unsupported web browser."); - return {}; - } - }, { - urls: [ - "*://assets.nflxext.com/*/ffe/player/html/*", - "*://assets.nflxext.com/player/html/ffe/*" - ], - types: ["script"] - }, ["blocking"] -); diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index a6e9fcc..2cfef06 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -41,7 +41,7 @@ function do_patch(desc, needle, replacement) { the response before the body of this script finishes executing */ var request = new XMLHttpRequest(); var cadmium_url = document.getElementById("player-core-js").src; -request.open("GET", cadmium_url + "?no_filter", false); // synchronous +request.open("GET", cadmium_url, false); // synchronous request.send(); var cadmium_src = request.responseText; diff --git a/manifest.json b/manifest.json index 9bf12fa..ff4ef89 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.22", + "version": "2.0.23", "author": "shirt", - "browser_action": { + "action": { "default_icon": "img/icon128.png", "default_popup": "pages/options.html" }, @@ -19,7 +19,6 @@ }, "content_scripts": [{ "matches": [ - "*://assets.nflxext.com/*", "*://netflix.com/*", "*://www.netflix.com/*" ], @@ -28,22 +27,34 @@ "js": ["content_script.js"], "run_at": "document_start" }], - "background": { - "scripts": ["background.js"] - }, "options_ui": { "page": "pages/options.html", "open_in_tab": true }, - "web_accessible_resources": [ - "cadmium-playercore-shim.js", - "netflix_max_bitrate.js", - "netflix.css" - ], + "web_accessible_resources": [{ + "resources": [ + "cadmium-playercore-shim.js", + "netflix_max_bitrate.js", + "netflix.css" + ], + "matches": [ + "*://assets.nflxext.com/*", + "*://netflix.com/*", + "*://www.netflix.com/*" + ] + }], + "declarative_net_request" : { + "rule_resources" : [{ + "id": "1", + "enabled": true, + "path": "rules.json" + }] + }, "permissions": [ "storage", - "webRequest", - "webRequestBlocking", + "declarativeNetRequestWithHostAccess" + ], + "host_permissions": [ "*://assets.nflxext.com/*", "*://netflix.com/*", "*://www.netflix.com/*" diff --git a/rules.json b/rules.json new file mode 100644 index 0000000..a948a65 --- /dev/null +++ b/rules.json @@ -0,0 +1,26 @@ +[ + { + "id": 1, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { "extensionPath": "/cadmium-playercore-shim.js" } + }, + "condition": { + "urlFilter": "*://assets.nflxext.com/*/ffe/player/html/*", + "resourceTypes": ["script"] + } + }, + { + "id": 2, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { "extensionPath": "/cadmium-playercore-shim.js" } + }, + "condition": { + "urlFilter": "*://assets.nflxext.com/player/html/ffe/*", + "resourceTypes": ["script"] + } + } +]