95
|
1 // ==UserScript==
|
|
2 // @name melonbooks unlazy
|
|
3 // @namespace https://nanaya.net
|
|
4 // @match https://www.melonbooks.co.jp/*
|
|
5 // @grant none
|
97
|
6 // @run-at document-start
|
|
7 // @version 1.0.2
|
95
|
8 // @author nanaya
|
|
9 // @description replace lazy loaded images with just images
|
|
10 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/melonbooks-unlazy.user.js
|
|
11 // ==/UserScript==
|
|
12
|
|
13 'use strict'
|
|
14
|
97
|
15 function fix (image) {
|
|
16 if (!image.classList.contains('lazyload')) return
|
|
17
|
|
18 image.classList.remove('lazyload')
|
|
19 image.src = image.dataset.src
|
|
20 delete image.dataset.src
|
|
21 }
|
95
|
22
|
97
|
23 function onMutate (mutations) {
|
|
24 for (const mutation of mutations) {
|
|
25 for (const node of mutation.addedNodes) {
|
|
26 if (node instanceof window.HTMLElement) {
|
|
27 for (const image of node.querySelectorAll('.lazyload')) {
|
|
28 fix(image)
|
|
29 }
|
|
30 }
|
|
31 }
|
95
|
32 }
|
|
33 }
|
97
|
34
|
|
35 const observer = new window.MutationObserver(onMutate)
|
|
36 observer.observe(document, { childList: true, subtree: true })
|