remove image lazy load

remove lazyload on img div

Από την 02/05/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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