Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************
- Trollvids Sauce Finder
- v1.0 (Initial Release)
- 9/5/2014
- Gets download links from
- trollvids.com videos
- ********************************/
- // Search page for video source
- function main(){
- var player_container = $('.watch_left .player_container');
- if (player_container.find('iframe').length){
- // Video Sources:
- // -Google videos
- var vid_id = player_container.find('iframe').attr('src').match(/file\/d\/(.*)\/preview/)[1];
- 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";
- modal.open("Video Found", "<a href='"+vid_path+"' target='_blank'>Google Video</a>");
- } else if (player_container.find('#nuevoplayer_top').length){
- // Video Sources:
- // -YouTube
- // -Hosted on site
- var vid_id = document.URL.match(/video\/(.*)\//)[1];
- 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 href='"+file_sd_path+"' target='_blank'>Download (SD FLV)</a>";
- } else if (file_sd_path.indexOf('.mp4') > -1) {
- // MP4 source
- content += "<a href='"+file_sd_path+"' target='_blank'>Download (SD MP4)</a>";
- } else if (file_sd_path.indexOf('youtube') > -1){
- // YouTube Video source
- content += "<a href='"+file_sd_path+"' target='_blank'>YouTube Video</a>";
- } else {
- content += "<a href='"+file_sd_path+"' target='_blank'>Download (SD)</a>";
- }
- }
- // Check for HD video (.mp4)
- var file_hd_path = data.find('config filehd').text();
- if (file_hd_path){
- content += "<a href='"+file_hd_path+"' target='_blank'>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><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!");
- }
- }
- // Instantiate modal code and stuff
- if (typeof modal === 'undefined'){
- var modal = {};
- modal.object;
- // Close modal object
- modal.close = function(){
- if (modal.object){
- modal.object.fadeOut(200, function(){
- $(this).remove();
- });
- modal.object = null;
- }
- }
- // Some extra modal styling
- $("<style>.muted{color:#777;font-size:13px;}.modal_container a{color:#aaa; display: block; margin-bottom: 5px;}.modal_container a:hover{color:#ccc;}.modal_close{color:#aaa;}.modal_close:hover{color:#ccc;}</style>").appendTo('body');
- // Create modal with header text and main content
- modal.open = function(header, content){
- // Close existing modal
- modal.close();
- // Contains all subsequent modal elements and darkens screen
- var modal_container = $("<div class='modal_container'>").css({
- 'position': 'fixed',
- 'top': 0,
- 'right': 0,
- 'bottom': 0,
- 'left': 0,
- 'z-index': 1050,
- 'outline': 0,
- 'display': 'block',
- 'background-color': 'rgba(0, 0, 0, .5)'
- });
- // Centered box
- var modal_dialogue = $("<div class='modal_dialogue'>").css({
- 'background-color': '#222',
- 'color': '#eee',
- 'width': '600px',
- 'height': '200px',
- 'margin': '30px auto',
- 'font-size': '14px',
- 'position': 'relative',
- 'box-shadow': '0 2px 6px rgba(0, 0, 0, .7)'
- });
- // Header text
- var modal_header = $("<div class='modal_header'>").css({
- 'border-bottom': '1px solid #444',
- 'padding': '8px',
- 'font-size': '20px'
- });
- // Main content
- var modal_content = $("<div class='modal_content'>").css({
- 'padding': '8px',
- 'font-size': '14px'
- });
- // Close button
- var modal_close = $("<div class='modal_close'>×</div>").css({
- 'position': 'absolute',
- 'top': 0,
- 'right': 0,
- 'margin': '2px 8px',
- 'font-size': '30px',
- 'cursor': 'pointer'
- });
- modal_close.click(modal.close);
- // Put it all together
- modal_header.html(header);
- modal_content.html(content);
- modal_dialogue.append(modal_close);
- modal_dialogue.append(modal_header);
- modal_dialogue.append(modal_content);
- modal_container.append(modal_dialogue);
- // Show it
- $('body').append(modal_container);
- modal.object = modal_container;
- modal.object.hide();
- modal.object.fadeIn(200);
- }
- $(document).mouseup(function(e){
- if ($(e.target).hasClass('modal_container')) modal.close();
- });
- }
- // Run main function
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement