// ==UserScript== // @name Video.mediaset.it native video player and direct links // @namespace http://andrealazzarotto.com // @description This script allows you to watch and download videos on Video Mediaset. // @include http://www.video.mediaset.it/video/* // @include http://*.video.mediaset.it/player/playerIFrame* // @include http://www.mediaset.it/* // @include http://www.tgcom24.mediaset.it/video/ // @version 6.2.4 // @require http://code.jquery.com/jquery-latest.min.js // @grant GM_xmlhttpRequest // @connect mediaset.it // @connect video.mediaset.it // @connect cdnselector.xuniplay.fdnames.com // @connect video.lazza.dk // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html // @downloadURL none // ==/UserScript== var silverlight = function() { return !!unsafeWindow.Silverlight && !!unsafeWindow.Silverlight.isInstalled(); }; var boxStyle = function(selector, color, textcolor) { $(selector).css({ 'padding': '.5em', 'margin': '1em 4em', 'text-align': 'center', 'background-color': color, 'color': textcolor }); $(selector + ' a').css('color', textcolor); }; var writeLive = function(stream, highquality) { $('
Flusso della diretta da aprire con VLC o avplay
:
' + stream + '
')
.append('Flusso a qualità più alta:
') .append('' + highquality + '
');
boxStyle('#stream-url', 'rgba(255,255,255,0.5)', 'black');
$('#stream-url p').css('font-size', '15px');
// kill login timeout
unsafeWindow.userNotLogged = function() { return; };
$('.countdown').remove();
// Firefox does not display the error correctly
var obj = $('#video-player > object');
if(!silverlight() && !!obj.length) {
$('Il tuo browser non supporta la riproduzione. Trovi sotto i link ai flussi in diretta.
') .append('— Andrea Lazzarotto
') .css({ 'background-color': 'black', 'margin': '3em', 'text-align': 'center', 'font-size': '15px' }); $('#custom-error img').css({ 'margin-bottom': '4em', 'display': 'inline-block' }); }; var handleLive = function(playlistUri) { GM_xmlhttpRequest({ method: 'GET', url: playlistUri, headers: { 'Accept': 'application/atom+xml,application/xml,text/xml' }, onload: function(responseDetails) { var r = responseDetails.responseText; var doc = $.parseXML(r); var $xml = $( doc ); var videoID = $xml.find('videoUrl').text(); GM_xmlhttpRequest({ method: 'GET', url: 'http://cdnselector.xuniplay.fdnames.com/GetCDN.aspx?type=livehls&streamid=' + videoID, headers: { 'Accept': 'application/atom+xml,application/xml,text/xml' }, onload: function(responseDetails) { var r = responseDetails.responseText; var doc = $.parseXML(r); var $xml = $( doc ); var src = $xml.find('video').attr('src'); var highquality = src.replace('index.m3u8', 'Stream(04)/index.m3u8'); writeLive(src, highquality); } }); } }); }; var fix_videoplayer = function() { setTimeout(function() { if($('#videoPlayer').length) { $('#videoPlayer').remove(); } else { setTimeout(arguments.callee, 400); } }, 400); } var initialize = function(id) { $('#myVideoContainer').remove(); $('.video-player') .prepend('') .prepend( '' ); fix_videoplayer(); console.debug('Initialized.'); } $(document).ready(function(){ // handle live stream var playlistUri = (unsafeWindow.playlistUri || null); if (playlistUri !== null) return handleLive('http://www.mediaset.it' + playlistUri); // check if it contains a video if (unsafeWindow.CDN_SELECTOR_URL === null) return; if(!silverlight()) { unsafeWindow.CDN_SELECTOR_URL = "http://video.lazza.dk/vd.php?id="; unsafeWindow.CDN_SELECTOR_SECURE_URL = "https://video.lazza.dk/vd.php?id="; } // kill ads unsafeWindow.adsEnabled = false; var loc = window.location; var isIframe = (loc.href.indexOf("playerIFrame") > 0); var id = (unsafeWindow.videoMetadataId) || 0; if (!id) { if(isIframe) id = loc.href.split("id=")[1].split("&")[0]; else { var chunks = loc.pathname.replace(/[\._]/g, "/").split("/"); for (var i in chunks) { id = chunks[i]; if(!!parseInt(id) && id.length > 4) break; } } } // kill registration request if (!!unsafeWindow.trafficlight) initialize(id); GM_xmlhttpRequest({ method: 'GET', url: 'http://video.lazza.dk/vd.php?id='+id, headers: { 'Accept': 'application/atom+xml,application/xml,text/xml' }, onload: function(responseDetails) { var r = responseDetails.responseText; var doc = $.parseXML(r); var $xml = $( doc ); var videos = $xml.find("video"); var vlinks = []; // parse video URLs videos.each(function (i) { var url = $( videos.get(i) ).attr("src"); var type = url.slice(-3); var name = ""; switch(type) { case "est": name = "Smooth streaming"; break; case "pl)": name = "Apple streaming"; break; case "flv": name = "Video FLV"; break; case "f4v": name = "Video F4V"; break; case "mp4": name = "Video MP4"; break; case "wmv": name = "Video WMV"; break; } vlinks.push( { na: name, url: url } ); }); // display video URLs var num = vlinks.length; if(isIframe) $('