remove image lazy load

remove lazyload on img div

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         remove image lazy load
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  remove lazyload on img div
// @author       Charles
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @match        *://**/*
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// ==/UserScript==

(function () {
  "use strict";
  let white_lists = GM_getValue("whitelists", []);
  let host_name = document.location.hostname;
  GM_registerMenuCommand("add site to enable remove lazy load", function () {
    console.log(host_name);
    // if host name is in white list, return
    if (white_lists.includes(host_name)) {
      return;
    }
    GM_setValue("whitelists", white_lists.concat(host_name));
  });
  GM_registerMenuCommand(
    "remove site to disable remove lazy load",
    function () {
      console.log(host_name);
      // if host name is not in white list, return
      if (!white_lists.includes(host_name)) {
        return;
      }
      GM_setValue(
        "whitelists",
        white_lists.filter((e) => e !== host_name)
      );
    }
  );
  // if host name is in white list , then enable remove lazy load
  if (white_lists.includes(host_name)) {
    // remove loading attribute
    let images = document.getElementsByTagName("img");
    for (let image of images) {
      image.removeAttribute("loading");
      // set data-src to src
      if (image.getAttribute("data-src") !== null)
        image.setAttribute("src", image.getAttribute("data-src"));
      else if (image.getAttribute("data-original") !== null)
        image.setAttribute("src", image.getAttribute("data-original"));
    }
  }
})();