// ==UserScript== // @name Youtube Prevent Autoplay with alternate player // @namespace userscripts.org // @version 0.1 // @description Prevents videos from playing automatically by replacing the default youtube.com player with a player that doesn't autostart playback // @include http://www.youtube.com/watch* // @include http://youtube.com/watch* // ==/UserScript== var vidID; var dUrl = document.URL if( dUrl.indexOf('&') > -1 ){ vidID = dUrl.slice( dUrl.indexOf('watch?v=')+8, dUrl.indexOf('&') ); } else{ vidID = dUrl.slice( dUrl.indexOf('watch?v=')+8); } var http_request = false; function makeRequest(url) { http_request = new XMLHttpRequest(); http_request.onreadystatechange = getStuff; http_request.open('GET', url, true); http_request.send(null); } function getStuff() { if (http_request.readyState == 4) { var vidUrl = http_request.getResponseHeader('Location'); console.log(http_request.getAllResponseHeaders()); console.log(vidUrl); document.getElementById('playerDiv').innerHTML = ''; } } var fv = document.getElementById('movie_player').getAttribute('flashvars'); var srcWithT = 'http://youtube.com/get_video?video_id='+vidID+'&'+fv.slice(fv.indexOf('t='), fv.indexOf('&sk=')); console.log('srcWithT '+srcWithT); makeRequest(srcWithT);