mirror of
https://github.com/shirt-dev/netflix-international.git
synced 2025-06-22 00:36:43 +00:00
v2.0.3
Cleaned up code, fixed CSS issues caused by Netflix update
This commit is contained in:
parent
4383594d23
commit
2380097d45
7 changed files with 100 additions and 65 deletions
|
@ -1,8 +1,9 @@
|
|||
/* eslint-disable no-undef */
|
||||
|
||||
script_urls = [];
|
||||
var script_urls = [];
|
||||
|
||||
urls = [
|
||||
'netflix_max_bitrate.js'
|
||||
var urls = [
|
||||
"netflix_max_bitrate.js"
|
||||
];
|
||||
|
||||
// https://stackoverflow.com/a/45985333
|
||||
|
@ -20,50 +21,50 @@ function getBrowser() {
|
|||
|
||||
// promisify chrome storage API for easier chaining
|
||||
function chromeStorageGet(opts) {
|
||||
if (getBrowser() == "Firefox") {
|
||||
return chrome.storage.sync.get(opts);
|
||||
}
|
||||
else {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.sync.get(opts, resolve);
|
||||
});
|
||||
}
|
||||
if (getBrowser() == "Firefox") {
|
||||
return chrome.storage.sync.get(opts);
|
||||
}
|
||||
else {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.sync.get(opts, resolve);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function attachScript(resp) {
|
||||
let xhr = resp.target;
|
||||
let mainScript = document.createElement('script');
|
||||
mainScript.type = 'application/javascript';
|
||||
if (xhr.status == 200) {
|
||||
mainScript.text = xhr.responseText;
|
||||
document.documentElement.appendChild(mainScript);
|
||||
}
|
||||
let xhr = resp.target;
|
||||
let mainScript = document.createElement("script");
|
||||
mainScript.type = "application/javascript";
|
||||
if (xhr.status == 200) {
|
||||
mainScript.text = xhr.responseText;
|
||||
document.documentElement.appendChild(mainScript);
|
||||
}
|
||||
}
|
||||
|
||||
chromeStorageGet({
|
||||
use6Channels: true,
|
||||
showAllTracks: true,
|
||||
setMaxBitrate: false,
|
||||
disableVP9: false,
|
||||
use6Channels: true,
|
||||
showAllTracks: true,
|
||||
setMaxBitrate: false,
|
||||
disableVP9: false,
|
||||
}).then(items => {
|
||||
// very messy workaround for accessing chrome storage outside of background / content scripts
|
||||
let mainScript = document.createElement('script');
|
||||
mainScript.type = 'application/javascript';
|
||||
mainScript.text = `var globalOptions = JSON.parse('${JSON.stringify(items)}');`;
|
||||
document.documentElement.appendChild(mainScript);
|
||||
// very messy workaround for accessing chrome storage outside of background / content scripts
|
||||
let mainScript = document.createElement("script");
|
||||
mainScript.type = "application/javascript";
|
||||
mainScript.text = `var globalOptions = JSON.parse('${JSON.stringify(items)}');`;
|
||||
document.documentElement.appendChild(mainScript);
|
||||
}).then(() => {
|
||||
// attach and include additional scripts after we have loaded the main configuration
|
||||
for (let i = 0; i < script_urls.length; i++) {
|
||||
let script = document.createElement('script');
|
||||
script.src = script_urls[i];
|
||||
document.documentElement.appendChild(script);
|
||||
}
|
||||
// attach and include additional scripts after we have loaded the main configuration
|
||||
for (let i = 0; i < script_urls.length; i++) {
|
||||
let script = document.createElement("script");
|
||||
script.src = script_urls[i];
|
||||
document.documentElement.appendChild(script);
|
||||
}
|
||||
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
let mainScriptUrl = chrome.extension.getURL(urls[i]);
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', mainScriptUrl, true);
|
||||
xhr.onload = attachScript;
|
||||
xhr.send();
|
||||
}
|
||||
});
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
let mainScriptUrl = chrome.extension.getURL(urls[i]);
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", mainScriptUrl, true);
|
||||
xhr.onload = attachScript;
|
||||
xhr.send();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue