[Feature] Added not found status in waifu.js (#478)

This commit is contained in:
end-4
2024-05-05 00:40:46 +07:00
committed by GitHub
@@ -127,6 +127,7 @@ const WaifuImage = (taglist) => {
'download': ImageState('downloading', 'Downloading image'),
'done': ImageState('done', 'Finished!'),
'error': ImageState('error', 'Error'),
'notfound': ImageState('error', 'Not found!'),
},
});
const downloadIndicator = MarginRevealer({
@@ -204,6 +205,10 @@ const WaifuImage = (taglist) => {
thisBlock.attribute.imageData = imageData;
const { status, signature, url, extension, source, dominant_color, is_nsfw, width, height, tags } = thisBlock.attribute.imageData;
thisBlock.attribute.isNsfw = is_nsfw;
if (status == 404) {
downloadState.shown = 'notfound';
return;
}
if (status != 200) {
downloadState.shown = 'error';
return;