Skip to content

Commit

Permalink
Fix indentation, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
shirt-dev committed Sep 8, 2021
1 parent 28b4b01 commit 099dfd0
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 69 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
79 changes: 40 additions & 39 deletions netflix_max_bitrate.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
/* 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\/.*/;

let oldLocation;

if(globalOptions.setMaxBitrate) {
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);
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);
}
59 changes: 30 additions & 29 deletions pages/options.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 099dfd0

Please sign in to comment.