-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |