Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onready(function(){
- var googlesearch = 'https://images.google.com/searchbyimage?image_url=';
- var host = window.location.hostname;
- var add_imgsearch = function(elem) {
- var images = elem.querySelectorAll(".fileinfo > a"); // Получаем все прямые ссылки на файлы
- for(var i = 0; i < images.length; i++) {
- var search_link = document.createElement('a');
- search_link.setAttribute('target', '_blank');
- search_link.setAttribute('href', googlesearch + host + images[i].getAttribute('href'));
- search_link.setAttribute('class', 'fa fa-search');
- search_link.setAttribute('style', 'text-decoration:none');
- images[i].parentNode.insertBefore(search_link, images[i].nextSibling);
- };
- };
- add_imgsearch(document); // Добавляем ссылки к пикчам
- if (window.jQuery) { // Добавляем ссылки к пикчам при аякс-подгрузке
- $(document).on('new_post', function(e, post) {
- add_imgsearch(post);
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement