master a4cdb0d8d2bd cached
5 files
8.6 KB
2.6k tokens
8 symbols
1 requests
Download .txt
Repository: DavidBuchanan314/Turbo-Recadmiumator
Branch: master
Commit: a4cdb0d8d2bd
Files: 5
Total size: 8.6 KB

Directory structure:
gitextract_du84s3un/

├── LICENSE
├── README.md
└── src/
    ├── background.js
    ├── cadmium-playercore-shim.js
    └── manifest.json

================================================
FILE CONTENTS
================================================

================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2020 David Buchanan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# Turbo-Recadmiumator [WIP]
A remake of truedread/netflix-1080p which auto-patches cadmium-playercore at runtime to enable enhanced playback features.

Works in both Firefox and Chrom{e,ium}.

Rather than bundling a hand-patched cadmium-playercore.js, this extension
performs the patches at runtime using regex. Therefore, it should be publishable
to the chrome/ff webstores without any copyright issues etc.

It remains to be seen how robust my regexes will be to playercore updates.

## Current features:

- Enable <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>S</kbd> bitrate selection window.

- 1080p video.

- Disable VP9 profiles.

- Enable 5.1 audio profile.

- Auto-select stream with max available bitrate.

## Undocumented Keyboard Shortcuts:

Netflix has a bunch of undocumented keyboard shortcuts, that do useful things. This list may be incomplete.

- <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>B</kbd> - Bitrate selection menu (re-enabled by this project) (NOTE: This used to be S, not B!)

- <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>D</kbd> - Debug overlay - displays lots of useful info and stats, including current resolution and bitrate.

- <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>T</kbd> - Upload custom subtitle file, in DFXP/TTML format.

- <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>L</kbd> - Log viewer.

## TODO:

- Add settings UI (right now, you have to edit the source...)

- Add comments detailing where I stole the code from...

## Credits:

