Created
March 25, 2016 00:53
-
-
Save son0fhobs/53fe93c6bb3674a348d8 to your computer and use it in GitHub Desktop.
Putlocker Autoscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$=jQuery; | |
jqueryLoaded(); | |
function jqueryLoaded(){ | |
// I made $=jquery global, which isn't the best idea, but it was convenient, and this isn't exactly a huge project | |
options = { | |
includeHeader:false | |
}; | |
var url = document.location.href; | |
// check if episode page or season list, run code accordingly | |
if(~url.indexOf('episode')){ | |
// specific episode, get rid of everything except video | |
episodePage(); | |
}else{ | |
// page with episode/season guide, search page, home page, or anything else | |
listPage(); | |
} | |
_adr = null; | |
antiClickjack = null; | |
} | |
function listPage(){ | |
console.log('list page function'); | |
var $header = $('td.mainlogo').closest('table'); | |
var $content = $('.content-box'); | |
var $body = $('body'); | |
$body.children().remove(); | |
if(options.includeHeader){ | |
$header.css({'position':'relative','margin':'5px auto'}); | |
$body.append($header) | |
} | |
$body.append($content); | |
$content.css({'position':'relative','margin':'5px auto'}); | |
$('[id^=MarketGidScriptRoot]').nextAll().remove(); | |
$('[id^=MarketGidScriptRoot]').remove(); | |
$('.abineContentPanel').remove(); // hidden, not sure | |
} | |
function episodePage(){ | |
console.log('episode page'); | |
var video_selector = ''; | |
var video_selectors = ['#videoPlayer', '.video', '#video']; | |
var $video = ''; | |
if(document.location.hostname == 'putlocker.is' && $('.video').length){ | |
$video = $('.video'); | |
if($video.find('iframe').length){ | |
$video = $video.find('iframe'); | |
} | |
console.log('is putlocker'); | |
_adr = null; | |
antiClickjack = null; | |
}else if($(video_selector).length){ | |
$video = $(video_selector); | |
remove_ads(); | |
}else{ | |
$video = find_common_selectors(video_selectors); | |
if(!$video){ | |
$video = find_objects_iframes(); | |
remove_ads(); | |
} | |
remove_overlayed_elems(); | |
} | |
if(!$video){ | |
alert('no video selector element found'); | |
// add prompt to add? Or force add to gist? | |
}else{ | |
show_only_video($video); | |
} | |
} | |
// remove overlayed/fixed elems in case doesn't fix everything else | |
function remove_overlayed_elems(){ | |
$('*').each(function(){ | |
if($(this).css('position') == 'fixed'){ | |
$(this).remove(); | |
} | |
}); | |
} | |
function find_common_selectors(video_selectors){ | |
var $video = ''; | |
for(i=0;i<video_selectors.length;i++){ | |
if($(video_selectors[i]).length){ | |
$video = $(video_selectors[i]); | |
return $video; | |
break; | |
} | |
} | |
return; | |
} | |
function find_objects_iframes(){ | |
var $objects = ''; | |
var $iframes = ''; | |
if($('iframe').length){ | |
$iframes = $('iframe'); | |
if(typeof $iframes === 'object' && $iframes.length > 1){ | |
$.grep($iframes, function(elem, i){ | |
// attr not working... | |
if($(elem).attr('src') !== 'undefined'){ | |
if($(elem).attr('src').indexOf('ads') || $(elem).attr('src').indexOf('facebook') || $(elem).attr('src').indexOf('addthis')){ | |
return false; | |
} | |
} | |
}); | |
} | |
$video = $iframes; | |
return $iframes; | |
}else if($('object').length){ | |
$objects = $('object'); | |
}if($('embed').length){ | |
$objects = $('embed'); | |
}else{ | |
console.log('No iframes or objects found on page'); | |
} | |
return $objects; | |
} | |
function show_only_video($video){ | |
$body_children = $('body').children(); // allow to add back if necessary | |
$body_children.remove(); | |
$video.appendTo('body'); | |
$('body').css({'background':'#111', 'text-align':'center', 'margin':'100px'}); | |
$video.css({'border':'1px solid #000','box-shadow':'2px 2px 8px #000, 1px 1px 20px #040404', 'margin':'auto'}); | |
$('html').css({'box-shadow':'1px 1px 2px #000 inset'}); | |
} | |
function remove_ads(){ | |
var ad_selectors = ['.ads']; | |
$(ad_selectors).css('border', '1px solid #33e'); | |
setTimeout(function(){ | |
$(ad_selectors).remove(); | |
}, 1500); | |
} | |
function add_all_elems_back($video){ | |
$video.remove(); | |
$('body').css({'margin':'0'}); | |
$('html').css({'box-shadow':'none'}); | |
$body_children.appendTo('body'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment