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