diff --git a/Plugins/ImageUtilities/ImageUtilities.plugin.js b/Plugins/ImageUtilities/ImageUtilities.plugin.js index 12759e3e07..b40d8899e4 100644 --- a/Plugins/ImageUtilities/ImageUtilities.plugin.js +++ b/Plugins/ImageUtilities/ImageUtilities.plugin.js @@ -2,7 +2,7 @@ * @name ImageUtilities * @author DevilBro * @authorId 278543574059057154 - * @version 4.4.6 + * @version 4.4.7 * @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.) * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,12 +17,12 @@ module.exports = (_ => { "info": { "name": "ImageUtilities", "author": "DevilBro", - "version": "4.4.6", + "version": "4.4.7", "description": "Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.)" }, "changeLog": { "fixed": { - "Double Zoom Lens": "No longer gets the zoom lens stuck on right click" + "Invalid Images (Instagram)": "Fixed Issue where some Images could not be downloaded" } } }; @@ -624,7 +624,7 @@ module.exports = (_ => { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: BDFDB.LanguageUtils.LanguageStrings.OPEN_LINK, id: BDFDB.ContextMenuUtils.createItemId(this.name, "open-link"), - action: _ => {BDFDB.DiscordUtils.openLink(urls.original);} + action: _ => BDFDB.DiscordUtils.openLink(urls.original) }), BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: BDFDB.LanguageUtils.LanguageStrings.COPY_LINK, @@ -686,16 +686,12 @@ module.exports = (_ => { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.context_saveas.replace("{{var0}}", type), id: BDFDB.ContextMenuUtils.createItemId(this.name, "download-file-as"), - action: _ => { - this.downloadFileAs(urls.file); - }, + action: _ => this.downloadFileAs(urls.file, urls.src), children: locations.length && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i), label: name, - action: _ => { - this.downloadFile(urls.file, ownLocations[name].location); - } + action: _ => this.downloadFile(urls.file, ownLocations[name].location, urls.src) })) }) }), @@ -1030,11 +1026,14 @@ module.exports = (_ => { }; } - downloadFile (url, path) { + downloadFile (url, path, fallbackUrl) { url = url.startsWith("/assets") ? (window.location.origin + url) : url; BDFDB.LibraryRequires.request(url, {encoding: null}, (error, response, body) => { let type = this.isValid(url, "video") ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; - if (error) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", path), {type: "danger"}); + if (error || response.statusCode != 200) { + if (fallbackUrl) this.downloadFile(fallbackUrl, path); + else BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", ""), {type: "danger"}); + } else { BDFDB.LibraryRequires.fs.writeFile(this.getFileName(path, url.split("/").pop().split(".").slice(0, -1).join("."), response.headers["content-type"].split("/").pop().split("+")[0], 0), body, error => { if (error) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", path), {type: "danger"}); @@ -1044,15 +1043,22 @@ module.exports = (_ => { }); } - downloadFileAs (url) { + downloadFileAs (url, fallbackUrl) { url = url.startsWith("/assets") ? (window.location.origin + url) : url; BDFDB.LibraryRequires.request(url, {encoding: null}, (error, response, body) => { - let hrefURL = window.URL.createObjectURL(new Blob([body])); - let tempLink = document.createElement("a"); - tempLink.href = hrefURL; - tempLink.download = `${url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown"}.${response.headers["content-type"].split("/").pop().split("+")[0]}`; - tempLink.click(); - window.URL.revokeObjectURL(hrefURL); + let type = this.isValid(url, "video") ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; + if (error || response.statusCode != 200) { + if (fallbackUrl) this.downloadFileAs(fallbackUrl); + else BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", ""), {type: "danger"}); + } + else { + let hrefURL = window.URL.createObjectURL(new Blob([body])); + let tempLink = document.createElement("a"); + tempLink.href = hrefURL; + tempLink.download = `${url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown"}.${response.headers["content-type"].split("/").pop().split("+")[0]}`; + tempLink.click(); + window.URL.revokeObjectURL(hrefURL); + } }); } @@ -1138,7 +1144,7 @@ module.exports = (_ => { createImageWrapper (instance, imgRef, type, svgIcon) { return BDFDB.ReactUtils.createElement("div", { className: BDFDB.disCNS._imageutilitiessibling + BDFDB.disCN[`_imageutilities${type}`], - onClick: _ => {this.switchImages(instance, type);}, + onClick: _ => this.switchImages(instance, type), children: [ imgRef, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { diff --git a/Plugins/StaffTag/StaffTag.plugin.js b/Plugins/StaffTag/StaffTag.plugin.js index cfc14f8dbf..cf9afaae60 100644 --- a/Plugins/StaffTag/StaffTag.plugin.js +++ b/Plugins/StaffTag/StaffTag.plugin.js @@ -431,7 +431,7 @@ module.exports = (_ => { case "bg": // Bulgarian return { management: "Управление", - creator: "{{var0}} създател" + creator: "Cъздател {{var0}}" }; case "cs": // Czech return { @@ -531,7 +531,7 @@ module.exports = (_ => { case "ru": // Russian return { management: "Управление", - creator: "{{var0}} создатель" + creator: "Cоздатель {{var0}}" }; case "sv": // Swedish return {