Created
March 11, 2018 14:33
-
-
Save RoliSoft/0fbfbf62bc3505aa50c5076f1fa3da0a to your computer and use it in GitHub Desktop.
Tampermonkey script for Netflix which auto-selects the highest bitrate and sets the playback speed to 1.7x.
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
// ==UserScript== | |
// @name Netflix adjustments | |
// @version 0.1 | |
// @author RoliSoft | |
// @match https://*.netflix.com/* | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
GM_addStyle('\ | |
.player-timedtext-text-container > span { \ | |
color: rgb(255, 200, 0) !important; \ | |
font-family: "Segoe UI" !important; \ | |
/* text-transform: lowercase; */ \ | |
} \ | |
'); | |
var previousVideoId = null; | |
setInterval(function() { | |
var videoId; | |
try { | |
videoId = document.querySelector('video[src^="blob:"]').src; | |
} catch (err) { | |
return; | |
} | |
if (videoId != previousVideoId) { | |
console.log('New video detected.'); | |
previousVideoId = videoId; | |
adjustments(); | |
} | |
}, 100); | |
})(); | |
function adjustments() { | |
setPlaybackSpeed(1.7); | |
setHighestBitrate(); | |
} | |
function setHighestBitrate() { | |
var kbEvent = new Event('keydown'); | |
kbEvent.keyCode = 83; | |
kbEvent.ctrlKey = true; | |
kbEvent.shiftKey = true; | |
kbEvent.altKey = true; | |
window.dispatchEvent(kbEvent); | |
var waitStreamList = setInterval(function() { | |
var streams = document.querySelector('.player-streams'); | |
if (streams) clearInterval(waitStreamList); | |
else return; | |
var streamList = streams.querySelectorAll('select[multiple=multiple]')[1]; | |
for (var i = 0; i < streamList.options.length; i++) { | |
streamList.options[i].selected = i == streamList.options.length - 1; | |
if (i == streamList.options.length - 1) { | |
console.log('Setting bitrate to ' + streamList.options[i].text); | |
} | |
} | |
var override = streams.querySelectorAll('button')[0]; | |
override.click(); | |
}, 100); | |
} | |
function setPlaybackSpeed(speed) { | |
var vids = document.querySelectorAll('video'); | |
for (var i = 0; i < vids.length; i++) { | |
console.log('Setting playback speed to ' + speed); | |
vids[i].playbackRate = speed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why the hell does it set the playback speed to 1.7? xD