Fetch lazy-load images immediately at document load
Version vom
// ==UserScript==
// @name Behance - fetch lazy-load images immediately
// @description Fetch lazy-load images immediately at document load
// @include https://www.behance.net/*
// @version 1.02
// @namespace wOxxOm.scripts
// @author wOxxOm
// @run-at document-start
// ==/UserScript==
window.addEventListener('DOMContentLoaded', function(e) {
var placeholders = document.querySelectorAll('.js-picture-lazy');
for (var i=0, len=placeholders.length, p, img; i<len && (p=placeholders[i]); i++) {
if (img = p.querySelector('img')) {
img.src = img.dataset.src;
img.deleteAttribute('width');
img.deleteAttribute('height');
img.deleteAttribute('style');
}
var picture = document.createElement('picture');
while (p.firstElementChild)
picture.appendChild(p.removeChild(p.firstElementChild));
p.parentNode.replaceChild(picture, p);
p.remove();
}
});