Mercurial > ec-userscripts
diff pixiv-fanbox-unlazy.user.js @ 108:2c4470b73ad9
Switch to semistandard
No more `;` at the start of line.
author | nanaya <me@nanaya.net> |
---|---|
date | Sun, 15 Jan 2023 23:24:03 +0900 |
parents | 93e21738b588 |
children | ef21ef445fc6 |
line wrap: on
line diff
--- a/pixiv-fanbox-unlazy.user.js Sun Jan 15 23:15:45 2023 +0900 +++ b/pixiv-fanbox-unlazy.user.js Sun Jan 15 23:24:03 2023 +0900 @@ -10,52 +10,52 @@ // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/pixiv-fanbox-unlazy.user.js // ==/UserScript== -'use strict' +'use strict'; -const imageUrlPrefix = 'https://downloads.fanbox.cc/images/post/' +const imageUrlPrefix = 'https://downloads.fanbox.cc/images/post/'; function disableEventLink (event) { - event.stopPropagation() + event.stopPropagation(); } function fix (link) { - const href = link.href + const href = link.href; // basic sanity check if (typeof href !== 'string' || !href.startsWith(imageUrlPrefix)) { - return + return; } // don't run again if already run on passed link if (link._ecUserscript) { - return + return; } - link._ecUserscript = true + link._ecUserscript = true; - link.addEventListener('click', disableEventLink) - const image = document.createElement('img') - image.style.width = '100%' - image.src = href - link.replaceChildren(image) + link.addEventListener('click', disableEventLink); + const image = document.createElement('img'); + image.style.width = '100%'; + image.src = href; + link.replaceChildren(image); } function run (node) { - if (!(node instanceof window.HTMLElement)) return + if (!(node instanceof window.HTMLElement)) return; - fix(node) + fix(node); for (const link of node.querySelectorAll(`[href^="${imageUrlPrefix}"]`)) { - fix(link) + fix(link); } } function onMutate (mutations) { for (const mutation of mutations) { for (const node of mutation.addedNodes) { - run(node) + run(node); } } } -const observer = new window.MutationObserver(onMutate) -observer.observe(document, { childList: true, subtree: true }) -run(document.body) +const observer = new window.MutationObserver(onMutate); +observer.observe(document, { childList: true, subtree: true }); +run(document.body);