Behance - fetch lazy-load images immediately

Fetch lazy-load images immediately at document load

Stan na 25-04-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
  }
});