diff --git a/manifest.json b/manifest.json index 4a8db55..688e80b 100644 --- a/manifest.json +++ b/manifest.json @@ -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" diff --git a/netflix_max_bitrate.js b/netflix_max_bitrate.js index a2f3551..048d2fb 100644 --- a/netflix_max_bitrate.js +++ b/netflix_max_bitrate.js @@ -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); } diff --git a/pages/options.js b/pages/options.js index 894a21f..036b895 100644 --- a/pages/options.js +++ b/pages/options.js @@ -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); \ No newline at end of file +document.addEventListener("DOMContentLoaded", restore_options); +document.getElementById("save").addEventListener("click", save_options); \ No newline at end of file