annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
1 // ==UserScript==
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
2 // @name melonbooks unlazy
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
3 // @namespace https://nanaya.net
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
4 // @match https://www.melonbooks.co.jp/*
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
5 // @grant none
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
6 // @version 1.0.0
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
7 // @author nanaya
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
8 // @description replace lazy loaded images with just images
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
9 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/melonbooks-unlazy.user.js
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
10 // ==/UserScript==
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
11
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
12 'use strict'
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
13
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
14 function unlazy () {
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
15 for (const img of document.querySelectorAll('.lazyload')) {
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
16 const src = img.dataset.src
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
17
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
18 if (src != null) {
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
19 img.src = src
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
20 img.classList.remove('lazyload')
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
21 img.classList.add('unlazied')
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
22 delete img.dataset.src
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
23 }
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
24 }
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
25 }
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
26
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
27 if (document.readyState === 'loading') {
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
28 document.addEventListener('DOMContentLoaded', unlazy)
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
29 } else {
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
30 unlazy()
afad36fddb64 Add melonbooks unlazy
nanaya <me@nanaya.net>
parents:
diff changeset
31 }