-
Notifications
You must be signed in to change notification settings - Fork 303
/
netflix_max_bitrate.js
41 lines (32 loc) · 1.11 KB
/
netflix_max_bitrate.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
41
let getElementByXPath = function(xpath) {
return document.evaluate(
xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
).singleNodeValue;
};
let doSetMaxBitrate = function() {
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']");
if (!VIDEO_SELECT || !AUDIO_SELECT || !BUTTON) {
return false;
}
[VIDEO_SELECT, AUDIO_SELECT].forEach(function (el) {
let parent = el.parentElement;
let options = parent.querySelectorAll('select > option');
if (options.length < 1) {
return false;
}
for (var i = 0; i < options.length - 1; i++) {
options[i].removeAttribute('selected');
}
options[options.length - 1].setAttribute('selected', 'selected');
});
BUTTON.click();
return true;
};