// ==UserScript==
// @name Ipla.tv, Player.pl: Skrypt umożliwiający pobieranie materiałów. Autor: Przemek
// @namespace http://www.ipla.tv/
// @include http://www.ipla.tv/*
// @include http://getmedia.redefine.pl/*
// @include http://player.pl/*
// @version 1.1
// @description SKrypt umożliwiający pobieranie materiałów z serwisów Ipla.tv, Player.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: 70px; width: 115px; height: 35px; background-color: #00a6ff; color: white");
}
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: 70px; left: 117px; width: 45px; height: 35px; background-color: #00a6ff; color: white");
}
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: 70px; left: 164px; width: 45px; height: 35px; background-color: #00a6ff; color: white");
}
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: 70px; left: 219px; width: 110px; height: 35px; background-color: #00a6ff; color: white");
}
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: 70px; left: 331px; width: 45px; height: 35px; background-color: #00a6ff; color: white");
}
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: 70px; left: 378px; width: 45px; height: 35px; background-color: #00a6ff; color: white");
}
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 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: 75px; width: 140px; height: 35px; background-color: #00a6ff; color: white");
}
/*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();
});
}
}
}
window.onload=start();