Skip to content

Instantly share code, notes, and snippets.

@ssaavedra
Last active April 9, 2020 01:59
Show Gist options
  • Save ssaavedra/dbc3a1d457ba03684258e65186101796 to your computer and use it in GitHub Desktop.
Save ssaavedra/dbc3a1d457ba03684258e65186101796 to your computer and use it in GitHub Desktop.
PrimeVideo Speed Changer
// ==UserScript==
// @name PrimeVideo/Netflix Speed Changer
// @namespace http://ssaavedra.eu/
// @version 1.2.3
// @description ALlows changing the playback speed on Primevideo and Netflix
// @author ssaavedra
// @homepageURL https://gitlab.com/ssaavedra.eu/userscripts
// @downloadURL https://gitlab.com/ssaavedra.eu/userscripts/-/raw/master/primevideospeedchanger.user.js
// @updateURL https://gitlab.com/ssaavedra.eu/userscripts/-/raw/master/primevideospeedchanger.user.js
// @match https://www.primevideo.com/*
// @match https://www.netflix.com/*
// @grant none
// ==/UserScript==
// License: CC0
(function() {
'use strict';
if(!window.location.href.match(/primevideo.com/)) {
return;
}
let div = document.createElement('div')
let input = document.createElement('input')
let theVideo
input.type = 'number'
input.min = 0.5
input.max = 4
input.step = 0.25
input.size = 2
function changeFn() {
if(theVideo) {
console.log("New value", input.value)
theVideo.playbackRate = input.value
}
}
setInterval(function(){
const videos = Array.prototype.slice.call(document.getElementsByTagName('video')).filter(v => v.src.match(/^blob:/))
if(videos.length <= 0) {
// console.log("No video in this page. Waiting until next tick.")
return;
}
theVideo = videos[0]
input.value = theVideo.playbackRate
if(!div.parentNode) {
div.appendChild(input)
document.querySelector('.right .topButtons .hideableTopButtons').appendChild(div)
input.addEventListener('change', changeFn, false)
}
}, 5000);
})();
(function() {
'use strict';
if(!window.location.href.match(/netflix.com/)) {
return;
}
let div = document.createElement('div')
let input = document.createElement('input')
let theVideo
input.type = 'number'
input.min = 0.5
input.max = 4
input.step = 0.25
input.size = 3
input.style.fontSize = "12pt"
input.style.color = "#000000"
function changeFn() {
if(theVideo) {
console.log("New value", input.value)
theVideo.playbackRate = input.value
}
}
setInterval(function(){
const videos = Array.prototype.slice.call(document.getElementsByTagName('video')).filter(v => v.src.match(/^blob:/))
if(videos.length <= 0) {
return;
}
theVideo = videos[0]
input.value = theVideo.playbackRate
if(!div.parentNode) {
console.log(div)
window._inputDiv = div
div.appendChild(input)
input.addEventListener('change', changeFn, false)
document
.querySelectorAll('.touchable.PlayerControls--control-element.nfp-popup-control.nfp-popup-control--static-position')[0]
.insertAdjacentElement('beforebegin', div)
}
}, 5000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment