Guest User

Untitled

a guest
May 21st, 2018
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.63 KB | None | 0 0
  1. http://s1-player5.cdntvn.pl/player.js > http://kemsan.xyz/player.js
  2. Switcheroo Reditcor
  3.  
  4. Tempermonkey
  5. // ==UserScript==
  6. // @name Skrypt umożliwiający pobieranie materiałów ze znanych serwisów VOD.
  7. // @namespace http://www.ipla.tv/
  8. // @include *www.ipla.tv/*
  9. // @include *getmedia.redefine.pl/*
  10. // @include *player.pl/*
  11. // @include *vod.pl/*
  12. // @include *tvp.pl/*
  13. // @include *www.cda.pl/*
  14. // @version 4.3
  15. // @description Skrypt umożliwiający pobieranie materiałów z serwisów: ipla.tv, player.pl, vod.pl, vod.tvp.pl, cda.pl. Działa tylko z rozszerzeniem Tampermonkey.
  16. // @author Frosty1337,Acer1337PL
  17. // @match http://www.ipla.tv/*
  18. // @grant none
  19. // ==/UserScript==
  20. //Ważne:
  21. //Skrypt opiera się na skryptach umieszczonych na stronie: miniskrypt.blogspot.com
  22. //oraz: miniskrypt.hubaiitv.pl. Moje rozszerzenie tylko i wyłącznie dodaje wygodne
  23. //w użyciu przyciski, jednak nie jestem autorem większości kodu.
  24. //Skrypt jest niepubliczny, a dostęp do niego mają tylko i wyłącznie osoby z linkiem.
  25. /////////////////////// KONFIGURACJA ////////////////////////
  26. Wlacz_skrypt = true; // true = skrypt włączony, false = skrypt wyłączony.
  27. //////////////////// KONIEC KONFIGURACJI ////////////////////
  28.  
  29. var SkryptKopiujText = "function copyText(e){function t(e){if(document.selection){var t=document.body.createTextRange();t.moveToElementText(e),t.select()}else if(window.getSelection){var t=document.createRange();t.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}}var n=document.createElement(\"DIV\");n.textContent=e,document.body.appendChild(n),t(n),document.execCommand(\"copy\"),n.remove()} ";
  30. var StyleText = "<style>body{font-family: \"Segoe UI\";}.clicked{background-color: #7CFC00;}</style>";
  31.  
  32. function addEvent(obj, event, func) {
  33. if (obj.addEventListener) {
  34. obj.addEventListener(event, func, false);
  35. return true;
  36. } else if (obj.attachEvent) {
  37. obj.attachEvent('on' + event, func);
  38. } else {
  39. var f = obj['on' + event];
  40. obj['on' + event] = typeof f === 'function' ? function () {
  41. f();
  42. func();
  43. }
  44. : func;
  45. }
  46. }
  47.  
  48. function ShowPromptWithInfo(lol, info = null) {
  49. var infotext = 'Aby skopiować link, wciśnij: CTRL+C, potem: ENTER aby rozpocząć pobieranie, lub ESC aby zakończyć działanie skryptu';
  50. if(info !== null){
  51. infotext = infotext + ". " + info;
  52. }
  53. if (window.prompt(infotext, lol)) {
  54. document.location.href = lol;
  55. }
  56. }
  57.  
  58. function ShowPrompt(lol) {
  59. window.prompt('Aby skopiować link, wciśnij: CTRL+C, potem: ENTER', lol);
  60. }
  61.  
  62. function makeid()
  63. {
  64. var text = '';
  65. var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  66. for (var i = 0; i < 5; i++)
  67. text += possible.charAt(Math.floor(Math.random() * possible.length));
  68. return text;
  69. }
  70.  
  71. var DocumentWriteFirefoxFix = '';
  72. function fireNewTab() {
  73. function makeid2() {
  74. var text = '';
  75. var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  76. for (var i = 0; i < 5; i++)
  77. text += possible.charAt(Math.floor(Math.random() * possible.length));
  78. return text;
  79. }
  80. var randomText = makeid2();
  81. var newTab = window.open('about:blank', 'MsgWindow-' + randomText);
  82. newTab.document.write("DocumentWriteFirefoxFix");
  83. newTab.addEventListener('load', function () {
  84. alert('hi2');
  85. var destDoc = newTab.document;
  86. destDoc.open();
  87. destDoc.write("DocumentWriteFirefoxFix");
  88. destDoc.close();
  89. }, false
  90. );
  91. }
  92. function addslashes( str ) {
  93. return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
  94. }
  95.  
  96. function addJS_Node(text, s_URL, funcToRun, runOnLoad) {
  97. var D = document;
  98. var scriptNode = D.createElement('script');
  99. if (runOnLoad) {
  100. scriptNode.addEventListener('load', runOnLoad, false);
  101. }
  102. scriptNode.type = 'text/javascript';
  103. if (text) scriptNode.textContent = text;
  104. if (s_URL) scriptNode.src = s_URL;
  105. var str = funcToRun.toString();
  106. var tes = addslashes(DocumentWriteFirefoxFix);
  107. var res = str.replace("DocumentWriteFirefoxFix", tes);
  108. res = res.replace("DocumentWriteFirefoxFix", tes);
  109. if (funcToRun) scriptNode.textContent = '(' + res + ')()';
  110.  
  111. var targ = D.getElementsByTagName('head') [0] || D.body || D.documentElement;
  112. targ.appendChild(scriptNode);
  113. }
  114.  
  115. function PokazLinkTVNNowy() {
  116. try {
  117. try {
  118. n = document.querySelector("#detailEpisode").getAttribute("data-article-id");
  119. } catch (e) {
  120. var pageURL = window.location.href;
  121. var lastComma = pageURL.lastIndexOf(",");
  122. if (lastComma > - 1) {
  123. n = pageURL.substring(lastComma+1);
  124. n = parseInt(n);
  125. }
  126. }
  127. xmlhttp = new XMLHttpRequest();
  128. xmlhttp.open("GET", "/api/?platform=ConnectedTV&terminal=Panasonic&format=json&authKey=064fda5ab26dc1dd936f5c6e84b7d3c2&v=3.1&m=getItem&id=" + n, false);
  129. xmlhttp.send();
  130. o = JSON.parse(xmlhttp.responseText);
  131. lt = o.item.videos.main.video_content_license_type;
  132. dd = o.item.videos.main.video_content;
  133. title = o.item.serie_title + " - S" + o.item.season + "E" + o.item.episode;
  134. if (lt !== null) {
  135. alert('DRM lub brak materiału TV :(');
  136. return;
  137. }
  138. DocumentWriteFirefoxFix = "";
  139. var randomText = makeid();
  140. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + '<p>Tytuł: ' + title + '</p>';
  141. var HighestResolution = 0;
  142. var HighestResolutionLink = '';
  143. for (var j = 0, len = dd.length; j < len; j = j + 1) {
  144. HighestResolution = HighestResolution + 1;
  145. dlurl = dd[j].url;
  146. if(j < 2){
  147. HighestResolutionLink = dlurl;
  148. }
  149. pn = dd[j].profile_name;
  150. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "<p>Jakość materiału: " + pn + "<br>";
  151. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "Link do materiału: <button id=\"button-" + j + "\" type=\"button\">Kopiuj</button><br><a target=\"_blank\" href=\"" + dlurl + "\">" + dlurl + "</a></p>";
  152. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "<script>var but = document.getElementById('button-"+j+"');but.addEventListener('click', function(){copyText(\""+ dlurl +"\");document.getElementById('button-"+j+"').setAttribute(\"class\", \"clicked\");})</script>";
  153. }
  154. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + StyleText + '<script type="application/javascript">function ShowPromptWithInfo(lol){if (window.prompt("Aby skopiować link, wciśnij: CTRL+C, potem: ENTER aby rozpocząć pobieranie, lub ESC aby zakończyć działanie skryptu", lol)){document.location.href=lol;}}setTimeout(function () {ShowPromptWithInfo("' + HighestResolutionLink + '");}, 1000);' + SkryptKopiujText + '</script>';
  155. addJS_Node(null, null, fireNewTab);
  156.  
  157. } catch (e) {}
  158. }
  159.  
  160. function PokazLinkPobieranieIpla() {
  161. //alert('ipla');
  162. nn = document.querySelector('pre').textContent;
  163. v = JSON.parse(nn);
  164. if (v.vod.drm == true) {
  165. alert('Niestety, ale materiał jest zabezpieczony DRM i prawdopodobnie nie będzie można go pobrać :(');
  166. }
  167. var QualityArray = [];
  168. var copies = v.vod.copies;
  169. if(copies !== null){
  170. if(copies.length > 0){
  171. for (var prop in copies) {
  172. var copy = copies[prop];
  173. var newArray = [copy.quality_p, copy.url];
  174. QualityArray.push(newArray);
  175. }
  176. if(QualityArray !== null){
  177. var countArray = QualityArray.length;
  178. if(countArray > 0){
  179. var countArrayElement = countArray - 1;
  180. var bestQuality = QualityArray[countArrayElement][0];
  181. var bestQualityLink = QualityArray[countArrayElement][1];
  182. ShowPromptWithInfo(bestQualityLink,"\nWybrana jakość materiału to: " + bestQuality + ".");
  183. }
  184. }
  185. }
  186. }
  187. }
  188.  
  189. function PokazLinkIpla() {
  190. if (location.href.match(/^http[s]?:\/\/www\.ipla\.tv\//)) {
  191. try {
  192. mid = document.querySelector('#vod-player').getAttribute('data-vod-json');
  193. idn = JSON.parse(mid).mid;
  194. document.location.href = 'http://getmedia.redefine.pl/vods/get_vod/?cpid=1&ua=mipla_ios/122&media_id=' + idn;
  195. } catch (e) {
  196. x = window.location.href;
  197. idn = x.match(/[\a-z\d]{32}/)[0];
  198. document.location.href = 'http://getmedia.redefine.pl/vods/get_vod/?cpid=1&ua=mipla_ios/122&media_id=' + idn;
  199. /*var pageURL = window.location.href.split("?")[0];
  200. var pageURLTemp = pageURL.substring(0, pageURL.length - 3);
  201. var lastComma = pageURLTemp.lastIndexOf("/");
  202. if (lastComma > - 1) {
  203. n = pageURL.substring(lastComma+1);
  204. mid = n;
  205. document.location.href = 'http://getmedia.redefine.pl/vods/get_vod/?cpid=1&ua=mipla_ios/122&media_id=' + mid;
  206. }*/
  207. }
  208. }
  209.  
  210. }
  211.  
  212. function PokazLinkOnet() {
  213. i = document.body.innerHTML;
  214. m = i.match(/mvp:([\d]{7}\.[\d]{1,10})/)[1];
  215. title = i.match(/title: \'(.*)\',/)[1];
  216. url = "aHR0cHM6Ly9wbGF5ZXItYXBpLmRyZWFtbGFiLnBsLz9ib2R5W2lkXT0rbSsmYm9keVtqc29ucnBjXT0yLjAmYm9keVttZXRob2RdPWdldF9hc3NldF9kZXRhaWwmYm9keVtwYXJhbXNdW0lEX1B1Ymxpa2FjamldPSttKyZib2R5W3BhcmFtc11bU2VydmljZV09dm9kLm9uZXQucGwmY29udGVudC10eXBlPWFwcGxpY2F0aW9uL2pzb25wJngtb25ldC1hcHA9cGxheWVyLmZyb250Lm9uZXRhcGkucGwmY2FsbGJhY2s9";
  217. url = (atob(url)).replace(/\+m\+/g, m);
  218. xhr = new XMLHttpRequest();
  219. xhr.open('GET', url, false);
  220. xhr.send(null);
  221. v = JSON.parse(xhr.responseText);
  222. vc = v.result[0].formats.wideo.mp4;
  223. if (!vc) {
  224. alert('Niestety, ale materiał jest zabezpieczony DRM i nie będzie można go pobrać :(');
  225. return;
  226. }
  227. title = v.result[0].meta.title;
  228. for (var i = -1, cc = [], dd = [], l = vc.length >>> 0; ++i !== l; null) {
  229. dd[i] = cc[i] = vc[i].video_bitrate;
  230. }
  231. dd.sort(function(a, b) {
  232. return b - a;
  233. });
  234. //pagecreate(title);
  235. DocumentWriteFirefoxFix = "";
  236. var randomText = makeid();
  237. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + '<p>Tytuł: ' + title + '</p>';
  238. var HighestResolution = 0;
  239. var HighestResolutionLink = '';
  240. for (var j = 0, len = dd.length; j < len; j = j + 1) {
  241. dlurl = vc[cc.indexOf(dd[j])].url;
  242. bitrate = vc[cc.indexOf(dd[j])].video_bitrate;
  243. vertical_resolution = vc[cc.indexOf(dd[j])].vertical_resolution;
  244. /*container.appendChild(createNode("pre", {}, {
  245. textContent: "Bitrate: " + bitrate + " - Rozdzielczość pionowa: " + vertical_resolution
  246. }));
  247. w = 'wget --restrict-file-names=windows --progress=bar --header="User-Agent:ABC" -c -O "' + title + '.mp4" ' + dlurl;
  248. buttoncreate(dlurl, title, w);*/
  249. if (vertical_resolution > HighestResolution) {
  250. HighestResolution = vertical_resolution;
  251. HighestResolutionLink = dlurl;
  252. }
  253. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + '<p>Bitrate: ' + bitrate + ' - Rozdzielczość pionowa: ' + vertical_resolution + '<br>';
  254. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "Link do materiału: <button id=\"button-" + j + "\" type=\"button\">Kopiuj</button><br><a target=\"_blank\" href=\"" + dlurl + "\">" + dlurl + "</a></p>";
  255. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "<script>var but = document.getElementById('button-"+j+"');but.addEventListener('click', function(){copyText(\""+ dlurl +"\");document.getElementById('button-"+j+"').setAttribute(\"class\", \"clicked\");})</script>";
  256. }
  257. if (HighestResolution > 0) {
  258. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + StyleText + '<script type="application/javascript">function ShowPromptWithInfo(lol){if (window.prompt("Aby skopiować link, wciśnij: CTRL+C, potem: ENTER aby rozpocząć pobieranie, lub ESC aby zakończyć działanie skryptu", lol)){document.location.href=lol;}}setTimeout(function () {ShowPromptWithInfo("' + HighestResolutionLink + '");}, 1000);' + SkryptKopiujText + '</script>';
  259. addJS_Node(null, null, fireNewTab);
  260. }
  261. }
  262.  
  263. function PokazLinkTvp() {
  264. if (location.href.match(/^http[s]?:\/\/vod\.tvp\.pl\/[\d]{0,8}/)) {
  265. i = document.body.innerHTML;
  266. m = i.match(/object_id=([\d]{0,8})/);
  267. var znalezionotytul = false;
  268. st = 'Nieznane';
  269. tt = 'Nieznane';
  270. i = document.querySelector('.movieWrapper');
  271. if (i !== null) {
  272. i = i.querySelector('iframe').contentWindow.document.head.innerHTML;
  273. if (i !== null) {
  274. st = i.match(/\{name: \x22SeriesTitle\x22\, value: \x22(.*)\x22\},/) [1];
  275. tt = i.match(/\{name: \x22Title\x22\, value: \x22(.*)\x22\},/) [1];
  276. znalezionotytul = true;
  277. }
  278. }
  279. title = st + ' - ' + tt;
  280. xmlhttp = new XMLHttpRequest();
  281. xmlhttp.open('GET', 'https://www.tvp.pl/shared/cdn/tokenizer_v2.php?object_id=' + m[1], false);
  282. xmlhttp.send();
  283. o = JSON.parse(xmlhttp.responseText);
  284. v = o.formats;
  285. vc = [];
  286. if(v != null){
  287. for (var i = - 1, vc = [
  288. ], l = v.length >>> 0; ++i !== l; null) {
  289. if (v[i].adaptive == false) {
  290. vc.push(v[i]);
  291. };
  292. };
  293. }
  294. if (vc.length == 0) {
  295. alert('Niestety, ale materiał jest zabezpieczony DRM i nie będzie można go pobrać :(');
  296. return;
  297. };
  298. for (var i = - 1, cc = [
  299. ], dd = [
  300. ], l = vc.length >>> 0; ++i !== l; null) {
  301. dd[i] = cc[i] = vc[i].totalBitrate;
  302. };
  303. dd.sort(function (a, b) {
  304. return b - a;
  305. });
  306. DocumentWriteFirefoxFix = '';
  307. if (znalezionotytul) {
  308. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + '<p>Tytuł: ' + title + '</p>';
  309. }
  310. for (var j = 0, len = dd.length; j < len; j = j + 1) {
  311. dlurl = vc[cc.indexOf(dd[j])].url;
  312. bitrate = vc[cc.indexOf(dd[j])].totalBitrate;
  313. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + '<p>Bitrate: ' + bitrate + '<br>';
  314. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "Link do materiału: <button id=\"button-" + j + "\" type=\"button\">Kopiuj</button><br><a target=\"_blank\" href=\"" + dlurl + "\">" + dlurl + "</a></p>";
  315. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + "<script>var but = document.getElementById('button-"+j+"');but.addEventListener('click', function(){copyText(\""+ dlurl +"\");document.getElementById('button-"+j+"').setAttribute(\"class\", \"clicked\");})</script>";
  316. }
  317. for (var j = 0, len = dd.length; j < len; j = j + 1) {
  318. dlurlbest = vc[cc.indexOf(dd[j])].url;
  319. if (dlurlbest !== undefined) {
  320. break;
  321. }
  322. }
  323. DocumentWriteFirefoxFix = DocumentWriteFirefoxFix + StyleText + '<script type="application/javascript">function ShowPromptWithInfo(lol){if (window.prompt("Aby skopiować link, wciśnij: CTRL+C, potem: ENTER aby rozpocząć pobieranie, lub ESC aby zakończyć działanie skryptu", lol)){document.location.href=lol;}}setTimeout(function () {ShowPromptWithInfo("' + dlurlbest + '");}, 1000);' + SkryptKopiujText + '</script>';
  324. addJS_Node(null, null, fireNewTab);
  325. }
  326.  
  327. }
  328.  
  329. function PokazLinkCda() {
  330. if (typeof l === 'undefined') {
  331. var kolumny_list2 = 'pb-video-player';
  332. var list_czat = document.getElementsByClassName(kolumny_list2);
  333. if (list_czat.length > 0) {
  334. for (i = 0; i < list_czat.length; i++)
  335. {
  336. var vviideoo = list_czat[i].src;
  337. ShowPromptWithInfo(vviideoo);
  338. break;
  339. }
  340. }
  341. }
  342. else {
  343. ShowPromptWithInfo(l);
  344. }
  345. }
  346.  
  347. function SkryptDoPobieraniaStart() {
  348. if (Wlacz_skrypt) {
  349. var url = window.location.href;
  350. if (location.href.match(/^http[s]?:\/\/www\.ipla\.tv\//)) {
  351. var btnIpla = document.createElement('input');
  352. btnIpla.setAttribute('value', 'Pobierz video');
  353. btnIpla.setAttribute('type', 'button');
  354. btnIpla.setAttribute('id', 'btnIpla');
  355. btnIpla.setAttribute('style', 'position:fixed !important; left: 0px; top: 4px; width: 140px; height: 35px; background-color: #00a6ff; color: white; z-index: 1000000000;');
  356. document.getElementsByTagName('body') [0].appendChild(btnIpla);
  357. addEvent(document.getElementById('btnIpla'), 'click', function () {
  358. PokazLinkIpla();
  359. });
  360. }
  361. else if (url.indexOf('getmedia.redefine.pl') > - 1) {
  362. PokazLinkPobieranieIpla();
  363. }
  364. else if (location.href.match(/^http[s]?:\/\/(?:w{3}\.)?(?:tvn)?player\.pl\//)) {
  365. var btnTVNNowy = document.createElement('input');
  366. btnTVNNowy.setAttribute('value', 'Pobierz video');
  367. btnTVNNowy.setAttribute('type', 'button');
  368. btnTVNNowy.setAttribute('id', 'btnTVNNowy');
  369. btnTVNNowy.setAttribute('style', 'position:fixed !important; left: 0px; top: 1px; width: 115px; height: 30px; background-color: #00a6ff; color: white; z-index: 1000000000;');
  370. document.getElementsByTagName('body') [0].appendChild(btnTVNNowy);
  371. addEvent(document.getElementById('btnTVNNowy'), 'click', function () {
  372. PokazLinkTVNNowy();
  373. });
  374. }
  375. else if (location.href.match(/^http[s]?:\/\/vod\.pl\//)) {
  376. var btnOnet = document.createElement('input');
  377. btnOnet.setAttribute('value', 'Pobierz video');
  378. btnOnet.setAttribute('type', 'button');
  379. btnOnet.setAttribute('id', 'btnOnet');
  380. btnOnet.setAttribute('style', 'position:fixed !important; left: 0px; top: 2px; width: 110px; height: 25px; background-color: #2fd6ff; z-index: 1000000000;');
  381. document.getElementsByTagName('body') [0].appendChild(btnOnet);
  382. addEvent(document.getElementById('btnOnet'), 'click', function () {
  383. PokazLinkOnet();
  384. });
  385. }
  386. else if (location.href.match(/^http[s]?:\/\/vod\.tvp\.pl\/[\d]{0,8}/)) {
  387. i = document.body.innerHTML;
  388. m = i.match(/object_id=([\d]{0,8})/);
  389. if (m !== null) {
  390. if (url.indexOf('vod.tvp.pl/vod/slider') == - 1) {
  391. if (url.indexOf('tvp.pl/sess/tvplayer.php?') == - 1) {
  392. var btnTvp = document.createElement('input');
  393. btnTvp.setAttribute('value', 'Pobierz video');
  394. btnTvp.setAttribute('type', 'button');
  395. btnTvp.setAttribute('id', 'btnTvp');
  396. btnTvp.setAttribute('style', 'position:fixed !important; left: 0px; top: 10px; width: 100px; height: 35px; z-index: 1000000000;');
  397. document.getElementsByTagName('body') [0].appendChild(btnTvp);
  398. addEvent(document.getElementById('btnTvp'), 'click', function () {
  399. PokazLinkTvp();
  400. });
  401. }
  402. }
  403. }
  404. }
  405. else if (url.indexOf('www.cda.pl') > - 1) {
  406. var btnCda = document.createElement('input');
  407. btnCda.setAttribute('value', 'Pobierz video');
  408. btnCda.setAttribute('type', 'button');
  409. btnCda.setAttribute('id', 'btnCda');
  410. btnCda.setAttribute('style', 'position:fixed !important; left: 0px; top: 2px; width: 95px; height: 30px; z-index: 1000000000;');
  411. document.getElementsByTagName('body') [0].appendChild(btnCda);
  412. addEvent(document.getElementById('btnCda'), 'click', function () {
  413. PokazLinkCda();
  414. });
  415. }
  416. }
  417. }
  418. if(window.jQuery){
  419. $(document).ready(function() {
  420. SkryptDoPobieraniaStart();
  421. });
  422. }
  423. else{
  424. window.onload = SkryptDoPobieraniaStart();
  425. }
  426. /*document.addEventListener("DOMContentLoaded", function(event) {
  427. SkryptDoPobieraniaStart();
  428. });*/
Advertisement
Add Comment
Please, Sign In to add comment