Created
March 2, 2013 09:18
-
-
Save mir4a/5070270 to your computer and use it in GitHub Desktop.
This bookmarklet only works on http://fotki.yandex.ru/top and strip all info blocks and left only the photos. Onclick on photo will load the XL sized photo onto simple lightbox.
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
javascript: | |
var script=document.createElement('script'); | |
script.onload = function () { | |
stripPhoto(); | |
}; | |
script.src='http://code.jquery.com/jquery-1.9.1.min.js'; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
function stripPhoto () { | |
var photos = $('.b-photoArray'); | |
var body = $('body'); | |
body.html(photos); | |
photos.css('text-align', 'center').find('.h-photoArray-cell1').css({ | |
'width':'100px', | |
'height':'100px', | |
'overflow':'hidden' | |
}).find('.description').hide().parent().find('img').css({ | |
'width':'100%', | |
'height':'auto' | |
}); | |
var overlay = '<div class=\"overlay\"></div>'; | |
$('body').append(overlay); | |
var clk = $('a.photo'); | |
clk.on('click', function(e){ | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
$.get(url).then( | |
function(data){ | |
var body = $('body'); | |
var str1 = data; | |
var patt1 = /js-img-link\">\<img src=\"(\D+\S+)?\"/i; | |
var str2 = str1.match(patt1); | |
var patt2 = /_\D+\./i; | |
var rep = '_XL.'; | |
var link = str2[1].replace(patt2,rep); | |
var overlay = body.find('.overlay'); | |
overlay.css({ | |
'display':'block', | |
'position':'fixed', | |
'top':'0', | |
'left':'0', | |
'width':'100%', | |
'height':'100%', | |
'text-align':'center', | |
'cursor':'pointer', | |
'background':'rgba(0,0,0,0.5)', | |
'z-index':'100' | |
}).on('click', function(e){ | |
var _this = $(this); | |
_this.hide(); | |
_this.html(''); | |
}); | |
var big = '<img class=\"b-photo_big\" src=\"'+link+'\">'; | |
overlay.append(big); | |
var bigP = body.find('.b-photo_big'); | |
bigP.css({ | |
'position': 'relative', | |
'display':'inline-block' | |
}); | |
console.log(link); | |
}, | |
function(){ alert('$.get failed!'); } | |
); | |
}) | |
} | |
void 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok!