Last active
January 21, 2018 12:25
-
-
Save Yonezpt/f13d315cd4dea79fd004 to your computer and use it in GitHub Desktop.
YouTube force playback quality
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== | |
// @version 1.0.1 | |
// @name YouTube force playback quality | |
// @match *://www.youtube.com/* | |
// @run-at document-start | |
// @grant none | |
// @noframes | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
var injection, | |
content = function() { | |
function playerReady(api) { | |
function stateChange() { | |
api.setPlaybackQuality('tiny'); | |
} | |
api.addEventListener('onStateChange', stateChange); | |
} | |
function detour(a){ | |
return function (b) { | |
a.apply(this, arguments); | |
playerReady(b); | |
} | |
} | |
window.onYouTubePlayerReady = detour(window.onYouTubePlayerReady); | |
}; | |
injection = document.createElement('script'); | |
injection.textContent = '(' + content + '())'; | |
document.documentElement.appendChild(injection); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you make scripts that set a timer to automatically pause/stop on all Youtube embed videos? Like pause a video after X seconds!!?