Skip to content

Commit

Permalink
version 1.27.0: updated extension to manifest V3, added option to sho…
Browse files Browse the repository at this point in the history
…w all subtitle tracks
  • Loading branch information
jangxx committed Apr 11, 2022
1 parent 864aacb commit 2ffebb7
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 61 deletions.
Binary file added _metadata/generated_indexed_rulesets/_ruleset1
Binary file not shown.
13 changes: 0 additions & 13 deletions background.js

This file was deleted.

21 changes: 18 additions & 3 deletions cadmium-playercore-6.0034.295.911-patched.js
Original file line number Diff line number Diff line change
@@ -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;
};
Expand Down Expand Up @@ -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",
Expand Down
45 changes: 14 additions & 31 deletions content_script.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -16,42 +10,31 @@ 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({
use6Channels: true,
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);
}
});
34 changes: 21 additions & 13 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}]
}
}
10 changes: 9 additions & 1 deletion netflix_max_bitrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<input type="checkbox" id="disableVP9"><label for="disableVP9">Disable VP9 codec</label>
<br>
<input type="checkbox" id="disableAVChigh"><label for="disableAVChigh">Disable AVChigh codec</label>
<br>
<input type="checkbox" id="showAllSubs"><label for="showAllSubs">Show all subtitle tracks</label>

<div id="status"></div>
<button id="save">Save</button>
Expand Down
3 changes: 3 additions & 0 deletions pages/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand All @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions redirect_rules.json
Original file line number Diff line number Diff line change
@@ -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/*"
}
}
]

0 comments on commit 2ffebb7

Please sign in to comment.