Last active
December 15, 2019 07:09
-
-
Save eai04191/8ccdcf9add1536ab4fbaf3d6df050baa to your computer and use it in GitHub Desktop.
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
let html = `<button type="button" id="saveAllWifus" class="bp3-button bp3-large bp3-intent-primary" style="position: absolute; top: 20px; right: 20px;">💾 Save ALL Waifus</button>`; | |
document.querySelector(".App").insertAdjacentHTML("beforeend", html); | |
document.querySelector("#saveAllWifus").addEventListener("click", () => { | |
download(); | |
}); | |
async function download() { | |
for (const property in document.querySelector(".cards-container")) { | |
if (property.startsWith("__reactInternalInstance")) { | |
const girls = document.querySelector(".cards-container")[property] | |
.memoizedProps.children; | |
const awaitGet = async girl => { | |
await new Promise(resolve => setTimeout(resolve, 1000)); | |
const seeds = girl.props.girl.seeds; | |
console.log(seeds); | |
const body = JSON.stringify({ | |
currentGirl: seeds, | |
step: 4, | |
size: 512 | |
}); | |
fetch("https://api.waifulabs.com/generate_big", { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json" | |
}, | |
body: body | |
}) | |
.then(res => { | |
return res.json(); | |
}) | |
.then(data => { | |
console.log(data); | |
const date = new Date() | |
.toLocaleString("ja-JP") | |
.replace(/:|\//g, "") | |
.replace(" ", "_"); | |
const a = document.createElement("a"); | |
a.download = `w_${date}_${seeds.toString()}.png`; | |
a.href = | |
"data:image/png;base64," + | |
encodeURIComponent(data.girl); | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); | |
}); | |
}; | |
for (const girl of girls) await awaitGet(girl); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment