Source for "Youtube Prevent Autoplay"

By Yansky
Has 43 other scripts.


// ==UserScript==
// @name          Youtube Prevent Autoplay
// @namespace     userscripts.org
// @version       0.7
// @description   Prevents videos from playing automatically by replacing the default youtube.com player with the youtube player that doesn't autostart playback
// @include        http://www.youtube.com/watch*
// @include        http://youtube.com/watch*
// @include        http://*.youtube.com/w*
// ==/UserScript==

var vidID;

var dUrl = document.URL

vidID = document.location.toString().split("v=")[1].split("&")[0];

var mp = document.getElementById('movie_player');

var fvars = mp.getAttribute('flashvars');

var l = fvars.slice( fvars.indexOf('&l=')+3, fvars.indexOf( '&', fvars.indexOf('&l=')+3 ) );

var t = fvars.slice( fvars.indexOf('&t=')+3, fvars.indexOf( '&', fvars.indexOf('&t=')+3 ) );  

if( document.getElementById('-moogoo-left-side-cell') ){ //youtube googler compatibility http://userscripts.org/scripts/show/6198

	var vidHeight = document.getElementById('-moogoo-left-side-cell').offsetHeight;

	document.getElementById('playerDiv').innerHTML = 
	'<embed id="movie_player" flashvars="&rs=1&sn=1&hl=en&iurl=http%3A//img.youtube.com/vi/'+vidID+'/default.jpg"'+
	'type="application/x-shockwave-flash" wmode="transparent" src="/player2.swf?video_id='+vidID+'&t='+t+'&l='+l+'"'+
	'height="'+vidHeight+'" width="100%"></embed>';	

	document.getElementById('showRating').addEventListener('mouseup', function() {
	
		var mpNew = document.getElementById('movie_player'); //old mp is gone so gotta grab it again
	
		var cH = mpNew.getAttribute("height");

	  if( document.getElementById('actionsAndStatsDiv').style.display == 'none' ){

		mpNew.setAttribute("height", Number(cH) - 115 ); 

	  }
	  else{

		mpNew.setAttribute("height", Number(cH) + 115 );

	  }  

	}, false);

}
else {

	document.getElementById('watch-player-div').innerHTML = 
	'<embed id="movie_player" flashvars="&rs=1&sn=1&hl=en&iurl=http%3A//img.youtube.com/vi/'+vidID+'/default.jpg"'+
	'type="application/x-shockwave-flash" wmode="transparent" src="/player2.swf?video_id='+vidID+'&t='+t+'&l='+l+'"'+
	'height="395px" width="480px"></embed>';

}