(function() { // Code Here const formats = ['jpeg', 'jpg', 'png'] let links = document.querySelectorAll('a[href]:not([itemprop])'); links.forEach(function(link){ let url = link.getAttribute('href'); let ext = _getUrlExt(url); if(formats.includes(ext)){ let content = link.textContent; if(content != 'Просмотр'){ let image = document.createElement("img"); image.setAttribute('class', 'lorpic'); image.setAttribute('src', url); //link.replaceWith(image); link.innerHTML = ""; link.appendChild(image); link.setAttribute('target', '_blank'); } } }); function _getUrlExt(url){ return url.split('.').pop(); } })();