Last active
June 11, 2022 03:57
-
-
Save Dobby233Liu/1e61dccc9f67156157bcf15387319566 to your computer and use it in GitHub Desktop.
getIllustUrl. it's useless, maybe
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
/** | |
* 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