Skip to content

Commit

Permalink
Make 5.1 audio work again
Browse files Browse the repository at this point in the history
Add rudimentary but functional Firefox options panel with checkbox to offer 5.1 audio if available.
  • Loading branch information
okradonkey committed Sep 12, 2019
1 parent 907f966 commit 85dccfb
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ urls = [
'get_manifest.js'
]


// very messy workaround for accessing chrome storage outside of background / content scripts
browser.storage.sync.get(['use6Channels'], function(items) {
var use6Channels = items.use6Channels;
var mainScript = document.createElement('script');
mainScript.type = 'application/javascript';
mainScript.text = 'var use6Channels = ' + use6Channels + ';';
document.documentElement.appendChild(mainScript);
});

for (var i = 0; i < urls.length; i++) {
var mainScriptUrl = chrome.extension.getURL(urls[i]);

Expand Down
2 changes: 1 addition & 1 deletion src/get_manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var profiles = [
];


if(window.use6Channels)
if(use6Channels)
profiles.push("heaac-5.1-dash");

var messageid = Math.floor(Math.random() * 2**52);
Expand Down
16 changes: 14 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
"*://assets.nflxext.com/*/ffe/player/html/*",
"*://www.assets.nflxext.com/*/ffe/player/html/*",
"*://netflix.com/*",
"*://www.netflix.com/*"
]
"*://www.netflix.com/*",
"storage"
],

"options_ui": {
"page": "options.html"
},

"applications": {
"gecko": {
"id": "netflix-1080p-firefox@vladikoff"
}
}

}
36 changes: 36 additions & 0 deletions src/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<style>
body {
margin: 2em 3em;
}
.pref-box {
display: block;
margin: 1em 0;;
}
label, input {
line-height: 150%;
}
</style>
</head>

<body>
<div class="pref-box">
<label>
<input type="checkbox" id="5.1">Use 5.1 audio when available</input>
</label>
</div>

<div id="status"></div>

<div class="pref-box">
<button id="save">Save</button>
</div>

<script src="options.js"></script>
</body>

</html>
35 changes: 35 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function save_options(e) {
e.preventDefault();
var use6Channels = document.getElementById('5.1').checked;
// var setMaxBitrate = document.getElementById('setMaxBitrate').checked;
browser.storage.sync.set({
use6Channels: use6Channels,
// setMaxBitrate: setMaxBitrate
}, function() {
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}

function restore_options() {
function setCurrentChoice(result) {
document.getElementById('5.1').checked = result.use6Channels;
// document.getElementById('setMaxBitrate').checked = result.setMaxBitrate;
}
function onError(error) {
console.log(`Error: ${error}`);
}

var getting = browser.storage.sync.get({
use6Channels: false,
// setMaxBitrate: false
});
getting.then(setCurrentChoice, onError);

}

document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click', save_options);

0 comments on commit 85dccfb

Please sign in to comment.