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