Add support for both the old and new player; Don't inject speed-contrl twice
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name netflix-speed
|
||||
// @version 0.1
|
||||
// @version 0.2
|
||||
// @include https://www.netflix.com/*
|
||||
// ==/UserScript==
|
||||
|
||||
@@ -10,9 +10,13 @@ function find_controls() {
|
||||
mutationsList.forEach(function(mutation) {
|
||||
var nodes = Array.from(mutation.addedNodes);
|
||||
for (var node of nodes) {
|
||||
if (node.parentNode && node.parentNode.matches && node.parentNode.matches('.PlayerControlsNeo__controls-group')) {
|
||||
observer.disconnect();
|
||||
resolve(node.parentNode);
|
||||
console.log(node);
|
||||
if (node.matches && node.matches('.classic-ui') && node.querySelector('.button-volumeMax')) {
|
||||
resolve(node.querySelector('.button-volumeMax').parentNode);
|
||||
return;
|
||||
}
|
||||
if (node.matches && node.matches('.AkiraPlayer') && node.querySelector('.button-nfplayerNextEpisode')) {
|
||||
resolve(node.querySelector('.button-nfplayerNextEpisode').parentNode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +29,10 @@ function find_controls() {
|
||||
|
||||
function inject_controls() {
|
||||
find_controls().then(function(controls) {
|
||||
if (document.querySelector('#speed-control'))
|
||||
return;
|
||||
var speed_control = document.createElement('select');
|
||||
speed_control.id = 'speed-control';
|
||||
speed_control.style.cssText = `
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
@@ -33,9 +40,9 @@ function inject_controls() {
|
||||
-moz-appearance: none;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
font-size: 1.96em;
|
||||
padding-bottom: 0.84em;
|
||||
font-size: 2.2em;
|
||||
`;
|
||||
speed_control.id = 'speed-control';
|
||||
speed_control.onchange = function() {
|
||||
document.querySelector('.VideoContainer video').playbackRate = this.value;
|
||||
};
|
||||
@@ -47,7 +54,7 @@ function inject_controls() {
|
||||
<option value=1.75>1.75</option>
|
||||
<option value=2.0>2.0</option>`;
|
||||
|
||||
controls.appendChild(speed_control);
|
||||
controls.after(speed_control);
|
||||
|
||||
inject_controls();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user