From a4bc5f94cd941f162158c61a9c3069fff4c82d30 Mon Sep 17 00:00:00 2001 From: shirt Date: Wed, 28 Sep 2022 21:35:25 -0400 Subject: [PATCH 01/14] Remove AV1 support For some reason, AV1 video seems to be missing the Netflix dubbing credits --- cadmium-playercore-shim.js | 8 -------- manifest.json | 2 +- pages/options.html | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index f409fdf..cdcc5fd 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -94,14 +94,6 @@ function get_profile_list() { "vp9-profile0-L31-dash-cenc", "vp9-profile0-L40-dash-cenc", ]); - - if (getBrowser() == "Chrome") { - custom_profiles = custom_profiles.concat([ - "av1-main-L30-dash-cbcs-prk", - "av1-main-L31-dash-cbcs-prk", - "av1-main-L40-dash-cbcs-prk", - ]); - } } custom_profiles = custom_profiles.concat([ diff --git a/manifest.json b/manifest.json index c14f974..5a49433 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.14", + "version": "2.0.15", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", diff --git a/pages/options.html b/pages/options.html index 56c9f1a..5bf7140 100644 --- a/pages/options.html +++ b/pages/options.html @@ -17,7 +17,7 @@

- +

From 0c6844c4bb325b4a1c2908859b525aa568ebe998 Mon Sep 17 00:00:00 2001 From: shirt <2660574+shirt-dev@users.noreply.github.com> Date: Sun, 9 Oct 2022 12:22:13 -0400 Subject: [PATCH 02/14] Rework profile selection --- cadmium-playercore-shim.js | 125 +++++++++++++++++-------------------- content_script.js | 1 + manifest.json | 2 +- pages/options.html | 2 + pages/options.js | 6 ++ 5 files changed, 68 insertions(+), 68 deletions(-) diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index cdcc5fd..e869cc7 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -39,86 +39,77 @@ request.send(); var cadmium_src = request.responseText; // eslint-disable-next-line no-unused-vars -function get_profile_list() { +function get_profile_list(original_profiles) { + var profiles = original_profiles; // Always add h264 main profiles - var custom_profiles = [ - "playready-h264mpl30-dash", - "playready-h264mpl31-dash", - "playready-h264mpl40-dash", - ]; - - if (window.MSMediaKeys) { - // PlayReady Specific - - // Always add 2.0 AAC profiles, some manifests fail without them - custom_profiles = custom_profiles.concat([ - "heaac-2-dash", - "heaac-2hq-dash", + if (original_profiles.includes("playready-h264mpl30-dash")) { + profiles = profiles.concat([ + "playready-h264mpl30-dash", + "playready-h264mpl31-dash", + "playready-h264mpl40-dash", ]); + } - if (globalOptions.useDDPlus) { - // Dolby Digital - custom_profiles = custom_profiles.concat([ - "ddplus-2.0-dash", - ]); - - if (globalOptions.use6Channels) { - custom_profiles = custom_profiles.concat([ - "ddplus-5.1-dash", - "ddplus-5.1hq-dash", - "ddplus-atmos-dash", - ]); - } - } else { - // No Dolby Digital - if (globalOptions.use6Channels) { - custom_profiles = custom_profiles.concat([ - "heaac-5.1-dash", - ]); - } - } - - - } else { - // Widevine Specific - custom_profiles = custom_profiles.concat([ + if (original_profiles.includes("playready-h264hpl30-dash")) { + profiles = profiles.concat([ "playready-h264hpl30-dash", "playready-h264hpl31-dash", "playready-h264hpl40-dash", ]); + } - if (!globalOptions.disableVP9) { - // Add VP9 Profiles if wanted - custom_profiles = custom_profiles.concat([ - "vp9-profile0-L30-dash-cenc", - "vp9-profile0-L31-dash-cenc", - "vp9-profile0-L40-dash-cenc", - ]); - } + if (original_profiles.includes("h264hpl30-dash-playready-live")) { + profiles = profiles.concat([ + "h264hpl30-dash-playready-live", + "h264hpl31-dash-playready-live", + "h264hpl40-dash-playready-live", + ]); + } - custom_profiles = custom_profiles.concat([ - "heaac-2-dash", - "heaac-2hq-dash", + if (!globalOptions.disableVP9 && original_profiles.includes("vp9-profile0-L30-dash-cenc")) { + profiles = profiles.concat([ + "vp9-profile0-L30-dash-cenc", + "vp9-profile0-L31-dash-cenc", + "vp9-profile0-L40-dash-cenc", + ]); + } else { + profiles = profiles.filter(val => !val.includes("vp9-")); + } + + if (!globalOptions.disableAV1 && original_profiles.includes("av1-main-L30-dash-cbcs-prk")) { + profiles = profiles.concat([ + "av1-main-L30-dash-cbcs-prk", + "av1-main-L31-dash-cbcs-prk", + "av1-main-L40-dash-cbcs-prk", + ]); + } else { + profiles = profiles.filter(val => !val.includes("av1-")); + } + + if (globalOptions.useDDPlus && MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { + // Dolby Digital + profiles = profiles.concat([ + "ddplus-2.0-dash", ]); if (globalOptions.use6Channels) { - custom_profiles = custom_profiles.concat([ + profiles = profiles.concat([ + "ddplus-5.1-dash", + "ddplus-5.1hq-dash", + "ddplus-atmos-dash", + ]); + } + } else { + // No Dolby Digital + if (globalOptions.use6Channels) { + profiles = profiles.concat([ "heaac-5.1-dash", ]); } } - // Always add subtitles - custom_profiles = custom_profiles.concat([ - "dfxp-ls-sdh", - "simplesdh", - "nflx-cmisc", - "imsc1.1", - "BIF240", - "BIF320", - ]); - - return custom_profiles; + profiles = [...new Set(profiles)].sort(); + return profiles; } // eslint-disable-next-line no-unused-vars @@ -139,14 +130,14 @@ do_patch( do_patch( "Custom profiles", - /(viewableId:.,profiles:).,/, - "$1 get_profile_list()," + /(viewableId:.,profiles:)(.),/, + "$1 get_profile_list($2)," ); do_patch( "Custom profiles 2", - /(name:"default",profiles:).}/, - "$1 get_profile_list()}" + /(name:"default",profiles:)(.)}/, + "$1 get_profile_list($2)}" ); do_patch( diff --git a/content_script.js b/content_script.js index 7e54d78..d6ed47b 100644 --- a/content_script.js +++ b/content_script.js @@ -46,6 +46,7 @@ chromeStorageGet({ showAllTracks: true, setMaxBitrate: false, disableVP9: false, + disableAV1: true, useDDPlus: false, preferredLocale: null, preferredTextLocale: null, diff --git a/manifest.json b/manifest.json index 5a49433..ab66991 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.15", + "version": "2.0.16", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", diff --git a/pages/options.html b/pages/options.html index 5bf7140..6f1598f 100644 --- a/pages/options.html +++ b/pages/options.html @@ -19,6 +19,8 @@

+ +

diff --git a/pages/options.js b/pages/options.js index 55d2ad5..9f4498c 100644 --- a/pages/options.js +++ b/pages/options.js @@ -4,6 +4,7 @@ function save_options() { const showAllTracks = document.getElementById("showAllTracks").checked; const setMaxBitrate = document.getElementById("setMaxBitrate").checked; const disableVP9 = document.getElementById("disableVP9").checked; + const disableAV1 = document.getElementById("disableAV1").checked; const useDDPlus = document.getElementById("useDDPlus").checked; const preferredLocale = document.getElementById("preferredLocale").value; const preferredTextLocale = document.getElementById("preferredTextLocale").value; @@ -13,6 +14,7 @@ function save_options() { showAllTracks: showAllTracks, setMaxBitrate: setMaxBitrate, disableVP9: disableVP9, + disableAV1: disableAV1, useDDPlus: useDDPlus, preferredLocale: preferredLocale, preferredTextLocale: preferredTextLocale, @@ -30,6 +32,7 @@ function reset_options() { document.getElementById("showAllTracks").checked = true; document.getElementById("setMaxBitrate").checked = false; document.getElementById("disableVP9").checked = false; + document.getElementById("disableAV1").checked = true; document.getElementById("useDDPlus").checked = false; document.getElementById("preferredLocale").value = null; document.getElementById("preferredTextLocale").value = null; @@ -39,6 +42,7 @@ function reset_options() { showAllTracks: true, setMaxBitrate: false, disableVP9: false, + disableAV1: true, useDDPlus: false, preferredLocale: null, preferredTextLocale: null, @@ -57,6 +61,7 @@ function restore_options() { showAllTracks: true, setMaxBitrate: false, disableVP9: false, + disableAV1: true, useDDPlus: false, preferredLocale: null, preferredTextLocale: null, @@ -65,6 +70,7 @@ function restore_options() { document.getElementById("showAllTracks").checked = items.showAllTracks; document.getElementById("setMaxBitrate").checked = items.setMaxBitrate; document.getElementById("disableVP9").checked = items.disableVP9; + document.getElementById("disableAV1").checked = items.disableAV1; document.getElementById("useDDPlus").checked = items.useDDPlus; document.getElementById("preferredLocale").value = items.preferredLocale; document.getElementById("preferredTextLocale").value = items.preferredTextLocale; From 96856b02e04aac36141a526daf8f9bfa1f325060 Mon Sep 17 00:00:00 2001 From: shirt Date: Mon, 16 Jan 2023 18:40:34 -0500 Subject: [PATCH 03/14] Add new MPL profiles, add option to disable HPL --- .gitignore | 1 + README.md | 1 + background.js | 8 ++---- cadmium-playercore-shim.js | 42 ++++++++++++++++++---------- content_script.js | 32 +++++++-------------- manifest.json | 2 +- netflix_max_bitrate.js | 57 ++++++++++++++++++++++++++------------ pages/options.html | 9 ++++-- pages/options.js | 6 ++++ 9 files changed, 94 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index c4c4ffc..4df9adb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.zip +_metadata diff --git a/README.md b/README.md index 366b1b5..4522800 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,4 @@ Contact me on discord: shirt#1337 # Based on the following extensions - https://github.com/DavidBuchanan314/Turbo-Recadmiumator - https://github.com/truedread/netflix-1080p +- https://github.com/lkmvip/netflix-4K-DDplus diff --git a/background.js b/background.js index 2b8ea29..d86bfad 100644 --- a/background.js +++ b/background.js @@ -14,11 +14,6 @@ function getBrowser() { chrome.webRequest.onBeforeRequest.addListener( function (details) { - /* Allow our shim to load an untouched copy */ - if (details.url.endsWith("?no_filter")) { - return {}; - } - if (getBrowser() == "Chrome") { return { redirectUrl: chrome.runtime.getURL("cadmium-playercore-shim.js") }; } @@ -46,6 +41,7 @@ chrome.webRequest.onBeforeRequest.addListener( urls: [ "*://assets.nflxext.com/*/ffe/player/html/*", "*://www.assets.nflxext.com/*/ffe/player/html/*" - ] + ], + types: ["script"] }, ["blocking"] ); diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index e869cc7..00917a5 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -2,6 +2,14 @@ // This script runs as a drop-in replacement of the original cadmium-playercore. This is not a content script. console.log("Netflix International script active!"); +if (window.globalOptions === undefined) { + try { + window.globalOptions = JSON.parse(document.getElementById("netflix-intl-settings").innerText); + } catch(e) { + console.error("Could not load settings:", e); + } +} + /* eslint-disable no-undef */ // https://stackoverflow.com/a/45985333 function getBrowser() { @@ -47,23 +55,29 @@ function get_profile_list(original_profiles) { "playready-h264mpl30-dash", "playready-h264mpl31-dash", "playready-h264mpl40-dash", + "h264mpl30-dash-playready-prk-qc", + "h264mpl31-dash-playready-prk-qc", + "h264mpl40-dash-playready-prk-qc", ]); } - if (original_profiles.includes("playready-h264hpl30-dash")) { - profiles = profiles.concat([ - "playready-h264hpl30-dash", - "playready-h264hpl31-dash", - "playready-h264hpl40-dash", - ]); - } - - if (original_profiles.includes("h264hpl30-dash-playready-live")) { - profiles = profiles.concat([ - "h264hpl30-dash-playready-live", - "h264hpl31-dash-playready-live", - "h264hpl40-dash-playready-live", - ]); + if (!globalOptions.disableHPL) { + if (original_profiles.includes("playready-h264hpl30-dash")) { + profiles = profiles.concat([ + "playready-h264hpl30-dash", + "playready-h264hpl31-dash", + "playready-h264hpl40-dash", + ]); + } + if (original_profiles.includes("h264hpl30-dash-playready-live")) { + profiles = profiles.concat([ + "h264hpl30-dash-playready-live", + "h264hpl31-dash-playready-live", + "h264hpl40-dash-playready-live", + ]); + } + } else { + profiles = profiles.filter(val => !val.includes("h264hpl")); } if (!globalOptions.disableVP9 && original_profiles.includes("vp9-profile0-L30-dash-cenc")) { diff --git a/content_script.js b/content_script.js index d6ed47b..dae47d1 100644 --- a/content_script.js +++ b/content_script.js @@ -31,44 +31,32 @@ function chromeStorageGet(opts) { } } -function attachScript(resp) { - let xhr = resp.target; - let mainScript = document.createElement("script"); - mainScript.type = "application/javascript"; - if (xhr.status == 200) { - mainScript.text = xhr.responseText; - document.documentElement.appendChild(mainScript); - } -} - chromeStorageGet({ use6Channels: true, showAllTracks: true, setMaxBitrate: false, disableVP9: false, disableAV1: true, + disableHPL: false, useDDPlus: false, preferredLocale: null, preferredTextLocale: null, }).then(items => { // very messy workaround for accessing chrome storage outside of background / content scripts let mainScript = document.createElement("script"); - mainScript.type = "application/javascript"; - mainScript.text = `var globalOptions = JSON.parse('${JSON.stringify(items)}');`; + mainScript.type = "application/json"; + mainScript.id = "netflix-intl-settings"; + mainScript.text = JSON.stringify(items); document.documentElement.appendChild(mainScript); }).then(() => { // attach and include additional scripts after we have loaded the main configuration - for (let i = 0; i < script_urls.length; i++) { - let script = document.createElement("script"); - script.src = script_urls[i]; - document.documentElement.appendChild(script); - } for (let i = 0; i < urls.length; i++) { - let mainScriptUrl = chrome.extension.getURL(urls[i]); - let xhr = new XMLHttpRequest(); - xhr.open("GET", mainScriptUrl, true); - xhr.onload = attachScript; - xhr.send(); + const mainScriptUrl = chrome.runtime.getURL(urls[i]); + + const mainScript = document.createElement('script'); + mainScript.type = 'application/javascript'; + mainScript.src = mainScriptUrl; + document.documentElement.appendChild(mainScript); } }); diff --git a/manifest.json b/manifest.json index ab66991..03e54e1 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.16", + "version": "2.0.17", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", diff --git a/netflix_max_bitrate.js b/netflix_max_bitrate.js index 048d2fb..9ad496b 100644 --- a/netflix_max_bitrate.js +++ b/netflix_max_bitrate.js @@ -5,18 +5,33 @@ let getElementByXPath = function (xpath) { ).singleNodeValue; }; -const fn = function () { - window.dispatchEvent(new KeyboardEvent("keydown", { +let fn = function () { + const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate']"); + const AUDIO_SELECT = getElementByXPath("//div[text()='Audio Bitrate']"); + const BUTTON = getElementByXPath("//button[text()='Override']"); + + const videoPlayer = netflix.appContext.state.playerApp.getAPI().videoPlayer; + if(!videoPlayer) { + console.log("API Not Loading!"); + return false; + } + const player = videoPlayer.getVideoPlayerBySessionId(videoPlayer.getAllPlayerSessionIds()[0]); + if(!player) { + console.log("Video Not Loading!"); + return false; + } + if(!player.isPlaying()) { + console.log("Video Not Playing!"); + return false; + } + + window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 83, ctrlKey: true, altKey: true, shiftKey: true, })); - const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate']"); - const AUDIO_SELECT = getElementByXPath("//div[text()='Audio Bitrate']"); - const BUTTON = getElementByXPath("//button[text()='Override']"); - if (!(VIDEO_SELECT && AUDIO_SELECT && BUTTON)){ return false; } @@ -24,40 +39,46 @@ const fn = function () { [VIDEO_SELECT, AUDIO_SELECT].forEach(function (el) { let parent = el.parentElement; - let options = parent.querySelectorAll("select > option"); + let options = parent.querySelectorAll('select > option'); for (var i = 0; i < options.length - 1; i++) { - options[i].removeAttribute("selected"); + options[i].removeAttribute('selected'); } - options[options.length - 1].setAttribute("selected", "selected"); + options[options.length - 1].setAttribute('selected', 'selected'); }); + console.log("Video Playing!"); BUTTON.click(); return true; }; let run = function () { - if (!fn()) { - setTimeout(run, 100); - } + fn() || setTimeout(run, 100) }; const WATCH_REGEXP = /netflix.com\/watch\/.*/; let oldLocation; -if(globalOptions.setMaxBitrate) { +if (window.globalOptions === undefined) { + try { + window.globalOptions = JSON.parse(document.getElementById("netflix-intl-settings").innerText); + } catch(e) { + console.error("Could not load settings:", e); + } +} +if(window.globalOptions.setMaxBitrate ) { console.log("netflix_max_bitrate.js enabled"); + //setInterval(test, 500); setInterval(function () { + let newLocation = window.location.toString(); if (newLocation !== oldLocation) { oldLocation = newLocation; - if (WATCH_REGEXP.test(newLocation)) { - run(); - } + WATCH_REGEXP.test(newLocation) && run(); } - }, 500); -} + }, 500); +} \ No newline at end of file diff --git a/pages/options.html b/pages/options.html index 6f1598f..f51e58a 100644 --- a/pages/options.html +++ b/pages/options.html @@ -6,6 +6,7 @@ @@ -17,11 +18,13 @@

- +
- +
- + +
+
diff --git a/pages/options.js b/pages/options.js index 9f4498c..1992ee0 100644 --- a/pages/options.js +++ b/pages/options.js @@ -5,6 +5,7 @@ function save_options() { const setMaxBitrate = document.getElementById("setMaxBitrate").checked; const disableVP9 = document.getElementById("disableVP9").checked; const disableAV1 = document.getElementById("disableAV1").checked; + const disableHPL = document.getElementById("disableHPL").checked; const useDDPlus = document.getElementById("useDDPlus").checked; const preferredLocale = document.getElementById("preferredLocale").value; const preferredTextLocale = document.getElementById("preferredTextLocale").value; @@ -15,6 +16,7 @@ function save_options() { setMaxBitrate: setMaxBitrate, disableVP9: disableVP9, disableAV1: disableAV1, + disableHPL: disableHPL, useDDPlus: useDDPlus, preferredLocale: preferredLocale, preferredTextLocale: preferredTextLocale, @@ -33,6 +35,7 @@ function reset_options() { document.getElementById("setMaxBitrate").checked = false; document.getElementById("disableVP9").checked = false; document.getElementById("disableAV1").checked = true; + document.getElementById("disableHPL").checked = false; document.getElementById("useDDPlus").checked = false; document.getElementById("preferredLocale").value = null; document.getElementById("preferredTextLocale").value = null; @@ -43,6 +46,7 @@ function reset_options() { setMaxBitrate: false, disableVP9: false, disableAV1: true, + disableHPL: false, useDDPlus: false, preferredLocale: null, preferredTextLocale: null, @@ -62,6 +66,7 @@ function restore_options() { setMaxBitrate: false, disableVP9: false, disableAV1: true, + disableHPL: false, useDDPlus: false, preferredLocale: null, preferredTextLocale: null, @@ -71,6 +76,7 @@ function restore_options() { document.getElementById("setMaxBitrate").checked = items.setMaxBitrate; document.getElementById("disableVP9").checked = items.disableVP9; document.getElementById("disableAV1").checked = items.disableAV1; + document.getElementById("disableHPL").checked = items.disableHPL; document.getElementById("useDDPlus").checked = items.useDDPlus; document.getElementById("preferredLocale").value = items.preferredLocale; document.getElementById("preferredTextLocale").value = items.preferredTextLocale; From 3435e4d1368ac84bfc884c8b8330083d6aa8aa28 Mon Sep 17 00:00:00 2001 From: shirt Date: Tue, 17 Jan 2023 20:30:26 -0500 Subject: [PATCH 04/14] Select highest audio bitrate --- cadmium-playercore-shim.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index 00917a5..70f2166 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -126,16 +126,6 @@ function get_profile_list(original_profiles) { return profiles; } -// eslint-disable-next-line no-unused-vars -function get_preferred_locale() { - return globalOptions.preferredLocale; -} - -// eslint-disable-next-line no-unused-vars -function get_preferred_text_locale() { - return globalOptions.preferredTextLocale; -} - do_patch( "Hello world", /(.*)/, @@ -170,14 +160,28 @@ if (globalOptions.showAllTracks) { do_patch( "Set preferred audio locale", /preferredAudioLocale:.\.preferredAudioLocale/, - "preferredAudioLocale: get_preferred_locale()" + "preferredAudioLocale: globalOptions.preferredLocale" ); do_patch( "Set preferred text locale", /preferredTextLocale:.\.preferredTextLocale/, - "preferredTextLocale: get_preferred_text_locale()" + "preferredTextLocale: globalOptions.preferredTextLocale" ); +if(globalOptions.useDDPlus) { + do_patch( + "Select highest audio bitrate 1", + /(indexOf\(z\))(\?[^?]+)/, + "$1)" + ); + + do_patch( + "Select highest audio bitrate 2", + /(var\sx;if\(this\.[^\)]+)/, + "$1 && !globalOptions.useDDPlus" + ); +} + // run our patched copy of playercore in a non-privileged context on the page window.Function(cadmium_src)(); From 3a8447877666a29d2bffbdef0388009a72e32f06 Mon Sep 17 00:00:00 2001 From: shirt Date: Tue, 17 Jan 2023 20:32:51 -0500 Subject: [PATCH 05/14] Bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 03e54e1..bff78bf 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.17", + "version": "2.0.18", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", From 24b0d31ab550548c618164cc5f5fe5177f7af7e5 Mon Sep 17 00:00:00 2001 From: shirt-dev Date: Sat, 11 Mar 2023 18:14:18 -0500 Subject: [PATCH 06/14] Fix bitrate selection --- cadmium-playercore-shim.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index 70f2166..9dbf41b 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -169,11 +169,11 @@ do_patch( "preferredTextLocale: globalOptions.preferredTextLocale" ); -if(globalOptions.useDDPlus) { +if(globalOptions.useDDPlus && MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { do_patch( "Select highest audio bitrate 1", - /(indexOf\(z\))(\?[^?]+)/, - "$1)" + /(indexOf\(.\))(\?[^?]+)(\?[0-9]:)/, + "$1)$3" ); do_patch( From e577af28494b72dae87fe1bdfe0c95b7a8949e0c Mon Sep 17 00:00:00 2001 From: shirt-dev Date: Sat, 11 Mar 2023 18:17:20 -0500 Subject: [PATCH 07/14] Bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index bff78bf..3bf5b6b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.18", + "version": "2.0.19", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", From cfe541e0e3943c274c78d7384cb1f920d34a0c64 Mon Sep 17 00:00:00 2001 From: shirt Date: Tue, 14 Mar 2023 08:44:53 -0400 Subject: [PATCH 08/14] Replace icon to appease Google --- img/icon128.png | Bin 953 -> 4188 bytes img/icon48.png | Bin 482 -> 2115 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/img/icon128.png b/img/icon128.png index ba0355ecefea5a796480fd90aad384178664a229..32c7b6465d2ac01ad0881878982cd9e09bcb86f8 100644 GIT binary patch literal 4188 zcmeHK=QrF9)Bf!)qO2Z0?kKAhZXt+>)mIlbYDA9~q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68YmW?jS;JBH2`2&1FIQf`-2)8xx< z$pmtrE@6zN95-bo{uP+0nS?8qSB^7&8WloMsV7PQT4^l)`DkEiP)Wo*{0rH086SL~%nVgQ4VU@mmL|AbWDm^1o0ASYBysehPVjAzV6Kw7 zeW?)fn$DzqaDF9a%_dF_?`nSYhU7|jq&=j8GcwM01=OIl$G2)$I8+UTW74vKMrr*CFfOI(qd*bAu F{2!g?jx+!O delta 468 zcmV;_0W1E)5aI)n7=Hu<0001`EabER001yhOjJbx004#n2U-ILX#xrJ2or__3W@~_ z=Li#>1r62+6sH9au?7#l1`yH*66FaL^a&LLY|Z=t000YgQchCYg>-miT zE0X{K0ai&wK~y-)b&)$x!$1@OXA>l7z-w`V@Hs$)H~1O`}%00ijT2$%xj5n!AJe-be~z*Yn#0-VK+9Oy;> z0<78)7zfag7=OTH%+6RwFC&TmV{uD)r%O;0;dt+1=y4jY#8vD5r6=> z4S|^gCIM{Qu+`5dm;*j7&(t6RNF_AZpQ?ANfdGtwycZf@pLUVuTflxuIlY}*pob_U z8SAVXl+$ehawgSvnny7MOlSxNDoY!MeiS|2KdRowqD>|$OCQB#xvRD@quy1+__cLb z! Date: Fri, 17 Mar 2023 19:26:15 -0400 Subject: [PATCH 09/14] Fix max bitrate selection --- netflix_max_bitrate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netflix_max_bitrate.js b/netflix_max_bitrate.js index 9ad496b..9707a43 100644 --- a/netflix_max_bitrate.js +++ b/netflix_max_bitrate.js @@ -6,7 +6,7 @@ let getElementByXPath = function (xpath) { }; let fn = function () { - const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate']"); + const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate']") || getElementByXPath("//div[text()='Video Bitrate / VMAF']"); const AUDIO_SELECT = getElementByXPath("//div[text()='Audio Bitrate']"); const BUTTON = getElementByXPath("//button[text()='Override']"); From 1ff293ccf3b222c0b01590c8ea962e3613ebd1c8 Mon Sep 17 00:00:00 2001 From: shirt-dev Date: Fri, 17 Mar 2023 19:27:26 -0400 Subject: [PATCH 10/14] Bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 3bf5b6b..03a43a2 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.19", + "version": "2.0.20", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", From 79ca463a5a8cb2e86ac1bb6e8dfc6b0eaf93803a Mon Sep 17 00:00:00 2001 From: shirt <2660574+shirt-dev@users.noreply.github.com> Date: Sun, 5 Nov 2023 11:14:51 -0500 Subject: [PATCH 11/14] Fix max bitrate selector --- cadmium-playercore-shim.js | 2 +- manifest.json | 2 +- netflix_max_bitrate.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index 9dbf41b..9d6d35a 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -145,7 +145,7 @@ do_patch( ); do_patch( - "Re-enable Ctrl+Shift+Alt+S menu", + "Re-enable Ctrl+Shift+Alt+B menu", /this\...\....\s*&&\s*this\.toggle\(\);/, "this.toggle();" ); diff --git a/manifest.json b/manifest.json index 03a43a2..183255f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.20", + "version": "2.0.21", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", diff --git a/netflix_max_bitrate.js b/netflix_max_bitrate.js index 9707a43..654c4b7 100644 --- a/netflix_max_bitrate.js +++ b/netflix_max_bitrate.js @@ -26,7 +26,7 @@ let fn = function () { } window.dispatchEvent(new KeyboardEvent('keydown', { - keyCode: 83, + keyCode: 66, ctrlKey: true, altKey: true, shiftKey: true, From aacc5fc76fa95c05140773102574d09d443c8bdc Mon Sep 17 00:00:00 2001 From: shirt <2660574+shirt-dev@users.noreply.github.com> Date: Sun, 5 Nov 2023 11:44:01 -0500 Subject: [PATCH 12/14] Remove Dolby Digital Plus support Unfortunately Netflix keeps breaking Dolby Digital Plus and I don't have time to fix it. PRs welcome. --- cadmium-playercore-shim.js | 40 +++++--------------------------------- pages/options.html | 2 -- pages/options.js | 6 ------ 3 files changed, 5 insertions(+), 43 deletions(-) diff --git a/cadmium-playercore-shim.js b/cadmium-playercore-shim.js index 9d6d35a..a6e9fcc 100644 --- a/cadmium-playercore-shim.js +++ b/cadmium-playercore-shim.js @@ -100,27 +100,11 @@ function get_profile_list(original_profiles) { profiles = profiles.filter(val => !val.includes("av1-")); } - if (globalOptions.useDDPlus && MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { - // Dolby Digital - profiles = profiles.concat([ - "ddplus-2.0-dash", - ]); - - if (globalOptions.use6Channels) { - profiles = profiles.concat([ - "ddplus-5.1-dash", - "ddplus-5.1hq-dash", - "ddplus-atmos-dash", - ]); - } - } else { - // No Dolby Digital - if (globalOptions.use6Channels) { - profiles = profiles.concat([ - "heaac-5.1-dash", - ]); - } - } + if (globalOptions.use6Channels) { + profiles = profiles.concat([ + "heaac-5.1-dash", + ]); + } profiles = [...new Set(profiles)].sort(); return profiles; @@ -169,19 +153,5 @@ do_patch( "preferredTextLocale: globalOptions.preferredTextLocale" ); -if(globalOptions.useDDPlus && MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) { - do_patch( - "Select highest audio bitrate 1", - /(indexOf\(.\))(\?[^?]+)(\?[0-9]:)/, - "$1)$3" - ); - - do_patch( - "Select highest audio bitrate 2", - /(var\sx;if\(this\.[^\)]+)/, - "$1 && !globalOptions.useDDPlus" - ); -} - // run our patched copy of playercore in a non-privileged context on the page window.Function(cadmium_src)(); diff --git a/pages/options.html b/pages/options.html index f51e58a..ca16bd9 100644 --- a/pages/options.html +++ b/pages/options.html @@ -24,8 +24,6 @@

- -

diff --git a/pages/options.js b/pages/options.js index 1992ee0..386a052 100644 --- a/pages/options.js +++ b/pages/options.js @@ -6,7 +6,6 @@ function save_options() { const disableVP9 = document.getElementById("disableVP9").checked; const disableAV1 = document.getElementById("disableAV1").checked; const disableHPL = document.getElementById("disableHPL").checked; - const useDDPlus = document.getElementById("useDDPlus").checked; const preferredLocale = document.getElementById("preferredLocale").value; const preferredTextLocale = document.getElementById("preferredTextLocale").value; @@ -17,7 +16,6 @@ function save_options() { disableVP9: disableVP9, disableAV1: disableAV1, disableHPL: disableHPL, - useDDPlus: useDDPlus, preferredLocale: preferredLocale, preferredTextLocale: preferredTextLocale, }, function() { @@ -36,7 +34,6 @@ function reset_options() { document.getElementById("disableVP9").checked = false; document.getElementById("disableAV1").checked = true; document.getElementById("disableHPL").checked = false; - document.getElementById("useDDPlus").checked = false; document.getElementById("preferredLocale").value = null; document.getElementById("preferredTextLocale").value = null; @@ -47,7 +44,6 @@ function reset_options() { disableVP9: false, disableAV1: true, disableHPL: false, - useDDPlus: false, preferredLocale: null, preferredTextLocale: null, }, function() { @@ -67,7 +63,6 @@ function restore_options() { disableVP9: false, disableAV1: true, disableHPL: false, - useDDPlus: false, preferredLocale: null, preferredTextLocale: null, }, function(items) { @@ -77,7 +72,6 @@ function restore_options() { document.getElementById("disableVP9").checked = items.disableVP9; document.getElementById("disableAV1").checked = items.disableAV1; document.getElementById("disableHPL").checked = items.disableHPL; - document.getElementById("useDDPlus").checked = items.useDDPlus; document.getElementById("preferredLocale").value = items.preferredLocale; document.getElementById("preferredTextLocale").value = items.preferredTextLocale; }); From 2d5268217e358d109007f3e1f0286f503647c5a7 Mon Sep 17 00:00:00 2001 From: shirt <2660574+shirt-dev@users.noreply.github.com> Date: Wed, 31 Jul 2024 19:06:19 -0400 Subject: [PATCH 13/14] Update playercore URLs --- background.js | 2 +- manifest.json | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/background.js b/background.js index d86bfad..68de4fa 100644 --- a/background.js +++ b/background.js @@ -40,7 +40,7 @@ chrome.webRequest.onBeforeRequest.addListener( }, { urls: [ "*://assets.nflxext.com/*/ffe/player/html/*", - "*://www.assets.nflxext.com/*/ffe/player/html/*" + "*://assets.nflxext.com/player/html/ffe/*" ], types: ["script"] }, ["blocking"] diff --git a/manifest.json b/manifest.json index 183255f..9bf12fa 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Netflix International", "description": "Displays all available Netflix audio and subtitle tracks.", - "version": "2.0.21", + "version": "2.0.22", "author": "shirt", "browser_action": { "default_icon": "img/icon128.png", @@ -19,8 +19,7 @@ }, "content_scripts": [{ "matches": [ - "*://assets.nflxext.com/*/ffe/player/html/*", - "*://www.assets.nflxext.com/*/ffe/player/html/*", + "*://assets.nflxext.com/*", "*://netflix.com/*", "*://www.netflix.com/*" ], @@ -45,8 +44,7 @@ "storage", "webRequest", "webRequestBlocking", - "*://assets.nflxext.com/*/ffe/player/html/*", - "*://www.assets.nflxext.com/*/ffe/player/html/*", + "*://assets.nflxext.com/*", "*://netflix.com/*", "*://www.netflix.com/*" ] From d0e76f73bf5a6607d2009204ce0b90b38bf16407 Mon Sep 17 00:00:00 2001 From: shirt <2660574+shirt-dev@users.noreply.github.com> Date: Sun, 4 Aug 2024 18:11:41 -0400 Subject: [PATCH 14/14] Update to manifest v3 --- background.js | 47 -------------------------------------- cadmium-playercore-shim.js | 2 +- manifest.json | 39 +++++++++++++++++++------------ rules.json | 26 +++++++++++++++++++++ 4 files changed, 52 insertions(+), 62 deletions(-) delete mode 100644 background.js create mode 100644 rules.json 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"] + } + } +]