view melonbooks-unlazy.user.js @ 95:afad36fddb64

Add melonbooks unlazy
author nanaya <me@nanaya.net>
date Fri, 23 Dec 2022 19:10:50 +0900
parents
children 368035f2213b
line wrap: on
line source

// ==UserScript==
// @name        melonbooks unlazy
// @namespace   https://nanaya.net
// @match       https://www.melonbooks.co.jp/*
// @grant       none
// @version     1.0.0
// @author      nanaya
// @description replace lazy loaded images with just images
// @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/melonbooks-unlazy.user.js
// ==/UserScript==

'use strict'

function unlazy () {
  for (const img of document.querySelectorAll('.lazyload')) {
    const src = img.dataset.src

    if (src != null) {
      img.src = src
      img.classList.remove('lazyload')
      img.classList.add('unlazied')
      delete img.dataset.src
    }
  }
}

if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', unlazy)
} else {
  unlazy()
}