Last active
July 16, 2020 02:42
-
-
Save smallfield/4b0b5cdc5d3bf9efa24399cbc9a218b9 to your computer and use it in GitHub Desktop.
bait画像表示
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
// bait | |
var imgLinks=document.querySelectorAll(".product-image-gallery img.gallery-image"); | |
imgLinks.forEach((img_tag,index)=>{ | |
const url=img_tag.src; | |
console.log(url); | |
const parent=document.querySelector(".product-name"); | |
const link=document.createElement("a"); | |
link.href=url; | |
link.target="_blank"; | |
link.download = true; | |
link.innerHTML="Download " + (index+1); | |
parent.appendChild(link); | |
parent.appendChild(document.createElement("br")); | |
}); | |
// shopify | |
var imgLinks = document.querySelectorAll("a.MagicZoom"); | |
imgLinks.forEach((a_tag, index) => { | |
const url = a_tag.href; | |
const parent = document.querySelector("div.product-buy-box"); | |
const link = document.createElement("a"); | |
console.log(url); | |
link.href = url; | |
link.target = "_blank"; | |
link.download = true; | |
link.innerHTML = "Download " + (index + 1); | |
const img = document.createElement("img"); | |
img.src = url; | |
img.width = 50; | |
img.height = 50; | |
link.appendChild(img); | |
parent.appendChild(link); | |
parent.appendChild(document.createElement("br")); | |
}); | |
// Target | |
var imgLinks = document.querySelectorAll(".slideDeckPicture img"); | |
imgLinks.forEach((img_tag, index) => { | |
const url = img_tag.src.replace(/\?.*$/i, "?wid=1200&hei=1200&fmt=png-alpha"); | |
const parent = document.querySelector("div.h-margin-b-tight.h-margin-t-tiny"); | |
const link = document.createElement("a"); | |
console.log(url); | |
link.href = url; | |
link.target = "_blank"; | |
link.download = true; | |
link.innerHTML = "Download " + (index + 1); | |
const img = document.createElement("img"); | |
img.src = url; | |
img.width = 50; | |
img.height = 50; | |
link.appendChild(img); | |
parent.appendChild(link); | |
parent.appendChild(document.createElement("br")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment