Mercurial > ec-userscripts
diff soranews-image.user.js @ 84:af4f8b25495e
Merge elements first and use actual srcset
author | nanaya <me@nanaya.pro> |
---|---|
date | Thu, 15 Apr 2021 14:56:23 +0900 |
parents | 86da34e62d29 |
children | 9c8cde985caf |
line wrap: on
line diff
--- a/soranews-image.user.js Tue Apr 13 15:11:32 2021 +0900 +++ b/soranews-image.user.js Thu Apr 15 14:56:23 2021 +0900 @@ -1,7 +1,7 @@ // ==UserScript== // @name Soranews image fix // @namespace https://myconan.net -// @version 1.0.2 +// @version 1.0.3 // @description Soranews lazy load image fix // @author nanaya // @match https://soranews24.com/* @@ -19,11 +19,8 @@ } for (var i = 0; i < nodes.length; i++) { - // first try fixing itself - fix(nodes[i]) - - // and then find all the images inside - var images = nodes[i].querySelectorAll('.lazy') + // find all the images inside (and self) + var images = [nodes[i], ...nodes[i].querySelectorAll('.lazy')] for (var j = 0; j < images.length; j++) { fix(images[j]) @@ -39,7 +36,7 @@ image.classList.remove('lazy') image.removeAttribute('src') - image.setAttribute('srcset', image.dataset.scoSrc) + image.setAttribute('srcset', image.dataset.scoSrcset) } var onMutate = function (mutations) {