Fix indentation, bump version

This commit is contained in:
shirtjs 2021-09-08 10:51:45 -04:00
parent 28b4b01913
commit 099dfd0107
3 changed files with 70 additions and 68 deletions

View file

@ -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);
}