This commit is contained in:
thororen1234 2025-08-29 17:17:25 -04:00
commit 1601db0339
No known key found for this signature in database
2 changed files with 6 additions and 23 deletions

View file

@ -91,23 +91,13 @@ export default definePlugin({
replacement: [
{
// Make use of the download function.
match: /(let{item:\i}=(\i).{0,450}?)let \i=(await \i.\i.saveImage\(\i,\i.contentType,\i.\i\)).{0,110}?&&/,
match: /(let{item:\i}=(\i).{0,450}?)(\i\(!0\);try{.{0,400}?finally{\i\(!1\)})/,
replace: "$1await $self.handleExpandedModalDownloadButtonClicked($2,async()=>{$3});",
},
{
// Disable default success toast.
match: /\(\(0,.{0,85}?ToastType.SUCCESS\)\)\)/,
replace: "",
},
{
// Disable default failure toast.
match: /(\(0,.{0,85}?ToastType.FAILURE\)\))/,
replace: "",
},
{
// Prevent videos from opening in browser.
match: /(let{item:\i}=\i.{0,350}?)(SAVE_MEDIA_PRESSED\)).{0,100}?(\i\(!0\);)/,
replace: "$1$2,true){$3"
match: /(let{item:\i}=\i.{0,350}?)(SAVE_MEDIA_PRESSED\)).{0,100}?type\){/,
replace: "$1$2,true){"
}
],
}

View file

@ -677,7 +677,7 @@ export async function handleHoverDownloadButtonClicked(props: HoverDownloadProps
if (!originalItem) {
// Fallback to default behavior.
DownloadifyLogger.info(`[${getFormattedNow()}] [UNRECOGNIZED HOVER DOWNLOAD ITEM]`, props.item);
displayStatus && showToast("File Opened in Browser", Toasts.Type.MESSAGE, { duration: statusDuration * 1000 });
displayStatus && showToast("Unknown Media Item. Falling Back to Default Behavior", Toasts.Type.MESSAGE, { duration: statusDuration * 1250 });
window.open(downloadUrl, "_blank");
} else {
contentType ??= (await DownloadifyNative.queryURL(downloadUrl) || "");
@ -700,15 +700,8 @@ export async function handleExpandedModalDownloadButtonClicked(props: ExpandedMo
if (!url && !original) {
// Fallback to default behavior.
DownloadifyLogger.info(`[${getFormattedNow()}] [UNRECOGNIZED EXPANDED MODAL DOWNLOAD ITEM]`, props.item);
displayStatus && showToast("Download Started", Toasts.Type.MESSAGE, { duration: statusDuration * 1000 });
try {
await fallback();
displayStatus && showToast("Download Success", Toasts.Type.SUCCESS, { duration: statusDuration * 1000 });
} catch (error) {
DownloadifyLogger.info(`[${getFormattedNow()}] [FALLBACK DOWNLOAD FAILED]`, error);
displayStatus && showToast("Download Failed", Toasts.Type.FAILURE, { duration: statusDuration * 1000 });
}
displayStatus && showToast("Unknown Media Item. Falling Back to Default Behavior", Toasts.Type.MESSAGE, { duration: statusDuration * 1250 });
await fallback();
} else {
contentType ??= (await DownloadifyNative.queryURL(url) || "");
let aliasBasename = sourceMetadata?.identifier.title ?? null;