From 2ffebb76a4af406d559bf2d615a39bab1c9054ef Mon Sep 17 00:00:00 2001 From: Jan Scheiper Date: Mon, 11 Apr 2022 13:23:29 +0200 Subject: [PATCH] version 1.27.0: updated extension to manifest V3, added option to show all subtitle tracks --- .../generated_indexed_rulesets/_ruleset1 | Bin 0 -> 843 bytes background.js | 13 ----- cadmium-playercore-6.0034.295.911-patched.js | 21 ++++++-- content_script.js | 45 ++++++------------ manifest.json | 34 ++++++++----- netflix_max_bitrate.js | 10 +++- pages/options.html | 2 + pages/options.js | 3 ++ redirect_rules.json | 35 ++++++++++++++ 9 files changed, 102 insertions(+), 61 deletions(-) create mode 100644 _metadata/generated_indexed_rulesets/_ruleset1 delete mode 100755 background.js mode change 100755 => 100644 content_script.js create mode 100644 redirect_rules.json diff --git a/_metadata/generated_indexed_rulesets/_ruleset1 b/_metadata/generated_indexed_rulesets/_ruleset1 new file mode 100644 index 0000000000000000000000000000000000000000..9e016649701b35db25dc6fbe9b13738d0d5652e0 GIT binary patch literal 843 zcmbu7u};G<5QeX%K!iGEU|?YAz*G^tKtTeD5s85bA;iEyYC9B&ld1^{Yz#aALkC74 zf(PIM7AkW9sHwIdIj&*e3Xb#RPzV0 z9;)%2av3KJzx^g~Zn=kO75>=XMXnUQiu1{I$RU$6h$GzEHioL;xTo2-b z)sc;pE3F43D^;lN#kCE}QdK%O!ItRtHu_?HdsA$$tp%enS3{%4Wd;e{wI!P44~+TJ W;LSJNclWUFGv`^?U-$X1wSNKWCW_7g literal 0 HcmV?d00001 diff --git a/background.js b/background.js deleted file mode 100755 index 6edcbb8..0000000 --- a/background.js +++ /dev/null @@ -1,13 +0,0 @@ -chrome.webRequest.onBeforeRequest.addListener( - function(details) { - return { - redirectUrl: chrome.extension.getURL("cadmium-playercore-6.0034.295.911-patched.js") - }; - }, { - urls: [ - "*://assets.nflxext.com/*/ffe/player/html/*", - "*://www.assets.nflxext.com/*/ffe/player/html/*", - "*://*.a.nflxso.net/sec/*/ffe/player/html/*", - ] - }, ["blocking"] -); diff --git a/cadmium-playercore-6.0034.295.911-patched.js b/cadmium-playercore-6.0034.295.911-patched.js index b4ae8db..14ee9fd 100644 --- a/cadmium-playercore-6.0034.295.911-patched.js +++ b/cadmium-playercore-6.0034.295.911-patched.js @@ -1,3 +1,11 @@ +if (window.globalOptions === undefined) { + try { + window.globalOptions = JSON.parse(document.getElementById("netflix-1080p-settings").innerText); + } catch(e) { + console.error("Could not load settings:", e); + } +} + a000.Z36 = function() { return typeof a000.e36.Q36 === 'function' ? a000.e36.Q36.apply(a000.e36, arguments) : a000.e36.Q36; }; @@ -128435,23 +128443,30 @@ a000.e36 = (function(N36) { "BIF320" ]; - if (!globalOptions.disableVP9) { + if (!window.globalOptions.disableVP9) { profiles.push("vp9-profile0-L21-dash-cenc", "vp9-profile0-L30-dash-cenc", "vp9-profile0-L31-dash-cenc", "vp9-profile0-L40-dash-cenc"); } else { console.log("VP9 disabled"); } - if (globalOptions.use6Channels) { + if (window.globalOptions.use6Channels) { profiles.push("heaac-5.1-dash"); console.log("5.1 support enabled"); } - if (!globalOptions.disableAVChigh) { + if (!window.globalOptions.disableAVChigh) { profiles.push("playready-h264hpl30-dash", "playready-h264hpl31-dash", "playready-h264hpl40-dash"); } else { console.log("AVChigh disabled"); } + if (window.globalOptions.showAllSubs) { + E.showAllSubDubTracks = true; + console.log("All subtitle tracks shown"); + } + + console.log("drmVersion:", C); + L = { type: "standard", manifestVersion: A.dh.zWa ? "v2" : "v1", diff --git a/content_script.js b/content_script.js old mode 100755 new mode 100644 index ec1313b..2bb177f --- a/content_script.js +++ b/content_script.js @@ -1,9 +1,3 @@ -// From EME Logger extension - -const EXTERNAL_SCRIPTS = [ - // 'https://cdn.rawgit.com/ricmoo/aes-js/master/index.js', - // 'https://cdn.rawgit.com/Caligatio/jsSHA/master/dist/sha.js' -]; const INTERNAL_SCRIPTS = [ 'netflix_max_bitrate.js' @@ -16,14 +10,14 @@ function chromeStorageGet(opts) { }); } -function attachScript(resp) { - const xhr = resp.target; +function addSettingsToHtml(settings) { const mainScript = document.createElement('script'); - mainScript.type = 'application/javascript'; - if (xhr.status == 200) { - mainScript.text = xhr.responseText; - document.documentElement.appendChild(mainScript); - } + mainScript.type = 'application/json'; + mainScript.text = JSON.stringify(settings); + mainScript.id = "netflix-1080p-settings"; + document.documentElement.appendChild(mainScript); + + console.log("Loaded settings"); } chromeStorageGet({ @@ -31,27 +25,16 @@ chromeStorageGet({ setMaxBitrate: true, disableVP9: false, disableAVChigh: false, + showAllSubs: false, }).then(items => { - // very messy workaround for accessing chrome storage outside of background / content scripts - const mainScript = document.createElement('script'); - mainScript.type = 'application/javascript'; - mainScript.text = `var globalOptions = JSON.parse('${JSON.stringify(items)}');`; - document.documentElement.appendChild(mainScript); + addSettingsToHtml(items); }).then(() => { - // attach and include additional scripts after we have loaded the main configuration - for (let i = 0; i < EXTERNAL_SCRIPTS.length; i++) { - const script = document.createElement('script'); - script.src = EXTERNAL_SCRIPTS[i]; - document.documentElement.appendChild(script); - } - for (let i = 0; i < INTERNAL_SCRIPTS.length; i++) { - const mainScriptUrl = chrome.extension.getURL(INTERNAL_SCRIPTS[i]); - - const xhr = new XMLHttpRequest(); - xhr.open('GET', mainScriptUrl, true); - xhr.onload = attachScript; + const mainScriptUrl = chrome.runtime.getURL(INTERNAL_SCRIPTS[i]); - xhr.send(); + const mainScript = document.createElement('script'); + mainScript.type = 'application/javascript'; + mainScript.src = mainScriptUrl; + document.documentElement.appendChild(mainScript); } }); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 191c4c8..b96ec3c 100755 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "Netflix 1080p", "description": "Forces 1080p and 5.1 playback for Netflix.", - "version": "1.26.1", + "version": "1.27.0", "author": "truedread, jangxx", - "browser_action": { + "action": { "default_icon": "img/icon128.png" }, "icons": { @@ -24,25 +24,33 @@ "js": ["content_script.js"], "run_at": "document_start" }], - "background": { - "scripts": ["background.js"] - }, "options_ui": { "page": "pages/options.html", "open_in_tab": false }, - "web_accessible_resources": [ - "netflix_max_bitrate.js", - "cadmium-playercore-6.0034.295.911-patched.js" - ], + "web_accessible_resources": [{ + "resources": [ + "netflix_max_bitrate.js", + "cadmium-playercore-6.0034.295.911-patched.js" + ], + "matches": [ "*://www.netflix.com/*" ] + }], "permissions": [ "storage", - "webRequest", - "webRequestBlocking", + "declarativeNetRequest" + ], + "host_permissions": [ "*://assets.nflxext.com/*/ffe/player/html/*", "*://www.assets.nflxext.com/*/ffe/player/html/*", "*://*.a.nflxso.net/sec/*/ffe/player/html/*", "*://netflix.com/*", "*://www.netflix.com/*" - ] + ], + "declarative_net_request" : { + "rule_resources": [{ + "id": "redirect_to_patched", + "enabled": true, + "path": "redirect_rules.json" + }] + } } diff --git a/netflix_max_bitrate.js b/netflix_max_bitrate.js index b8b1c45..36479a3 100644 --- a/netflix_max_bitrate.js +++ b/netflix_max_bitrate.js @@ -90,7 +90,15 @@ const WATCH_REGEXP = /netflix.com\/watch\/.*/; let oldLocation; -if(globalOptions.setMaxBitrate) { +if (window.globalOptions === undefined) { + try { + window.globalOptions = JSON.parse(document.getElementById("netflix-1080p-settings").innerText); + } catch(e) { + console.error("Could not load settings:", e); + } +} + +if (window.globalOptions.setMaxBitrate) { console.log("netflix_max_bitrate.js enabled"); setInterval(function () { let newLocation = window.location.toString(); diff --git a/pages/options.html b/pages/options.html index 1cad998..56ba511 100755 --- a/pages/options.html +++ b/pages/options.html @@ -13,6 +13,8 @@
+
+
diff --git a/pages/options.js b/pages/options.js index 728060f..d0200a3 100755 --- a/pages/options.js +++ b/pages/options.js @@ -3,12 +3,14 @@ function save_options() { const setMaxBitrate = document.getElementById("setMaxBitrate").checked; const disableVP9 = document.getElementById("disableVP9").checked; const disableAVChigh = document.getElementById("disableAVChigh").checked; + const showAllSubs = document.getElementById("showAllSubs").checked; chrome.storage.sync.set({ use6Channels, setMaxBitrate, disableVP9, disableAVChigh, + showAllSubs, }, function() { var status = document.getElementById('status'); status.textContent = 'Options saved.'; @@ -24,6 +26,7 @@ function restore_options() { setMaxBitrate: true, disableVP9: false, disableAVChigh: false, + showAllSubs: false, }, function(items) { document.getElementById("use51").checked = items.use6Channels; document.getElementById("setMaxBitrate").checked = items.setMaxBitrate; diff --git a/redirect_rules.json b/redirect_rules.json new file mode 100644 index 0000000..5465b0e --- /dev/null +++ b/redirect_rules.json @@ -0,0 +1,35 @@ +[ + { + "id": 1, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { "extensionPath": "/cadmium-playercore-6.0034.295.911-patched.js" } + }, + "condition": { + "urlFilter": "*://assets.nflxext.com/*/ffe/player/html/*" + } + }, + { + "id": 2, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { "extensionPath": "/cadmium-playercore-6.0034.295.911-patched.js" } + }, + "condition": { + "urlFilter": "*://www.assets.nflxext.com/*/ffe/player/html/*" + } + }, + { + "id": 3, + "priority": 1, + "action": { + "type": "redirect", + "redirect": { "extensionPath": "/cadmium-playercore-6.0034.295.911-patched.js" } + }, + "condition": { + "urlFilter": "*://*.a.nflxso.net/sec/*/ffe/player/html/*" + } + } +] \ No newline at end of file