This codebase is cobbled together with bits and pieces from [truedread/netflix-1080p](https://github.com/truedread/netflix-1080p) and its various forks. Notably:

- https://github.com/vladikoff/netflix-1080p-firefox

- https://github.com/TheGoddessInari/netflix-1080p-firefox

- https://github.com/OothecaPickle/netflix-1080p

- https://github.com/jangxx/netflix-1080p


================================================
FILE: src/background.js
================================================
// 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) {
		/* Allow our shim to load an untouched copy */
		if (details.url.endsWith("?no_filter")) {
			return {};
		}
		
		if (getBrowser() == "Chrome") {
			return {
				redirectUrl: chrome.extension.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 = event => {
				fetch(browser.extension.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 :(");
		}
	}, {
		urls: [
			"*://assets.nflxext.com/player/html/ffe/*",
			"*://*.a.nflxso.net/sec/player/html/ffe/*"
		]
	}, ["blocking"]
);


================================================
FILE: src/cadmium-playercore-shim.js
================================================
/* This script runs as a drop-in replacement of the original cadmium-playercore */
console.log("Hello, I am running instead of playercore");

var my_config = {
	"use_VP9": false,
	"use_5.1": false,
	"set_max_bitrate": true,
}

function repr(obj) {
	// can you tell I'm a python programmer?
	return JSON.stringify(obj);
}

function do_patch(desc, needle, replacement) {
	var match = cadmium_src.match(needle);
	if (!match) {
		alert("Failed to find patch: " + repr(desc));
	} else {
		cadmium_src = cadmium_src.replace(needle, replacement);
		console.log("[+] Patched: " + repr(desc));
		if (match[0].length < 200) { // avoid spamming the console
			console.log(repr(match[0]) + " -> " + repr(replacement));
		}
	}
}

/* We need to do a synchronous request because we need to eval
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.send(null);

var cadmium_src = request.responseText;

function get_profile_list() {
	custom_profiles = [
		"playready-h264mpl30-dash",
		"playready-h264mpl31-dash",
		"playready-h264mpl40-dash",
		
		"playready-h264hpl30-dash",
		"playready-h264hpl31-dash",
		"playready-h264hpl40-dash",
		
		"heaac-2-dash",
		"heaac-2hq-dash",

		"simplesdh",
		"nflx-cmisc",
		"BIF240",
		"BIF320"
	];

	if (my_config["use_VP9"]) {
		custom_profiles = custom_profiles.concat([
			"vp9-profile0-L30-dash-cenc",
			"vp9-profile0-L31-dash-cenc",
			"vp9-profile0-L40-dash-cenc",
		]);
	}

	if (my_config["use_5.1"]) {
		custom_profiles.push("heaac-5.1-dash");
	}

	return custom_profiles;
}

do_patch(
	"Hello world",
	/(.*)/,
	"console.log('Hello, I am code which has been injected into playercore!'); $1"
);

do_patch(
	"Custom profiles",
	/(viewableId:.,profiles:).,/,
	"$1 get_profile_list(),"
);

do_patch(
	"Custom profile group",
	/(name:"default",profiles:)./,
	"$1 get_profile_list()"
);

do_patch(
	"Re-enable Ctrl+Shift+Alt+S menu",
	/this\...\....\s*\&\&\s*this\.toggle\(\);/,
	"this.toggle();");

// run our patched copy of playercore
eval(cadmium_src);



/* netflix_max_bitrate.js */

function getElementByXPath(xpath) {
	return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

function set_max_bitrate() {
	const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate / VMAF']");
	const AUDIO_SELECT = getElementByXPath("//div[text()='Audio Bitrate']");
	const BUTTON = getElementByXPath("//button[text()='Override']");

	if (!(VIDEO_SELECT && AUDIO_SELECT && BUTTON)){
		window.dispatchEvent(new KeyboardEvent('keydown', {
			keyCode: 66,
			ctrlKey: true,
			altKey: true,
			shiftKey: true,
		}));

		return false;
	}

	let SELECT_LISTS = [VIDEO_SELECT, AUDIO_SELECT];
	let result = false;

	for (var index = 0; index < SELECT_LISTS.length; index++) {
		let list = SELECT_LISTS[index];
		let parent = list.parentElement;
		let select = parent.querySelector('select');

		if (select.disabled){
			return false;
		}

		let options = parent.querySelectorAll('select > option');

		if (options.length == 0){
			return false;
		}

		if (options.length > 1 && options[0].selected == false){
			return false;
		}

		for (var i = 0; i < options.length - 1; i++) {
			options[i].selected = false;
		}

		options[options.length - 1].selected = true;
		result = options[options.length - 1].selected;
	}

	if (result){
		console.log("max bitrate selected, closing window");
		BUTTON.click();
	}

	return result;
}

function set_max_bitrate_run(attempts) {
	if (!attempts) {
		console.log("failed to select max bitrate");
		return;
	}

	set_max_bitrate() || setTimeout(() => set_max_bitrate_run(attempts - 1), 200);
}

const WATCH_REGEXP = /netflix.com\/watch\/.*/;

let oldLocation;

if(my_config["set_max_bitrate"]) {
	console.log("netflix_max_bitrate.js enabled");
	setInterval(function () {
		let newLocation = window.location.toString();

		if (newLocation !== oldLocation) {
			oldLocation = newLocation;
			WATCH_REGEXP.test(newLocation) && set_max_bitrate_run(10);
		}
	}, 500);
}


================================================
FILE: src/manifest.json
================================================
{
	"manifest_version": 2,
	"name": "Turbo-Recadmiumator",
	"description": "Hotpatches Netflix cadmium-playercore.js to enhance features",
	"version": "0.0.1",
	"author": "Retr0id",
	"background": {
		"scripts": [
			"background.js"
		]
	},
	"web_accessible_resources": [
		"cadmium-playercore-shim.js"
	],
	"permissions": [
		"storage",
		"webRequest",
		"webRequestBlocking",
		"*://assets.nflxext.com/player/html/ffe/*",
		"*://*.a.nflxso.net/sec/player/html/ffe/*",
		"*://netflix.com/*",
		"*://www.netflix.com/*"
	]
}
Download .txt
gitextract_du84s3un/

├── LICENSE
├── README.md
└── src/
    ├── background.js
    ├── cadmium-playercore-shim.js
    └── manifest.json
Download .txt
SYMBOL INDEX (8 symbols across 2 files)

FILE: src/background.js
  function getBrowser (line 2) | function getBrowser() {

FILE: src/cadmium-playercore-shim.js
  function repr (line 10) | function repr(obj) {
  function do_patch (line 15) | function do_patch(desc, needle, replacement) {
  function get_profile_list (line 37) | function get_profile_list() {
  function getElementByXPath (line 101) | function getElementByXPath(xpath) {
  function set_max_bitrate (line 105) | function set_max_bitrate() {
  function set_max_bitrate_run (line 159) | function set_max_bitrate_run(attempts) {
  constant WATCH_REGEXP (line 168) | const WATCH_REGEXP = /netflix.com\/watch\/.*/;
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (10K chars).
[
  {
    "path": "LICENSE",
    "chars": 1071,
    "preview": "MIT License\n\nCopyright (c) 2020 David Buchanan\n\nPermission is hereby granted, free of charge, to any person obtaining a "
  },
  {
    "path": "README.md",
    "chars": 1893,
    "preview": "# Turbo-Recadmiumator [WIP]\nA remake of truedread/netflix-1080p which auto-patches cadmium-playercore at runtime to enab"
  },
  {
    "path": "src/background.js",
    "chars": 1197,
    "preview": "// https://stackoverflow.com/a/45985333\nfunction getBrowser() {\n\tif (typeof chrome !== \"undefined\") {\n\t\tif (typeof brows"
  },
  {
    "path": "src/cadmium-playercore-shim.js",
    "chars": 4166,
    "preview": "/* This script runs as a drop-in replacement of the original cadmium-playercore */\nconsole.log(\"Hello, I am running inst"
  },
  {
    "path": "src/manifest.json",
    "chars": 523,
    "preview": "{\n\t\"manifest_version\": 2,\n\t\"name\": \"Turbo-Recadmiumator\",\n\t\"description\": \"Hotpatches Netflix cadmium-playercore.js to e"
  }
]

About this extraction

This page contains the full source code of the DavidBuchanan314/Turbo-Recadmiumator GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (8.6 KB), approximately 2.6k tokens, and a symbol index with 8 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!