Created
January 3, 2021 13:26
-
-
Save K-atc/4eebd88bbbed00e572fb4705b3688b10 to your computer and use it in GitHub Desktop.
<a href=URL> の下に <img src=URL loading=lazy> を追加するブックマークレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
function check_extention(url) { | |
for (const ext of [".jpg", ".jpeg", ".png", ".png"]) { | |
if (url.includes(ext)) return true; | |
} | |
return false; | |
} | |
function append_image(el) { | |
var el_img = document.createElement("img"); | |
el_img.setAttribute("src", el.href); | |
el_img.setAttribute("loading", "lazy"); | |
el.append(el_img); | |
} | |
Array.from(document.getElementsByTagName("a")).filter(function(el) { return check_extention(el.href); }).map(function(el) { append_image(el) } ) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment