From 7b50fa5a47c222cdbb9802af89544f743117d008 Mon Sep 17 00:00:00 2001 From: coomdev Date: Sun, 16 Jan 2022 17:22:24 +0100 Subject: [PATCH] Add fallback host when config is undefined --- main.meta.js | 2 +- main.user.js | 4 ++-- src/utils.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.meta.js b/main.meta.js index 3aaf646..b5e0cb8 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.144 +// @version 0.145 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index a049c90..244883e 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.144 +// @version 0.145 // @description uhh // @author You // @match https://boards.4channel.org/* @@ -11643,7 +11643,7 @@ let total = 0; fireNotification("info", `Uploading ${injs.length} files...`); return await Promise.all(injs.map(async (inj) => { - const ret = await filehosts[csettings2.fhost].uploadFile(await buildPeeFile(inj)); + const ret = await filehosts[csettings2.fhost || 0].uploadFile(await buildPeeFile(inj)); fireNotification("info", `Uploaded files [${++total}/${injs.length}] ${ret}`); return ret; })); diff --git a/src/utils.ts b/src/utils.ts index 61b1789..a611dc8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -182,7 +182,7 @@ export const uploadFiles = async (injs: File[]) => { let total = 0; fireNotification('info', `Uploading ${injs.length} files...`); return await Promise.all(injs.map(async inj => { - const ret = await filehosts[csettings.fhost].uploadFile(await buildPeeFile(inj)); + const ret = await filehosts[csettings.fhost || 0].uploadFile(await buildPeeFile(inj)); fireNotification('info', `Uploaded files [${++total}/${injs.length}] ${ret}`); return ret; }));