Skip to content

Commit

Permalink
Separate subtitle language
Browse files Browse the repository at this point in the history
  • Loading branch information
shirt-dev committed Apr 25, 2022
1 parent a793273 commit 5216752
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 5 deletions.
7 changes: 6 additions & 1 deletion cadmium-playercore-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ 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 @@ -150,7 +155,7 @@ do_patch(
do_patch(
"Set preferred text locale",
/preferredTextLocale:.\.preferredTextLocale/,
"preferredTextLocale: get_preferred_locale()"
"preferredTextLocale: get_preferred_text_locale()"
);

// run our patched copy of playercore in a non-privileged context on the page
Expand Down
3 changes: 2 additions & 1 deletion content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ chromeStorageGet({
setMaxBitrate: false,
disableVP9: false,
useDDPlus: false,
preferredLocale: "en",
preferredLocale: null,
preferredTextLocale: null,
}).then(items => {
// very messy workaround for accessing chrome storage outside of background / content scripts
let mainScript = document.createElement("script");
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Netflix International",
"description": "Displays all available Netflix audio tracks.",
"version": "2.0.10",
"version": "2.0.11",
"author": "shirt",
"browser_action": {
"default_icon": "img/icon128.png",
Expand Down
39 changes: 38 additions & 1 deletion pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,45 @@
<br>
<input type="checkbox" id="useDDPlus"><label for="useDDPlus">Use Dolby Digital Plus (Chromium Edge)</label>
<br>
<label for="preferredLocale">Preferred language</label>
<label for="preferredLocale">Preferred audio language</label>
<select name="preferredLocale" id="preferredLocale">
<option value="null">None</option>
<option value="ar">ar</option>
<option value="cs">cs</option>
<option value="da">da</option>
<option value="de">de</option>
<option value="el">el</option>
<option value="en">en</option>
<option value="es">es</option>
<option value="fi">fi</option>
<option value="fr">fr</option>
<option value="he">he</option>
<option value="hi">hi</option>
<option value="hr">hr</option>
<option value="hu">hu</option>
<option value="id">id</option>
<option value="it">it</option>
<option value="ja">ja</option>
<option value="ko">ko</option>
<option value="ms">ms</option>
<option value="nb">nb</option>
<option value="nl">nl</option>
<option value="pl">pl</option>
<option value="pt">pt</option>
<option value="ro">ro</option>
<option value="ru">ru</option>
<option value="sv">sv</option>
<option value="ta">ta</option>
<option value="te">te</option>
<option value="th">th</option>
<option value="tr">tr</option>
<option value="uk">uk</option>
<option value="vi">vi</option>
<option value="zh">zh</option>
</select>
<label for="preferredTextLocale">Preferred subtitle language</label>
<select name="preferredTextLocale" id="preferredTextLocale">
<option value="null">None</option>
<option value="ar">ar</option>
<option value="cs">cs</option>
<option value="da">da</option>
Expand Down
6 changes: 5 additions & 1 deletion pages/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function save_options() {
const disableVP9 = document.getElementById("disableVP9").checked;
const useDDPlus = document.getElementById("useDDPlus").checked;
const preferredLocale = document.getElementById("preferredLocale").value;
const preferredTextLocale = document.getElementById("preferredTextLocale").value;

chrome.storage.sync.set({
use6Channels: use6Channels,
Expand All @@ -14,6 +15,7 @@ function save_options() {
disableVP9: disableVP9,
useDDPlus: useDDPlus,
preferredLocale: preferredLocale,
preferredTextLocale: preferredTextLocale,
}, function() {
var status = document.getElementById("status");
status.textContent = "Options saved.";
Expand All @@ -30,14 +32,16 @@ function restore_options() {
setMaxBitrate: false,
disableVP9: false,
useDDPlus: false,
preferredLocale: "en",
preferredLocale: null,
preferredTextLocale: null,
}, function(items) {
document.getElementById("use51").checked = items.use6Channels;
document.getElementById("showAllTracks").checked = items.showAllTracks;
document.getElementById("setMaxBitrate").checked = items.setMaxBitrate;
document.getElementById("disableVP9").checked = items.disableVP9;
document.getElementById("useDDPlus").checked = items.useDDPlus;
document.getElementById("preferredLocale").value = items.preferredLocale;
document.getElementById("preferredTextLocale").value = items.preferredTextLocale;
});
}

Expand Down

0 comments on commit 5216752

Please sign in to comment.