mirror of
https://github.com/shirt-dev/netflix-international.git
synced 2025-05-03 16:30:33 +00:00
Fix indentation, bump version
This commit is contained in:
parent
28b4b01913
commit
099dfd0107
3 changed files with 70 additions and 68 deletions
|
@ -2,7 +2,7 @@
|
|||
"manifest_version": 2,
|
||||
"name": "Netflix International",
|
||||
"description": "Displays all available Netflix audio tracks.",
|
||||
"version": "2.0.3",
|
||||
"version": "2.0.4",
|
||||
"author": "shirt",
|
||||
"browser_action": {
|
||||
"default_icon": "img/icon128.png"
|
||||
|
|
|
@ -1,46 +1,47 @@
|
|||
/* eslint-disable no-undef */
|
||||
let getElementByXPath = function (xpath) {
|
||||
return document.evaluate(
|
||||
xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
|
||||
).singleNodeValue;
|
||||
return document.evaluate(
|
||||
xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
|
||||
).singleNodeValue;
|
||||
};
|
||||
|
||||
const fn = function () {
|
||||
window.dispatchEvent(new KeyboardEvent('keydown', {
|
||||
keyCode: 83,
|
||||
ctrlKey: true,
|
||||
altKey: true,
|
||||
shiftKey: true,
|
||||
}));
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", {
|
||||
keyCode: 83,
|
||||
ctrlKey: true,
|
||||
altKey: true,
|
||||
shiftKey: true,
|
||||
}));
|
||||
|
||||
const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate']");
|
||||
const AUDIO_SELECT = getElementByXPath("//div[text()='Audio Bitrate']");
|
||||
const BUTTON = getElementByXPath("//button[text()='Override']");
|
||||
const VIDEO_SELECT = getElementByXPath("//div[text()='Video Bitrate']");
|
||||
const AUDIO_SELECT = getElementByXPath("//div[text()='Audio Bitrate']");
|
||||
const BUTTON = getElementByXPath("//button[text()='Override']");
|
||||
|
||||
if (!(VIDEO_SELECT && AUDIO_SELECT && BUTTON)){
|
||||
return false;
|
||||
}
|
||||
if (!(VIDEO_SELECT && AUDIO_SELECT && BUTTON)){
|
||||
return false;
|
||||
}
|
||||
|
||||
[VIDEO_SELECT, AUDIO_SELECT].forEach(function (el) {
|
||||
let parent = el.parentElement;
|
||||
[VIDEO_SELECT, AUDIO_SELECT].forEach(function (el) {
|
||||
let parent = el.parentElement;
|
||||
|
||||
let options = parent.querySelectorAll('select > option');
|
||||
let options = parent.querySelectorAll("select > option");
|
||||
|
||||
for (var i = 0; i < options.length - 1; i++) {
|
||||
options[i].removeAttribute('selected');
|
||||
}
|
||||
for (var i = 0; i < options.length - 1; i++) {
|
||||
options[i].removeAttribute("selected");
|
||||
}
|
||||
|
||||
options[options.length - 1].setAttribute('selected', 'selected');
|
||||
});
|
||||
options[options.length - 1].setAttribute("selected", "selected");
|
||||
});
|
||||
|
||||
BUTTON.click();
|
||||
BUTTON.click();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
};
|
||||
|
||||
let run = function () {
|
||||
if (!fn()) {
|
||||
setTimeout(run, 100);
|
||||
}
|
||||
if (!fn()) {
|
||||
setTimeout(run, 100);
|
||||
}
|
||||
};
|
||||
|
||||
const WATCH_REGEXP = /netflix.com\/watch\/.*/;
|
||||
|
@ -48,15 +49,15 @@ const WATCH_REGEXP = /netflix.com\/watch\/.*/;
|
|||
let oldLocation;
|
||||
|
||||
if(globalOptions.setMaxBitrate) {
|
||||
console.log("netflix_max_bitrate.js enabled");
|
||||
setInterval(function () {
|
||||
let newLocation = window.location.toString();
|
||||
console.log("netflix_max_bitrate.js enabled");
|
||||
setInterval(function () {
|
||||
let newLocation = window.location.toString();
|
||||
|
||||
if (newLocation !== oldLocation) {
|
||||
oldLocation = newLocation;
|
||||
if (WATCH_REGEXP.test(newLocation)) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
if (newLocation !== oldLocation) {
|
||||
oldLocation = newLocation;
|
||||
if (WATCH_REGEXP.test(newLocation)) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
|
|
@ -1,36 +1,37 @@
|
|||
/* eslint-disable no-undef */
|
||||
function save_options() {
|
||||
const use6Channels = document.getElementById("use51").checked;
|
||||
const showAllTracks = document.getElementById("showAllTracks").checked;
|
||||
const setMaxBitrate = document.getElementById("setMaxBitrate").checked;
|
||||
const disableVP9 = document.getElementById("disableVP9").checked;
|
||||
const use6Channels = document.getElementById("use51").checked;
|
||||
const showAllTracks = document.getElementById("showAllTracks").checked;
|
||||
const setMaxBitrate = document.getElementById("setMaxBitrate").checked;
|
||||
const disableVP9 = document.getElementById("disableVP9").checked;
|
||||
|
||||
chrome.storage.sync.set({
|
||||
use6Channels,
|
||||
showAllTracks,
|
||||
setMaxBitrate,
|
||||
disableVP9,
|
||||
}, function() {
|
||||
var status = document.getElementById('status');
|
||||
status.textContent = 'Options saved.';
|
||||
setTimeout(function() {
|
||||
status.textContent = '';
|
||||
}, 750);
|
||||
});
|
||||
chrome.storage.sync.set({
|
||||
use6Channels,
|
||||
showAllTracks,
|
||||
setMaxBitrate,
|
||||
disableVP9,
|
||||
}, function() {
|
||||
var status = document.getElementById("status");
|
||||
status.textContent = "Options saved.";
|
||||
setTimeout(function() {
|
||||
status.textContent = "";
|
||||
}, 750);
|
||||
});
|
||||
}
|
||||
|
||||
function restore_options() {
|
||||
chrome.storage.sync.get({
|
||||
use6Channels: true,
|
||||
showAllTracks: true,
|
||||
setMaxBitrate: false,
|
||||
disableVP9: false,
|
||||
}, 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;
|
||||
});
|
||||
chrome.storage.sync.get({
|
||||
use6Channels: true,
|
||||
showAllTracks: true,
|
||||
setMaxBitrate: false,
|
||||
disableVP9: false,
|
||||
}, 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.addEventListener('DOMContentLoaded', restore_options);
|
||||
document.getElementById('save').addEventListener('click', save_options);
|
||||
document.addEventListener("DOMContentLoaded", restore_options);
|
||||
document.getElementById("save").addEventListener("click", save_options);
|
Loading…
Add table
Reference in a new issue