Last active
December 2, 2019 04:54
-
-
Save Kazuki-tam/15ab9c7231db8fe6dfede399d1745d43 to your computer and use it in GitHub Desktop.
Bookmarklet Script for Download Image
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
/* | |
全画像ダウンロード | |
*/ | |
function downloadAll() { | |
// 画像要素取得 | |
const imgLinks = document.querySelectorAll( | |
".swiper-container .swiper-slide img" | |
); | |
imgLinks.forEach((value, index) => { | |
const url = value.src; | |
// 画像名取得 | |
const fileName = "download-file" + index; | |
const link = document.createElement("a"); | |
// ダウンロード用リンク設定 | |
link.href = url; | |
link.download = fileName; | |
// aタグ作成 | |
document.body.appendChild(link); | |
// リンククリック | |
link.click(); | |
// aタグ削除 | |
document.body.removeChild(link); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment