Sunday, January 23, 2011

Better, enhanced YouTube alternative player - JW Player


// ==UserScript==
// @name           YouTube alternative player - JW Player
// @description    Replaces YouTube standard player with latest JW Player.
// @include        http://*.youtube.com/watch?*v=*
// @include        http://youtube.com/watch?*v=*
// @include        http://*youtube.com/*
// @author         clicker - clickerinjo [at] gmail [dot] com
// @version                     1.0.1
// @license                     Free to copy and improve
// ==/UserScript==


function show() {
 // Remove original player and take flashvars
 original_player = document.getElementById('movie_player');
 var container = original_player.parentNode;
 container.removeChild(original_player);
 flashvars = to_array(original_player.getAttribute('flashvars'));

 // vidID
 var vidID = flashvars['video_id']; 
  
 // Create player
 var player = document.createElement( "embed" );
  player.setAttribute( "height", original_player.getAttribute( "height" ) );
  player.setAttribute( "width", original_player.getAttribute( "width" ) );
  player.setAttribute( "type", "application/x-shockwave-flash" );
  player.setAttribute( "src", "http://player.longtailvideo.com/player.swf" );
  player.setAttribute( "id", original_player.getAttribute( "id" ) );
  player.setAttribute( "allowscriptaccess", original_player.getAttribute( "allowscriptaccess" ) );
  player.setAttribute( "allowfullscreen", original_player.getAttribute( "allowfullscreen" ) );
  player.setAttribute( "flashvars", 'plugins=fbit-1,tweetit-1,gimme-1,shortcuts-1&gimme.url=http://www.google.hr/#q=Donations+on+moneybookers.com%3A+clickerinjo%40gmail.com+thx&gimme.target=_blank&skin=http%3A//www.longtailvideo.com/files/skins/modieus/5/modieus.zip&autostart=true&file=http://www.youtube.com/watch?v='+vidID);
  container.appendChild( player );

}

var to_array = function( raw ) {
    var raw = raw.split( "&" );
    var parameters = new Array;
    for( i in raw ){
        parameters[raw[i].split( "=" )[0]] = raw[i].split( "=" )[1];
    }
    return parameters;
}


show();
document.getElementById('movie_player').focus();

0 comments:

Post a Comment