Guest User

tvrain.ru video downloader v0.2 userjs

a guest
Jan 30th, 2014
147
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name tvrain_video_dl
  3. // @description tvrain.ru video downloader
  4. // @author ANT
  5. // @include http://cloud.tvigle.ru/playlist/*
  6. // @include http://cloud.tvigle.ru/video/*
  7. // @version 0.2
  8. // @created 30.01.2014
  9. // ==/UserScript==
  10.  
  11. window.addEventListener('load', function(e){
  12.  
  13.     document.getElementsByTagName('head')[0].innerHTML += '<link rel="stylesheet" type="text/css" href="http://tvrain-st.cdn.ngenix.net/static/css/pub/style.css?892-1" />';
  14.  
  15.     var match = location.href.match(/http:\/\/cloud.tvigle.ru\/((?:playlist|video)\/(?:\d+))\//);
  16.     if(match)
  17.     {
  18.         var dl_links = "";
  19.         var vid_id = match[1];
  20.         $.getJSON('http://cloud.tvigle.ru/api/play/'+vid_id, function(data) {
  21.             for(i in data.playlist.items)
  22.             {
  23.                 var tmp = "";
  24.                 var vid_avail_res = [];
  25.                 $.each(data.playlist.items[i].videos, function(key, value){ vid_avail_res.push(key); });
  26.                 vid_avail_res.sort();
  27.                 for(a in vid_avail_res)
  28.                 {
  29.                     tmp += '<a href="'+data.playlist.items[i].videos[vid_avail_res[a]]+'">'+vid_avail_res[a]+'</a> ';
  30.                 }
  31.                 dl_links += ((data.playlist.items.length > 1) ? "Часть " + (parseInt(i) + 1) + ": " + tmp : "Скачать: " + tmp) + ((a < vid_avail_res.length) ? "<br>" : "");
  32.             }
  33.             document.getElementsByTagName('body')[0].innerHTML += '<div><div style="float:left" id="my_links">'+dl_links+'</div><div style="float:right;padding-right:5px"><a href="'+location.href+'" title="Текущий URL">URL</a> | <a href="#" onclick="FindVideos(vid_range);" title="Искать платные ролики">Найти</a> | <a href="#" onclick=\'var answ=prompt("Диапазон для поиска:", vid_range); (answ ? vid_range=answ : null);\' title="Диапазон">[*]</a></div></div>';
  34.             document.getElementsByClassName('TviglePlayer')[0].height -= document.getElementById("my_links").clientHeight+3;
  35.  
  36.             var js = document.createElement('script');
  37.             js.text = "var vid_range = '-500,10'";
  38.             document.getElementsByTagName('body')[0].appendChild(js);
  39.  
  40.             var js = document.createElement('script');
  41.             js.text = base64.decode('ICAgIGZ1bmN0aW9uIEZpbmRWaWRlb3MocmFuZ2UpDQogICAgew0KICAgICAgICB2YXIgbWF0Y2ggPSBsb2NhdGlvbi5ocmVmLm1hdGNoKC9odHRwOlwvXC9jbG91ZC50dmlnbGUucnVcL3ZpZGVvXC8oXGQrKVwvLyk7DQogICAgICAgIGlmKG1hdGNoKQ0KICAgICAgICB7DQogICAgICAgICAgICB2YXIgcmFuZ2UgPSByYW5nZS5zcGxpdCgnLCcpOw0KICAgICAgICAgICAgdmFyIHZpZF9mcm9tID0gcGFyc2VJbnQobWF0Y2hbMV0pK3BhcnNlSW50KHJhbmdlWzFdKTsNCiAgICAgICAgICAgIHZhciB2aWRfdG8gPSBwYXJzZUludChtYXRjaFsxXSkrcGFyc2VJbnQocmFuZ2VbMF0pOw0KICAgICAgICAgICAgdmFyIGNvdW50ID0gMDsNCiAgICAgICAgICAgIHZhciBteVBvcHVwID0gd2luZG93Lm9wZW4oJycsJycsJ3dpZHRoPTYwMCxoZWlnaHQ9NDAwLHNjcm9sbGJhcnM9MScpOw0KICAgICAgICAgICAgbXlQb3B1cC5kb2N1bWVudC53cml0ZSgnPGh0bWw+PGhlYWQ+PHRpdGxlPlNlYXJjaCBmb3IgdGhlIHZpZGVvcy4uLjwvdGl0bGU+PGxpbmsgcmVsPSJzdHlsZXNoZWV0IiB0eXBlPSJ0ZXh0L2NzcyIgaHJlZj0iaHR0cDovL3R2cmFpbi1zdC5jZG4ubmdlbml4Lm5ldC9zdGF0aWMvY3NzL3B1Yi9zdHlsZS5jc3M/ODkyLTEiIC8+PC9oZWFkPjxib2R5PjxjZW50ZXI+PGI+PGRpdiBpZD0ibXlfcHJvZ3Jlc3MiPlNlYXJjaGluZy4uLjwvZGl2PjwvYj48L2N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291bnQrKzsNCiAgICAgICAgICAgICAgICAgICAgbXlQb3B1cC5kb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnbXlfcHJvZ3Jlc3MnKS5pbm5lckhUTUwgPSAnUHJvZ3Jlc3M6ICcrTWF0aC5yb3VuZCgxMDAvKHZpZF9mcm9tLXZpZF90bysxKSpjb3VudCkrJyUnOw0KICAgICAgICAgICAgICAgIH0pLmZhaWwoZnVuY3Rpb24oKSB7IGNvdW50Kys7IG15UG9wdXAuZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ215X3Byb2dyZXNzJykuaW5uZXJIVE1MID0gJ1Byb2dyZXNzOiAnK01hdGgucm91bmQoMTAwLyh2aWRfZnJvbS12aWRfdG8rMSkqY291bnQpKyclJzsgfSk7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9');
  42.             document.getElementsByTagName('body')[0].appendChild(js);
  43.         });
  44.     }
  45. }, false);
RAW Paste Data