diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/melonbooks-unlazy.user.js	Fri Dec 23 19:10:50 2022 +0900
@@ -0,0 +1,31 @@
+// ==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()
+}