// ==UserScript==
// @name Skrypt umożliwiający pobieranie materiałów ze znanych serwisów VOD. Autor: Przemek
// @namespace http://www.ipla.tv/
// @include http://www.ipla.tv/*
// @include http://getmedia.redefine.pl/*
// @include http://player.pl/*
// @include http://vod.pl/*
// @include http://*tvp.pl/*
// @version 1.3
// @description SKrypt umożliwiający pobieranie materiałów z serwisów Ipla.tv, Player.pl, Vod.pl
// @author Przemek
// @match http://www.ipla.tv/*
// @grant none
// ==/UserScript==
/////////////////////// KONFIGURACJA ////////////////////////
Wlacz_skrypt = true; // true = skrypt włączony, false = skrypt wyłączony.
//////////////////// KONIEC KONFIGURACJI ////////////////////
function addEvent(obj, event, func) {
if (obj.addEventListener) {
obj.addEventListener(event, func, false);
return true;
} else if (obj.attachEvent) {
obj.attachEvent('on' + event, func);
} else {
var f = obj['on' + event];
obj['on' + event] = typeof f === 'function' ? function() {
f();
func();
} : func
}
}
function texxtIpla(lol){
if (window.prompt("Aby skopiować link, wciśnij: CTRL+C, potem: ENTER aby rozpocząć pobieranie, lub przycisk Anuluj aby zakończyć działanie skryptu", lol)){
document.location.href=lol;
}
}
function texxt(lol){
window.prompt ("Aby skopiować link, wciśnij: CTRL+C, potem: ENTER", lol);
}
function PokazLink(){
var n = document.location.href.split(/[.,]/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/api/?platform=ConnectedTV&terminal=Samsung&format=json&v=2.0&authKey=ba786b315508f0920eca1c34d65534cd&type=episode&id='+n[n.length-2]+'&sort=newest&m=getItem&deviceScreenHeight=1080&deviceScreenWidth=1920',false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
var heyhey9 = null;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
heyhey9 = xhr.response;
// alert(heyhey9);
texxt(heyhey9);
return heyhey9;
}
}
var link = o.item.videos.main.video_content[1].url;
// texxt(link);
var str = link;
var res = str.replace("tvnplayer", "player");
xhr.open('GET', res, false);
//alert(heyhey9);
xhr.send(null);
//texxt(o.item.videos.main.video_content[1].url);
//document.location.href = o.item.videos.main.video_content[1].url;
}
function PokazLinkA(){
var n = document.location.href.split(/[.,]/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/api/?platform=ConnectedTV&terminal=Samsung&format=json&v=2.0&authKey=ba786b315508f0920eca1c34d65534cd&type=episode&id='+n[n.length-2]+'&sort=newest&m=getItem&deviceScreenHeight=1080&deviceScreenWidth=1920',false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
var heyhey9 = null;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
heyhey9 = xhr.response;
// alert(heyhey9);
texxt(heyhey9);
return heyhey9;
}
}
var link = o.item.videos.main.video_content[0].url;
// texxt(link);
var str = link;
var res = str.replace("tvnplayer", "player");
xhr.open('GET', res, false);
//alert(heyhey9);
xhr.send(null);
//texxt(o.item.videos.main.video_content[1].url);
//document.location.href = o.item.videos.main.video_content[1].url;
}
function PokazLinkB(){
var n = document.location.href.split(/[.,]/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/api/?platform=ConnectedTV&terminal=Samsung&format=json&v=2.0&authKey=ba786b315508f0920eca1c34d65534cd&type=episode&id='+n[n.length-2]+'&sort=newest&m=getItem&deviceScreenHeight=1080&deviceScreenWidth=1920',false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
var heyhey9 = null;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
heyhey9 = xhr.response;
// alert(heyhey9);
texxt(heyhey9);
return heyhey9;
}
}
var link = o.item.videos.main.video_content[o.item.videos.main.video_content.length-1].url;
// texxt(link);
var str = link;
var res = str.replace("tvnplayer", "player");
xhr.open('GET', res, false);
//alert(heyhey9);
xhr.send(null);
//texxt(o.item.videos.main.video_content[1].url);
//document.location.href = o.item.videos.main.video_content[1].url;
}
function RozpocznijPobieranie(){
//alert('hi');
var n = document.location.href.split(/[.,]/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/api/?platform=ConnectedTV&terminal=Samsung&format=json&v=2.0&authKey=ba786b315508f0920eca1c34d65534cd&type=episode&id='+n[n.length-2]+'&sort=newest&m=getItem&deviceScreenHeight=1080&deviceScreenWidth=1920',false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
var s = o.item.videos.main.video_content[1].url;
var m = s.match(/:\/\/(?:www\.)?(.[^/]+)(.*)/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET',m[2],false);xmlhttp.send();
document.location.href = xmlhttp.responseText;
}
function RozpocznijPobieranieA(){
//alert('hi');
var n = document.location.href.split(/[.,]/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/api/?platform=ConnectedTV&terminal=Samsung&format=json&v=2.0&authKey=ba786b315508f0920eca1c34d65534cd&type=episode&id='+n[n.length-2]+'&sort=newest&m=getItem&deviceScreenHeight=1080&deviceScreenWidth=1920',false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
var s = o.item.videos.main.video_content[0].url;
var m = s.match(/:\/\/(?:www\.)?(.[^/]+)(.*)/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET',m[2],false);xmlhttp.send();
document.location.href = xmlhttp.responseText;
}
function RozpocznijPobieranieA(){
//alert('hi');
var n = document.location.href.split(/[.,]/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/api/?platform=ConnectedTV&terminal=Samsung&format=json&v=2.0&authKey=ba786b315508f0920eca1c34d65534cd&type=episode&id='+n[n.length-2]+'&sort=newest&m=getItem&deviceScreenHeight=1080&deviceScreenWidth=1920',false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
var s = o.item.videos.main.video_content[o.item.videos.main.video_content.length-1].url;
var m = s.match(/:\/\/(?:www\.)?(.[^/]+)(.*)/);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET',m[2],false);xmlhttp.send();
document.location.href = xmlhttp.responseText;
}
var btn = document.createElement( 'input' );
with( btn ) {
setAttribute( 'onclick', 'PokazLink()' );
setAttribute( 'value', 'Pokaż Link: HD' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn1' );
setAttribute("style", "position:fixed !important; left: 0px; top: 1px; width: 115px; height: 30px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
var btna = document.createElement( 'input' );
with( btna ) {
setAttribute( 'onclick', 'PokazLink()' );
setAttribute( 'value', 'MQ' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn1a' );
setAttribute("style", "position:fixed !important; left: 0px; top: 1px; left: 117px; width: 45px; height: 30px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
var btnb = document.createElement( 'input' );
with( btnb ) {
setAttribute( 'onclick', 'PokazLink()' );
setAttribute( 'value', 'LQ' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn1b' );
setAttribute("style", "position:fixed !important; left: 0px; top: 1px; left: 164px; width: 45px; height: 30px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
var btn2 = document.createElement( 'input' );
with( btn2 ) {
setAttribute( 'onclick', 'RozpocznijPobieranie()' );
setAttribute( 'value', 'Pobierz w: HD' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn2' );
setAttribute("style", "position:fixed !important; left: 0px; top: 1px; left: 219px; width: 110px; height: 30px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
var btn2a = document.createElement( 'input' );
with( btn2a ) {
setAttribute( 'onclick', 'RozpocznijPobieranie()' );
setAttribute( 'value', 'MQ' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn2a' );
setAttribute("style", "position:fixed !important; left: 0px; top: 1px; left: 331px; width: 45px; height: 30px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
var btn2b = document.createElement( 'input' );
with( btn2b ) {
setAttribute( 'onclick', 'RozpocznijPobieranie()' );
setAttribute( 'value', 'LQ' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn2a' );
setAttribute("style", "position:fixed !important; left: 0px; top: 1px; left: 378px; width: 45px; height: 30px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
function PokazLinkIpla(){
var whatToOpen;
if(document.location.href.indexOf('www.ipla.tv/')>0){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','/VOD/play-in-ipla/'+document.location.href.substr(document.location.href.indexOf('/vod-')+5),false);
xmlhttp.send();
var idn=xmlhttp.responseText.substr(xmlhttp.responseText.indexOf('ipla://playvod-1|')+17);
idn=idn.substr(0,idn.indexOf(' ')-1);
document.location.href='http://getmedia.redefine.pl/vods/get_vod/?cpid=1&ua=mipla/23&media_id='+idn;
whatToOpen = 'http://getmedia.redefine.pl/vods/get_vod/?cpid=1&ua=mipla/23&media_id='+idn;
}
else if(document.location.href.indexOf('getmedia.redefine.pl/')>0){
s=JSON.parse(document.body.textContent);
if(s.vod.video_hd)a=s.vod.video_hd;
else if(s.vod.video){
a=s.vod.video;
}else{a=s.vod.copies[0].url}
document.location.href=a;
whatToOpen = a;
}
}
function PokazLinkOnet(){
var i=document.body.innerHTML.substr(document.body.innerHTML.indexOf('id='+atob('Ig==')+'mvp:')+8,100);
i=i.substr(0,i.indexOf(atob('Ig==')));
s=atob('PGh0bWw+PGhlYWQ+PHNjcmlwdD4KZnVuY3Rpb24gbShlKXsKdj1ldmFsKGUpOwpkb2N1bWVudC5sb2NhdGlvbi5ocmVmPXYucmVzdWx0WzBdLmZvcm1hdHMud2lkZW8ubXA0W3YucmVzdWx0WzBdLmZvcm1hdHMud2lkZW8ubXA0Lmxlbmd0aC0xXVsidXJsIl07Cn0KPC9zY3JpcHQ+CjxzY3JpcHQgc3JjPSJodHRwOi8vcWkuY2ttLm9uZXRhcGkucGwvP2NhbGxiYWNrPW0mYm9keVtpZF09RUJCQUUxRTQzMjZFNENFOTM0M0ZGRUVGNTZBOTE5OEQmYm9keVtqc29ucnBjXT0yLjAmYm9keVttZXRob2RdPWdldF9hc3NldF9kZXRhaWwmYm9keVtwYXJhbXNdW0lEX1B1Ymxpa2FjamldPVFRUVEmYm9keVtwYXJhbXNdW1NlcnZpY2VdPXZvZC5vbmV0LnBsJmNvbnRlbnQtdHlwZT1hcHBsaWNhdGlvbiUyRmpzb25wJngtb25ldC1hcHA9cGxheWVyLmZyb250Lm9uZXRhcGkucGwmXz0xMzYyMTY0OTEzMTQ1Ij48L3NjcmlwdD4gCjwvaGVhZD48Ym9keT48L2JvZHk+PC9odG1sPg==');
s=s.replace('QQQQ',i);
var win=open();
with(win.document){open();
write(s);
close();
}
}
function PokazLinkTvp(){
var xmlhttp=new XMLHttpRequest();
m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('data-video-id=')+15,8).replace(/\D/g,'');
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('data-videoid=')+14,8).replace(/\D/g,'');
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('/player/video?id=')+17,8);
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('/player/')+8,8);
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('video_id=')+9,8).replace(/\D/g,'');
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('object_id:')+10,9).replace(/\D/g,'');
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('amp;object_id=')+14,8).replace(/\D/g,'');
if (!/^\d+$/.test(m)) m=document.body.innerHTML.substr(document.body.innerHTML.indexOf('object_id=')+10,8).replace(/\D/g,'');
if (!/^\d+$/.test(m)) {n=document.location.href.split(/[?/=-]/); m=n[n.length-2]; }
if (!/^\d+$/.test(m)) m=n[n.length-1];
xmlhttp.open('GET','http://www.tvp.pl/shared/cdn/tokenizer_v2.php?object_id='+m,false);
xmlhttp.send();
var o = eval('('+xmlhttp.responseText+')');
maxbitrate=0;
maxurl='';
for (i = 0; o.formats.length > i;i=i+1) {
if ((o.formats[i].totalBitrate > maxbitrate) && (o.formats[i].adaptive == false)) {maxbitrate=o.formats[i].totalBitrate;
maxurl=o.formats[i].url;
}}
//document.location.href=maxurl;
texxtIpla(maxurl);
}
function PokazLinkPobieranieIpla(){
var strona = document.body.innerText;
var search1 = strona.indexOf('"video": "');
var search2 = strona.substr(search1+10);
var search3 = search2.indexOf('",');
var search4 = search2.substr(0,search3);
var link = search4
texxtIpla(link);
}
var btnIpla = document.createElement( 'input' );
with( btnIpla ) {
setAttribute( 'onclick', 'PokazLink()' );
setAttribute( 'value', 'Pobierz video' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btnIpla' );
setAttribute("style", "position:fixed !important; left: 0px; top: 4px; width: 140px; height: 35px; background-color: #00a6ff; color: white; z-index: 2147483647;");
}
var btnOnet = document.createElement( 'input' );
with( btnOnet ) {
setAttribute( 'onclick', 'PokazLink()' );
setAttribute( 'value', 'Pobierz video' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btnOnet' );
setAttribute("style", "position:fixed !important; left: 0px; top: 2px; width: 110px; height: 25px; background-color: #2fd6ff; z-index: 2147483647;");
}
var btnTvp = document.createElement( 'input' );
with( btnTvp ) {
setAttribute( 'onclick', 'PokazLink()' );
setAttribute( 'value', 'Pobierz video' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btnTvp' );
setAttribute("style", "position:fixed !important; left: 0px; top: 10px; width: 110px; height: 35px; z-index: 2147483647;");
}
/*var btn2 = document.createElement( 'input' );
with( btn2 ) {
setAttribute( 'onclick', 'RozpocznijPobieranie()' );
setAttribute( 'value', 'Pobierz' );
setAttribute( 'type', 'button' );
setAttribute( 'id', 'btn2' );
setAttribute("style", "position:fixed !important; left: 0px; top: 75px; left: 117px; width: px; height: 35px; background-color: #00a6ff; color: white");
}*/
function start() {
if (Wlacz_skrypt){
var url = window.location.href;
//alert(url);
if (url.indexOf("www.ipla.tv") > -1) {
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btnIpla );
// document.getElementsByTagName( 'body' )[ 0 ].appendChild( btn2 );
addEvent(document.getElementById('btnIpla'), 'click', function() {
PokazLinkIpla();
});
/*addEvent(document.getElementById('btn2'), 'click', function() {
RozpocznijPobieranie();
});*/
}
else if (url.indexOf("getmedia.redefine.pl") > -1) {
// alert('getmedia');
PokazLinkPobieranieIpla();
}
else if (url.indexOf("player.pl") > -1) {
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btn );
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btna );
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btnb );
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btn2 );
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btn2a );
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btn2b );
addEvent(document.getElementById('btn1'), 'click', function() {
PokazLink();
});
addEvent(document.getElementById('btn1a'), 'click', function() {
PokazLinkA();
});
addEvent(document.getElementById('btn1b'), 'click', function() {
PokazLinkB();
});
addEvent(document.getElementById('btn2'), 'click', function() {
RozpocznijPobieranie();
});
addEvent(document.getElementById('btn2a'), 'click', function() {
RozpocznijPobieranieA();
});
addEvent(document.getElementById('btn2b'), 'click', function() {
RozpocznijPobieranieB();
});
}
else if (url.indexOf("vod.pl") > -1) {
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btnOnet );
addEvent(document.getElementById('btnOnet'), 'click', function() {
PokazLinkOnet();
});
}
else if (url.indexOf("tvp.pl") > -1) {
if (url.indexOf("vod.tvp.pl/vod/slider") == -1) {
if (url.indexOf("tvp.pl/sess/tvplayer.php?") == -1) {
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btnTvp );
addEvent(document.getElementById('btnTvp'), 'click', function() {
PokazLinkTvp();
});
}
}
}
}
}
window.onload=start();