// ==UserScript==
// @name FreeTube : débridage Youtube by rAthur & NoEx
// @description FreeTube débride les vidéos Youtube pour ne plus qu'elles galèrent leur race quand on est chez Free ;)
// @namespace [m.T.m]
// @include http*://*youtube.*/watch*
// @include http://*.proxfree.com/*
// @icon http://rathur.fr/greasemonkey/Youtube/icon.png
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require http://rathur.fr/greasemonkey/Youtube/flowplayer-3.2.11.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// ==/UserScript==
var counter = GM_getValue('counter', 0);
console.log('Ce script a été initialisé ' + counter + ' fois.');
GM_setValue('counter', ++counter);
/****************/
/****************/
/** EVERY GO ! **/
/****************/
/****************/
var h_debride = 430;
if (location.href.match(/^http\:\/\/www\.youtube\.com\/watch/) || location.href.match(/^https\:\/\/www\.youtube\.com\/watch/))
{
var w_normal = $('#watch7-player').width();
var h_normal = $('#watch7-player').height();
GM_setValue('videocode', $(location).attr('href').split('v=')[1].split('&')[0].split('#')[0]);
$('#logo-container').html('');
GM_addStyle('#iframe { width: '+w_normal+'px; height: '+h_debride+'px; margin: 0; padding: 0; }');
$('#watch7-player').animate({'height':h_debride+'px'},500);
if ($('#watch7-playlist-tray').size()>0)
{
GM_setValue('next_url', encodeURIComponent($('#watch7-playlist-tray').find('.video-list-item').eq($('li.playlist-bar-item-playing').index()+1).find('a').attr('href')));
if (/chrome/.test(navigator.userAgent.toLowerCase())==true)
{
$('#watch7-video').append('
Attention : la lecture de playlist ne fonctionne pas sur Chrome, il faudra donc manuellement passer à la vidéo suivante, ou uliliser Firefox !
');
GM_addStyle('#playlist_chrome { position: absolute; right: 0; bottom: 0; width: 300px; height: 40px; background: #cc0000; color: #fff; padding: 0 2px 0 3px; }');
}
else
{
$('#watch7-video').append('La gestion de playlists est prise en compte, le passage à la vidéo suivante et son débridage seront automatiques !
');
GM_addStyle('#playlist_chrome { position: absolute; right: 0; bottom: 0; width: 300px; height: 40px; background: #009900; color: #fff; padding: 0 2px 0 3px; }');
}
}
$('#watch7-player').html('');
removePlayers = function()
{
if ($('embed').size()>0)
$('embed').remove();
if ($('object').size()>0)
$('object').remove();
}
setInterval(function(){ removePlayers(); }, 1000);
/** Gestion du lien de recherche du MP3 **/
var titre = $('.watch-title').html();
function strtr (str, from, to)
{
var fr = '',
i = 0,
j = 0,
lenStr = 0,
lenFrom = 0,
tmpStrictForIn = false,
fromTypeStr = '',
toTypeStr = '',
istr = '';
var tmpFrom = [];
var tmpTo = [];
var ret = '';
var match = false;
// Received replace_pairs?
// Convert to normal from->to chars
if (typeof from === 'object') {
tmpStrictForIn = this.ini_set('phpjs.strictForIn', false); // Not thread-safe; temporarily set to true
from = this.krsort(from);
this.ini_set('phpjs.strictForIn', tmpStrictForIn);
for (fr in from) {
if (from.hasOwnProperty(fr)) {
tmpFrom.push(fr);
tmpTo.push(from[fr]);
}
}
from = tmpFrom;
to = tmpTo;
}
// Walk through subject and replace chars when needed
lenStr = str.length;
lenFrom = from.length;
fromTypeStr = typeof from === 'string';
toTypeStr = typeof to === 'string';
for (i = 0; i < lenStr; i++) {
match = false;
if (fromTypeStr) {
istr = str.charAt(i);
for (j = 0; j < lenFrom; j++) {
if (istr == from.charAt(j)) {
match = true;
break;
}
}
} else {
for (j = 0; j < lenFrom; j++) {
if (str.substr(i, from[j].length) == from[j]) {
match = true;
// Fast forward
i = (i + from[j].length) - 1;
break;
}
}
}
if (match) {
ret += toTypeStr ? to.charAt(j) : to[j];
} else {
ret += str.charAt(i);
}
}
return ret;
}
var titre_simple = titre.replace(/^(\s*)|(\s*)$/g,'');
titre_simple = titre_simple.replace(/\&/g,' ');
titre_simple = strtr(titre_simple,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ','aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
titre_simple = titre_simple.replace(/[^a-zA-Z0-9]HQ[^a-zA-Z0-9]/ig,' ');
titre_simple = titre_simple.replace(/[^a-zA-Z0-9]HD[^a-zA-Z0-9]/ig,' ');
titre_simple = titre_simple.replace(/[^a-zA-Z0-9]/ig,' ');
titre_simple = titre_simple.replace(/[ ]{1,}/ig,' ');
var lien_mp3 = 'https://www.google.fr/search?q=site:zippyshare.com mp3 '+titre_simple;
$('.watch-title').html(''+titre+'');
$('#watch7-main-container').on('click', 'a', function()
{
if ($(this).attr('onclick').match(/^yt\.www\.watch\.player\.seekTo\(/))
{
var time = eval($(this).attr('onclick').split('(')[1].split(')')[0]);
frames[0].postMessage(time, 'http://rathur.fr/greasemonkey/Youtube/player.php?url=*');
window.scrollTo(0,0);
}
return false;
});
}
else if (location.href.match(/^http\:\/\/fr\.proxfree\.com/))
{
if ($('#watch7-video').size()>0)
{
GM_setValue('videocode', 0);
var next_url = GM_getValue('next_url', 0);
if (!next_url)
next_url = '';
GM_setValue('next_url', 0);
if (/chrome/.test(navigator.userAgent.toLowerCase())==false)
{
var vars = decodeURIComponent($('embed').attr('flashvars').split('config=')[1]);
var vars_json = eval("("+vars+")");
var url = vars_json.clip.url;
$('body').html($('#watch7-video').find('div').eq(0).html());
removeEmbed = function()
{
if ($('embed').size()>0)
$('embed').remove();
else
setTimeout(function(){ removeEmbed(); }, 100);
}
removeEmbed();
var quality_links = $('body').html();
document.location.href = 'http://rathur.fr/greasemonkey/Youtube/player.php?url='+encodeURIComponent(url)+'&next_url='+encodeURIComponent(next_url)+'#'+encodeURIComponent(quality_links);
}
else
{
$('body').html($('#watch7-video').find('div').eq(0).html());
GM_addStyle('body { overflow: hidden; text-align: center; color: #666; }');
$('b').eq(0).html("Qualité de la vidéo :");
$('b').eq(1).html("Qualité par défaut :");
}
}
else
{
var videocode = GM_getValue('videocode', 0);
if (videocode)
{
GM_addStyle('body { overflow: hidden; text-align: center; }');
$('body').append('Chargement de la vidéo débridée...
');
GM_addStyle('#debridageencours { width: 100%; height: '+h_debride+'px; line-height: '+h_debride+'px; text-align: center; background: #000; color: #fff; position: fixed; left: 0; top: 0; z-index: 10000000; }');
$('.pfaddressBar').val('http://www.youtube.com/watch?v='+videocode);
$('form').eq(0).submit();
}
}
}