forked from truedread/netflix-1080p
-
Notifications
You must be signed in to change notification settings - Fork 57
/
content_script.js
40 lines (34 loc) · 1.1 KB
/
content_script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const INTERNAL_SCRIPTS = [
'netflix_max_bitrate.js'
];
// promisify chrome storage API for easier chaining
function chromeStorageGet(opts) {
return new Promise(resolve => {
chrome.storage.sync.get(opts, resolve);
});
}
function addSettingsToHtml(settings) {
const mainScript = document.createElement('script');
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 => {
addSettingsToHtml(items);
}).then(() => {
for (let i = 0; i < INTERNAL_SCRIPTS.length; i++) {
const mainScriptUrl = chrome.runtime.getURL(INTERNAL_SCRIPTS[i]);
const mainScript = document.createElement('script');
mainScript.type = 'application/javascript';
mainScript.src = mainScriptUrl;
document.documentElement.appendChild(mainScript);
}
});