comparison melonbooks-unlazy.user.js @ 102:3fded109e23a

Also run on own node
author nanaya <me@nanaya.net>
date Sat, 24 Dec 2022 21:33:30 +0900
parents b44d5cb661c5
children 93e21738b588
comparison
equal deleted inserted replaced
101:e21710f5dd7b 102:3fded109e23a
2 // @name melonbooks unlazy 2 // @name melonbooks unlazy
3 // @namespace https://nanaya.net 3 // @namespace https://nanaya.net
4 // @match https://www.melonbooks.co.jp/* 4 // @match https://www.melonbooks.co.jp/*
5 // @grant none 5 // @grant none
6 // @run-at document-start 6 // @run-at document-start
7 // @version 1.0.3 7 // @version 1.0.4
8 // @author nanaya 8 // @author nanaya
9 // @description replace lazy loaded images with just images 9 // @description replace lazy loaded images with just images
10 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/melonbooks-unlazy.user.js 10 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/melonbooks-unlazy.user.js
11 // ==/UserScript== 11 // ==/UserScript==
12 12
13 'use strict' 13 'use strict'
14 14
15 function fix (image) { 15 function fix (image) {
16 if (!image.classList.contains('lazyload')) return
17
16 const src = image.dataset.src 18 const src = image.dataset.src
17 19
18 if (src == null || src === '') return 20 if (src == null || src === '') return
19 21
20 image.classList.remove('lazyload') 22 image.classList.remove('lazyload')
24 26
25 function onMutate (mutations) { 27 function onMutate (mutations) {
26 for (const mutation of mutations) { 28 for (const mutation of mutations) {
27 for (const node of mutation.addedNodes) { 29 for (const node of mutation.addedNodes) {
28 if (node instanceof window.HTMLElement) { 30 if (node instanceof window.HTMLElement) {
31 fix(node)
29 for (const image of node.querySelectorAll('.lazyload')) { 32 for (const image of node.querySelectorAll('.lazyload')) {
30 fix(image) 33 fix(image)
31 } 34 }
32 } 35 }
33 } 36 }