From fbd15b28b9c9bb9025216c1a8c0577babadab376 Mon Sep 17 00:00:00 2001 From: hyww Date: Sat, 10 Dec 2022 04:39:35 +0800 Subject: [PATCH] Unlock all languages resolves #29 tested with cadium-playercore 6.0033.414.911, 6.0034.588.911, 6.0038.181.911 --- src/nflxmultisubs.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/nflxmultisubs.js b/src/nflxmultisubs.js index b6e1935..0bf791a 100644 --- a/src/nflxmultisubs.js +++ b/src/nflxmultisubs.js @@ -22,6 +22,28 @@ const hookJsonParseAndAddCallback = function(_window) { hookJsonParseAndAddCallback(window); +// Hook JSON.stringify() to intercept and modify manifest requests +const hookJsonStringify = function(_window) { + const _stringify = JSON.stringify; + _window.JSON.stringify = (...args) => { + if (args[0] && (args[0].url === 'licensedManifest' || args[0].url === 'manifest')) { + // key name is different for different cadium-playercore versions + // so we check each one by testing two common properties + for (let i in args[0]) { + if (args[0][i] && args[0][i].viewableId && args[0][i].manifestVersion) { + args[0][i].showAllSubDubTracks = true; + args[0][i].supportsPartialHydration = false; + console.log(`Modified manifest request to unlock all sub/dub tracks`); + } + } + } + const result = _stringify.call(JSON, ...args); + return result; + }; +}; +hookJsonStringify(window); + + // hook `history.pushState()` as there is not "pushstate" event in DOM API // Because Netflix preload manifests when the user hovers mouse over movies on index page, // our .updateManifest() won't be trigger after user clicks a movie to start watching (they must reload the player page) @@ -1396,4 +1418,4 @@ window.addEventListener('keyup', (event) => { primary.style.visibility = secondary.style.visibility = (visible) ? 'hidden' : 'visible'; } -}, true); \ No newline at end of file +}, true);