Skip to content

Instantly share code, notes, and snippets.

@son0fhobs
Last active August 29, 2015 14:12
Show Gist options
  • Save son0fhobs/2bc5cf1b22b48c83adf3 to your computer and use it in GitHub Desktop.
Save son0fhobs/2bc5cf1b22b48c83adf3 to your computer and use it in GitHub Desktop.
putlocker.is bookmarklet
// more thorough explanation and version to share: http://jsfiddle.net/ydj56zy3/5/
/*
// variable selector for grabbing ads, extra iframes?
// prompt for selector. Button to add back all elements and try again?
// if nothing else, color background black.
// find table elements as well.
Bookmarklet:
javascript:(function()%7Bif(typeof jQuery!%3D%3D'function')%7Bvar url%3D'%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1.11.1%2Fjquery.min.js'%3Bvar script%3Ddocument.createElement('script')%3Bscript.src%3Durl%3Bvar head%3Ddocument.getElementsByTagName('head')%5B0%5D%3Bhead.appendChild(script)%3Bscript.onload%3DjqueryLoaded%7Delse%7BjqueryLoaded()%7Dfunction jqueryLoaded()%7B%24%3DjQuery%3Bconsole.log('Make sure you start the video first%2C remove ads. Try to select ads if not in iframe')%3Bvar video_selector%3D''%3Bvar video_selectors%3D%5B'%23videoPlayer'%2C'.video'%2C'%23video'%5D%3Bvar %24video%3D''%3Bif(document.location.hostname%3D%3D'putlocker.is'%26%26%24('.video').length)%7B%24video%3D%24('.video')%3Bconsole.log('is putlocker')%3B_adr%3Dnull%3BantiClickjack%3Dnull%7Delse if(%24(video_selector).length)%7B%24video%3D%24(video_selector)%3Bremove_ads()%7Delse%7B%24video%3Dfind_common_selectors(video_selectors)%3Bif(!%24video)%7B%24video%3Dfind_objects_iframes()%3Bremove_ads()%7D%7Dif(!%24video)%7Balert('no video selector element found')%7Delse%7Bshow_only_video(%24video)%7Dremove_putlocker_overlay()%7Dfunction find_common_selectors(video_selectors)%7Bvar %24video%3D''%3Bfor(i%3D0%3Bi<video_selectors.length%3Bi%2B%2B)%7Bif(%24(video_selectors%5Bi%5D).length)%7B%24video%3D%24(video_selectors%5Bi%5D)%3Breturn %24video%3Bbreak%7D%7Dreturn%7Dfunction find_objects_iframes()%7Bvar %24objects%3D''%3Bvar %24iframes%3D''%3Bif(%24('iframe').length)%7B%24iframes%3D%24('iframe')%3Bif(typeof %24iframes%3D%3D%3D'object'%26%26%24iframes.length>1)%7B%24.grep(%24iframes%2Cfunction(elem%2Ci)%7Bif(%24(elem).attr('src')!%3D%3D'undefined')%7Bif(%24(elem).attr('src').indexOf('ads')%7C%7C%24(elem).attr('src').indexOf('facebook')%7C%7C%24(elem).attr('src').indexOf('addthis'))%7Breturn false%7D%7D%7D)%7D%24video%3D%24iframes%3Breturn %24iframes%7Delse if(%24('object').length)%7B%24objects%3D%24('object')%7Dif(%24('embed').length)%7B%24objects%3D%24('embed')%7Delse%7Bconsole.log('No iframes or objects found on page')%7Dreturn %24objects%7Dfunction show_only_video(%24video)%7B%24body_children%3D%24('body').children()%3B%24body_children.remove()%3B%24video.appendTo('body')%3B%24('body').css(%7B'background'%3A'%23111'%2C'text-align'%3A'center'%2C'margin'%3A'100px'%7D)%3B%24video.css(%7B'border'%3A'1px solid %23000'%2C'box-shadow'%3A'2px 2px 8px %23000%2C 1px 1px 20px %23040404'%2C'margin'%3A'auto'%7D)%3B%24('html').css(%7B'box-shadow'%3A'1px 1px 2px %23000 inset'%7D)%7Dfunction remove_putlocker_overlay()%7B%24('object').remove()%7Dfunction remove_ads()%7Bvar ad_selectors%3D%5B'.ads'%5D%3B%24(ad_selectors).css('border'%2C'1px solid %2333e')%3BsetTimeout(function()%7B%24(ad_selectors).remove()%7D%2C1500)%7D%7D)()
if(typeof jQuery !== 'function'){
var url = '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js';
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0];
head.appendChild(script);
script.onload = jqueryLoaded;
}else{
jqueryLoaded();
}
function jqueryLoaded(){
$=jQuery;
console.log('Make sure you start the video first, remove ads. Try to select ads if not in iframe');
var video_selector = '';
var video_selectors = ['#videoPlayer', '.video', '#video'];
var $video = '';
if(document.location.hostname == 'putlocker.is' && $('.video').length){
$video = $('.video');
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');
}
*/
// first jqueryify, then this the actual code used
$=jQuery
$video = $('.filminfo3 iframe').eq(1);
$('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'});
$('html').css({'box-shadow':'1px 1px 2px #000 inset'});
_adr = null;
antiClickjack = null;
// js compression: http://javascriptcompressor.com/
// generated here: http://benalman.com/code/test/jquery-run-code-bookmarklet/
// Use this for overly thorough jquery bookmarklet - http://www.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/
// full version with jQuery or $ being universal for easy working with
var url = '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js';
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0];
script.onload = jqueryLoaded;
head.appendChild(script);
function jqueryLoaded(){
$=jQuery
$video = $('.video');
$('body').children().remove();
$video.appendTo('body');
$('body').css({'background':'#111', 'text-align':'center', 'margin':'100px'});
$('iframe').css({'border':'1px solid #000','box-shadow':'2px 2px 8px #000, 1px 1px 20px #040404'});
$('html').css({'box-shadow':'1px 1px 2px #000 inset'});
_adr = null;
antiClickjack = null;
}
var head = document.getElementsByTagName("head")[0], done = false;
var script = document.createElement("script");
script.src = url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment