forked from OpenNeo/impress-2020
Compare commits
No commits in common. "always-use-@" and "main" have entirely different histories.
always-use
...
main
1 changed files with 7 additions and 6 deletions
|
|
@ -33,11 +33,13 @@ export async function loadCustomPetData(petName) {
|
|||
// prepending "@", which is a special code that can *also* be used in the
|
||||
// CustomPetService in place of name, to get a pet's appearance from its image
|
||||
// hash.
|
||||
const imageHash = await loadImageHashFromPetName(petName);
|
||||
console.debug(
|
||||
`[loadCustomPetData] Converted pet name ${petName} to @${imageHash}`,
|
||||
);
|
||||
petName = "@" + imageHash;
|
||||
if (petName.match(/^[0-9]/)) {
|
||||
const imageHash = await loadImageHashFromPetName(petName);
|
||||
console.debug(
|
||||
`[loadCustomPetData] Converted pet name ${petName} to @${imageHash}`,
|
||||
);
|
||||
petName = "@" + imageHash;
|
||||
}
|
||||
|
||||
try {
|
||||
return neopetsAmfphpCall("CustomPetService.getViewerData", [petName]);
|
||||
|
|
@ -58,7 +60,6 @@ const PETS_CP_URL_PATTERN =
|
|||
/https?:\/\/pets\.neopets\.com\/cp\/([a-z0-9]+)\/[0-9]+\/[0-9]+\.png/;
|
||||
async function loadImageHashFromPetName(petName) {
|
||||
const res = await fetch(`https://pets.neopets.com/cpn/${petName}/1/1.png`, {
|
||||
method: "HEAD",
|
||||
redirect: "manual",
|
||||
});
|
||||
if (res.status !== 302) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue