# HG changeset patch # User nanaya # Date 1671936750 -32400 # Node ID 93e21738b588d7fbeec623212a0be60b0613bebe # Parent b2d0b37f945f57d851b56b96eb62a8e3776737de Run fix on whole body on start There's no guarantee the script loads before document. diff -r b2d0b37f945f -r 93e21738b588 mandarake-direct-link.user.js --- a/mandarake-direct-link.user.js Sat Dec 24 22:10:30 2022 +0900 +++ b/mandarake-direct-link.user.js Sun Dec 25 11:52:30 2022 +0900 @@ -1,7 +1,7 @@ // ==UserScript== // @name mandarake direct link // @namespace https://myconan.net -// @version 2.0.0 +// @version 2.0.1 // @description Make proper link on mandarake pages // @author nanaya // @match https://order.mandarake.co.jp/* @@ -32,20 +32,24 @@ } } +function run (node) { + if (!(node instanceof window.HTMLElement)) return + if (removeR18Mark(node)) return + + fixR18Link(node) + for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) { + fixR18Link(link) + } +} + function onMutate (mutations) { for (const mutation of mutations) { for (const node of mutation.addedNodes) { - if (node instanceof window.HTMLElement) { - if (removeR18Mark(node)) continue - - fixR18Link(node) - for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) { - fixR18Link(link) - } - } + run(node) } } } const observer = new window.MutationObserver(onMutate) observer.observe(document, { childList: true, subtree: true }) +run(document.body) diff -r b2d0b37f945f -r 93e21738b588 melonbooks-unlazy.user.js --- a/melonbooks-unlazy.user.js Sat Dec 24 22:10:30 2022 +0900 +++ b/melonbooks-unlazy.user.js Sun Dec 25 11:52:30 2022 +0900 @@ -4,7 +4,7 @@ // @match https://www.melonbooks.co.jp/* // @grant none // @run-at document-start -// @version 1.0.4 +// @version 1.0.5 // @author nanaya // @description replace lazy loaded images with just images // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/melonbooks-unlazy.user.js @@ -24,18 +24,23 @@ delete image.dataset.src } +function run (node) { + if (!(node instanceof window.HTMLElement)) return + + fix(node) + for (const image of node.querySelectorAll('.lazyload')) { + fix(image) + } +} + function onMutate (mutations) { for (const mutation of mutations) { for (const node of mutation.addedNodes) { - if (node instanceof window.HTMLElement) { - fix(node) - for (const image of node.querySelectorAll('.lazyload')) { - fix(image) - } - } + run(node) } } } const observer = new window.MutationObserver(onMutate) observer.observe(document, { childList: true, subtree: true }) +run(document.body) diff -r b2d0b37f945f -r 93e21738b588 pixiv-fanbox-unlazy.user.js --- a/pixiv-fanbox-unlazy.user.js Sat Dec 24 22:10:30 2022 +0900 +++ b/pixiv-fanbox-unlazy.user.js Sun Dec 25 11:52:30 2022 +0900 @@ -1,7 +1,7 @@ // ==UserScript== // @name pixiv fanbox no lazy loading image // @namespace https://myconan.net -// @version 2.1.1 +// @version 2.1.2 // @description Lazy loading is bad for environment. Disable it. // @author nanaya // @match https://*.fanbox.cc/* @@ -39,18 +39,23 @@ link.replaceChildren(image) } +function run (node) { + if (!(node instanceof window.HTMLElement)) return + + fix(node) + for (const link of node.querySelectorAll(`[href^="${imageUrlPrefix}"]`)) { + fix(link) + } +} + function onMutate (mutations) { for (const mutation of mutations) { for (const node of mutation.addedNodes) { - if (node instanceof window.HTMLElement) { - fix(node) - for (const link of node.querySelectorAll(`[href^="${imageUrlPrefix}"]`)) { - fix(link) - } - } + run(node) } } } const observer = new window.MutationObserver(onMutate) observer.observe(document, { childList: true, subtree: true }) +run(document.body)