Last active
March 31, 2018 09:23
-
-
Save thienha1/6e21ee2a2a9d62ea40f9edacec464261 to your computer and use it in GitHub Desktop.
Youtubespeed
This file contains hidden or 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 Youtubespeed | |
// @namespace Youtubespeed | |
// @include https://www.youtube.com/* | |
// @version 1 | |
// ==/UserScript== | |
var playspeed = 0.25, //---> set the speed you want here (replace "3.5", don't remove the comma behind it) | |
prevspeed = 0, | |
rprevspeed = 0, | |
curspeed = 0, | |
curtime = 0, | |
sdif = 0, | |
bleh = 0; | |
setInterval(function(){ | |
try { | |
curspeed = Math.round(10 * document.getElementsByClassName('html5-main-video')[0].playbackRate) / 10; | |
curtime = 0; | |
try {curtime = document.getElementById("movie_player").getCurrentTime();} | |
catch(err) {} | |
if (prevspeed === 0){ | |
rprevspeed = 1; | |
} else { | |
rprevspeed = prevspeed; | |
} | |
if(curspeed != prevspeed){ | |
sdif = Math.round(10 * (curspeed - prevspeed)) / 10; | |
if (sdif > 0){sdif = "+" + sdif;} | |
console.log("Speed changed to " + curspeed + " (previously it was " + prevspeed + "). " + sdif); | |
} | |
if (curspeed == 1 && rprevspeed > 1.01 && curtime < 3){ | |
document.getElementsByClassName('html5-main-video')[0].playbackRate = rprevspeed; | |
} else if (curspeed == 1 && curtime < 3){ | |
document.getElementsByClassName('html5-main-video')[0].playbackRate = playspeed; | |
} else if (curspeed == 4){ | |
document.getElementsByClassName('html5-main-video')[0].playbackRate = 3.999; | |
} | |
prevspeed = curspeed; | |
} | |
catch(err) {} | |
}, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment