Advertisement
Guest User

Trollvids Sauce Finder v1.1 (Source)

a guest
Sep 5th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********************************
  2.     Trollvids Sauce Finder
  3.     v1.1
  4.     9/5/2014
  5.    
  6.     Gets download links from
  7.     trollvids.com videos
  8. ********************************/
  9. // Make sure page has jQuery
  10. if (typeof $ === 'undefined'){
  11.     var error = "Could not find jQuery object!";
  12.     alert(error);
  13.     throw new Error(error);
  14. }
  15.  
  16. // Initialize modal code
  17. if (typeof modal === 'undefined'){
  18.     var modal = {};
  19.     modal.init = false;
  20.     modal.info = 'Trollvids Sauce Finder v1.1';
  21. }
  22.  
  23. // Search page for video source
  24. function main(){
  25.     if (window.location.hostname != 'trollvids.com'){
  26.         var error = "This script will only work on trollvids.com";
  27.         alert(error);
  28.         throw new Error(error);
  29.     }
  30.    
  31.     var player_container = $('.watch_left .player_container');
  32.     if (!player_container.length){
  33.         modal.open("Video player not found", "Couldn't find the video player on this page. Maybe the site updated.");
  34.         return;
  35.     }
  36.    
  37.     if (player_container.find('iframe').length){
  38.         // Video Sources:
  39.         //      -Google videos
  40.         var vid_id = player_container.find('iframe').attr('src').match(/file\/d\/(.*)\/preview/);
  41.         vid_id = vid_id ? vid_id[1] : null;
  42.         if (!vid_id){
  43.             modal.open("Video Not Found", "Couldn't find the video source. Sorry!");
  44.             return false;
  45.         }
  46.         var vid_path = "https://docs.google.com/uc?id="+vid_id+"&export=download";
  47.        
  48.         var content = "";
  49.         content += "<a class='btn' href='"+player_container.find('iframe').attr('src')+"?start=1"+"' target='_blank'><i class='fa fa-play'></i> Watch Google Video</a>";
  50.         content += "<a class='btn' href='"+vid_path+"' target='_blank'><i class='fa fa-download'></i> Download Google Video</a>";
  51.        
  52.         modal.open("Video Found", content);
  53.     } else if (player_container.find('#nuevoplayer_top').length){
  54.         // Video Sources:
  55.         //      -YouTube
  56.         //      -Hosted on site
  57.         var vid_id = document.URL.match(/video\/(.*)\//);
  58.         vid_id = vid_id ? vid_id[1] : null;
  59.         var nuevo_url = "/nuevo/player/config.php";
  60.         $.ajax({
  61.             url: nuevo_url,
  62.             data: {v: vid_id},
  63.             success: function(data){
  64.                 data = $(data);
  65.                
  66.                 // Check for SD video (usually a .flv)
  67.                 var file_sd_path = data.find('config file').text();
  68.                 var header = "Video Found";
  69.                 var content = "";
  70.                 if (file_sd_path){
  71.                     if (file_sd_path.indexOf('.flv') > -1){
  72.                         // FLV source
  73.                         content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-download'></i> Download (SD FLV)</a>";
  74.                     } else if (file_sd_path.indexOf('.mp4') > -1) {
  75.                         // MP4 source
  76.                         content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-download'></i> Download (SD MP4)</a>";
  77.                     } else if (file_sd_path.indexOf('youtube') > -1){
  78.                         // YouTube Video source
  79.                         content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-play'></i> Watch YouTube Video</a>";
  80.                     } else {
  81.                         content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-download'></i> Download (SD)</a>";
  82.                     }
  83.                 }
  84.                
  85.                 // Check for HD video (.mp4)
  86.                 var file_hd_path = data.find('config filehd').text();
  87.                 if (file_hd_path){
  88.                     content += "<a class='btn' href='"+file_hd_path+"' target='_blank'><i class='fa fa-download'></i> Download (HD MP4)</a>";
  89.                 }
  90.                
  91.                 // Display failure message
  92.                 if (content == ""){
  93.                     header = "Video Not Found";
  94.                     content += "<p>Couldn't find the video source. Sorry!</p>";
  95.                 }
  96.                
  97.                 // Extra info
  98.                 content += "<br><br><a href='"+nuevo_url+"?v="+vid_id+"' target='_blank'>View video config data</a>";
  99.                 content += "<i class='muted'>Note: Some video sources may be missing due to site issues.</i>";
  100.                
  101.                 modal.open(header, content);
  102.             }
  103.         });
  104.     } else {
  105.         // Failsafe in case there's a new video embed format
  106.         // that this script doesn't include
  107.         modal.open("Video Not Found", "This embedded video format hasn't been coded into this script!");
  108.     }
  109. }
  110.  
  111. // Initialize Modal code
  112. function init(){
  113.     modal.init = true;
  114.    
  115.     // Close modal object
  116.     modal.close = function(){
  117.         if (modal.object){
  118.             modal.object.fadeOut(200, function(){
  119.                 $(this).remove();
  120.             });
  121.             modal.object = null;
  122.         }
  123.     };
  124.    
  125.     // Get Fontawesome
  126.     $('<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">').appendTo('body');
  127.    
  128.     // Modal styling
  129.     $("<style>#tsf{line-height: 20px;position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;display:block;background-color:rgba(0,0,0,.5)}#tsf .dialogue{background-color:#292929;color:#eee;max-width:600px;height:200px;margin:0 auto;font-size:14px;position:relative;box-shadow:0 2px 6px rgba(0,0,0,.7)}#tsf .muted{color:#777;font-size:13px}#tsf a{color:#aaa;display:block}#tsf a:hover{color:#ccc}#tsf .close{position:absolute;top:0;right:0;margin:6px 8px;font-size:20px;cursor:pointer;color:#aaa}#tsf .close:hover{color:#ccc}#tsf .header{border-bottom:1px solid #444;font-size:20px;padding:8px}#tsf .content{padding:8px}#tsf a.btn{background-color:#333;border:1px solid #444;border-radius:2px;padding:7px 9px;display:inline-block;margin:3px;text-decoration:none}#tsf a.btn:hover{background-color:#393939;}#tsf *{transition:color .2s,background-color .2s;} #tsf .version{position:absolute;bottom:0;right:0;text-align:right;font-size:11px;color:#777;padding:3px 5px;}</style>").appendTo('body');
  130.    
  131.     // Create modal with header text and main content
  132.     modal.open = function(header, content){
  133.         // Close existing modal
  134.         modal.close();
  135.        
  136.         var modal_html = "<div id='tsf'><div class='dialogue'><div class='close'><i class='fa fa-times'></i></div><div class='header'></div><div class='content'></div><div class='version'></div></div></div>";
  137.            
  138.         // Create modal object
  139.         modal.object = $(modal_html);
  140.        
  141.         // Click event for closing modal
  142.         modal.object.find('.close').click(modal.close);
  143.        
  144.         // Fill in content
  145.         modal.object.find('.header').html(header);
  146.         modal.object.find('.content').html(content);
  147.        
  148.         modal.object.find('.version').html(modal.info);
  149.        
  150.         // Append modal to page
  151.         $('body').append(modal.object);
  152.        
  153.         // Show it
  154.         modal.object.hide();
  155.         modal.object.fadeIn(200);
  156.         modal.object.find('.dialogue').animate({'margin-top': '30px'}, 200);
  157.     };
  158.    
  159.     // Clicking on backdrop closes modal
  160.     $(document).mouseup(function(e){
  161.         if ($(e.target).is('#tsf')) modal.close();
  162.     });
  163. }
  164.  
  165. // Run script
  166. if (!modal.init) init();
  167. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement