Skip to content

Commit

Permalink
Select highest audio bitrate
Browse files Browse the repository at this point in the history
  • Loading branch information
shirt-dev committed Jan 18, 2023
1 parent 96856b0 commit 3435e4d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions cadmium-playercore-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
/(.*)/,
Expand Down Expand Up @@ -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)();

0 comments on commit 3435e4d

Please sign in to comment.