Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************
- Trollvids Sauce Finder
- v1.1
- 9/5/2014
- Gets download links from
- trollvids.com videos
- ********************************/
- // Make sure page has jQuery
- if (typeof $ === 'undefined'){
- var error = "Could not find jQuery object!";
- alert(error);
- throw new Error(error);
- }
- // Initialize modal code
- if (typeof modal === 'undefined'){
- var modal = {};
- modal.init = false;
- modal.info = 'Trollvids Sauce Finder v1.1';
- }
- // Search page for video source
- function main(){
- if (window.location.hostname != 'trollvids.com'){
- var error = "This script will only work on trollvids.com";
- alert(error);
- throw new Error(error);
- }
- var player_container = $('.watch_left .player_container');
- if (!player_container.length){
- modal.open("Video player not found", "Couldn't find the video player on this page. Maybe the site updated.");
- return;
- }
- if (player_container.find('iframe').length){
- // Video Sources:
- // -Google videos
- var vid_id = player_container.find('iframe').attr('src').match(/file\/d\/(.*)\/preview/);
- vid_id = vid_id ? vid_id[1] : null;
- if (!vid_id){
- modal.open("Video Not Found", "Couldn't find the video source. Sorry!");
- return false;
- }
- var vid_path = "https://docs.google.com/uc?id="+vid_id+"&export=download";
- var content = "";
- 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>";
- content += "<a class='btn' href='"+vid_path+"' target='_blank'><i class='fa fa-download'></i> Download Google Video</a>";
- modal.open("Video Found", content);
- } else if (player_container.find('#nuevoplayer_top').length){
- // Video Sources:
- // -YouTube
- // -Hosted on site
- var vid_id = document.URL.match(/video\/(.*)\//);
- vid_id = vid_id ? vid_id[1] : null;
- var nuevo_url = "/nuevo/player/config.php";
- $.ajax({
- url: nuevo_url,
- data: {v: vid_id},
- success: function(data){
- data = $(data);
- // Check for SD video (usually a .flv)
- var file_sd_path = data.find('config file').text();
- var header = "Video Found";
- var content = "";
- if (file_sd_path){
- if (file_sd_path.indexOf('.flv') > -1){
- // FLV source
- content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-download'></i> Download (SD FLV)</a>";
- } else if (file_sd_path.indexOf('.mp4') > -1) {
- // MP4 source
- content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-download'></i> Download (SD MP4)</a>";
- } else if (file_sd_path.indexOf('youtube') > -1){
- // YouTube Video source
- content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-play'></i> Watch YouTube Video</a>";
- } else {
- content += "<a class='btn' href='"+file_sd_path+"' target='_blank'><i class='fa fa-download'></i> Download (SD)</a>";
- }
- }
- // Check for HD video (.mp4)
- var file_hd_path = data.find('config filehd').text();
- if (file_hd_path){
- content += "<a class='btn' href='"+file_hd_path+"' target='_blank'><i class='fa fa-download'></i> Download (HD MP4)</a>";
- }
- // Display failure message
- if (content == ""){
- header = "Video Not Found";
- content += "<p>Couldn't find the video source. Sorry!</p>";
- }
- // Extra info
- content += "<br><br><a href='"+nuevo_url+"?v="+vid_id+"' target='_blank'>View video config data</a>";
- content += "<i class='muted'>Note: Some video sources may be missing due to site issues.</i>";
- modal.open(header, content);
- }
- });
- } else {
- // Failsafe in case there's a new video embed format
- // that this script doesn't include
- modal.open("Video Not Found", "This embedded video format hasn't been coded into this script!");
- }
- }
- // Initialize Modal code
- function init(){
- modal.init = true;
- // Close modal object
- modal.close = function(){
- if (modal.object){
- modal.object.fadeOut(200, function(){
- $(this).remove();
- });
- modal.object = null;
- }
- };
- // Get Fontawesome
- $('<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">').appendTo('body');
- // Modal styling
- $("<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');
- // Create modal with header text and main content
- modal.open = function(header, content){
- // Close existing modal
- modal.close();
- 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>";
- // Create modal object
- modal.object = $(modal_html);
- // Click event for closing modal
- modal.object.find('.close').click(modal.close);
- // Fill in content
- modal.object.find('.header').html(header);
- modal.object.find('.content').html(content);
- modal.object.find('.version').html(modal.info);
- // Append modal to page
- $('body').append(modal.object);
- // Show it
- modal.object.hide();
- modal.object.fadeIn(200);
- modal.object.find('.dialogue').animate({'margin-top': '30px'}, 200);
- };
- // Clicking on backdrop closes modal
- $(document).mouseup(function(e){
- if ($(e.target).is('#tsf')) modal.close();
- });
- }
- // Run script
- if (!modal.init) init();
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement