Skip to content

Instantly share code, notes, and snippets.

@Dobby233Liu
Last active June 11, 2022 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dobby233Liu/1e61dccc9f67156157bcf15387319566 to your computer and use it in GitHub Desktop.
Save Dobby233Liu/1e61dccc9f67156157bcf15387319566 to your computer and use it in GitHub Desktop.
getIllustUrl. it's useless, maybe
/**
* getIllustUrl - DevTools console script to get pixiv illust original image... in it's page
* Written by GitHub@Dobby233Liu
* Public Domain, take the below function is free too.
* note: this script will output to console. output may be:
* url and data (success), boolean and error message, including "GET xxx 4xx/5xx" (api error), or "uncaught error" (something gone wrong)
* offical version always at: https://gist.github.com/Dobby233Liu/1e61dccc9f67156157bcf15387319566
**/
getIllustUrl = (illustID, cb, httpErrorCB) => {
fetch("https://www.pixiv.net/ajax/illust/" + illustID)
.then(async (r) => {
return {
err: !r.ok
, j: await r.json()
, stText: r['statusText'] || toString(r['status'])
}
})
.then((j) => {
if (!j.err && !j.j.error) {
cb(j.j.body.urls.original, j.j.body)
} else {
httpErrorCB(j.err || j.j.error, (j.j.error ? j.j.message : j.stText))
}
})
}
getIllustUrl(location.pathname.replace(/\/artworks\//ig, "").replace(/\//g, ""), console.log, console.log)
/**
* anti 403 way:
* replace fore getIllustUrl(...) call code with below code: (no "*" character)
* getIllustUrl(location.pathname.replace(/\/artworks\//ig, "").replace(/\//g, ""), (result,body)=>{var ele=document.createElement("img"),b=(ele.src=result),c=(document.body.appendChild(ele))}, console.log)
* then you can dl the image at the most bottom of the page.
* sorry for the confusing code.
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment