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