Skip to content

Instantly share code, notes, and snippets.

@Kazuki-tam
Last active December 2, 2019 04:54
Show Gist options
  • Save Kazuki-tam/15ab9c7231db8fe6dfede399d1745d43 to your computer and use it in GitHub Desktop.
Save Kazuki-tam/15ab9c7231db8fe6dfede399d1745d43 to your computer and use it in GitHub Desktop.
Bookmarklet Script for Download Image
/*
全画像ダウンロード
*/
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