Skip to content

Instantly share code, notes, and snippets.

@to
Created August 14, 2010 05:02
Show Gist options
  • Select an option

  • Save to/523996 to your computer and use it in GitHub Desktop.

Select an option

Save to/523996 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name YouTube Manual Play
// @include http://www.youtube.com/watch*
// @include http://youtube.com/watch*
// ==/UserScript==
(function(){
var player = document.getElementById('movie_player');
if(!player)
return;
var values = {
autoplay : 1,
enablejsapi : 1,
iv_load_policy : 3,
fs : 1,
vq : 'large', // medium large hd720 hd1080
invideo : false,
}
var clone = player.cloneNode(true).wrappedJSObject;
var vars = player.getAttribute('flashvars');
for(var key in values){
vars = vars.replace(new RegExp(key + '=.+?(&|$)', 'g'), '') +
'&' + key + '=' + values[key];
}
clone.setAttribute('flashvars', vars.
replace(/&&/g, '&').
replace(/[\&\?]?(ad_|infringe|invideo|watermark)([^=]*)?=[^\&]*/gi, '').
replace(/(^[\&\?]*)|([\&\?]*$)/g, ''));
player.parentNode.replaceChild(clone, player);
player = clone;
var iid = window.setInterval(function(){
if(player.getPlayerState && player.getPlayerState()==1){
clearInterval(iid);
player.seekTo(0);
player.pauseVideo();
}
}, 100);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment