From 7d6964a325382b91661c821ce4ac0efb14bed1bd Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Sun, 10 Nov 2024 18:17:54 +1300 Subject: [PATCH] Fix downloading event ICS files --- src/renderer/patches/downloadEventFile.tsx | 32 ++++++++++++++++++++++ src/renderer/patches/index.ts | 1 + 2 files changed, 33 insertions(+) create mode 100644 src/renderer/patches/downloadEventFile.tsx diff --git a/src/renderer/patches/downloadEventFile.tsx b/src/renderer/patches/downloadEventFile.tsx new file mode 100644 index 00000000..f473e40f --- /dev/null +++ b/src/renderer/patches/downloadEventFile.tsx @@ -0,0 +1,32 @@ +/* + * SPDX-License-Identifier: GPL-3.0 + * Vesktop, a desktop app aiming to give you a snappier Discord Experience + * Copyright (c) 2024 Vendicated and Vencord contributors + */ + +import { addPatch } from "./shared"; + +addPatch({ + patches: [ + { + find: "discord-event.ics", + replacement: { + match: /("discord-event\.ics".{0,10}?)window\.open/, + replace: "$1$self.downloadEvent" + } + } + ], + + downloadEvent(uri: string) { + const a = document.createElement("a"); + a.href = uri; + a.download = "discord-event.ics"; + + document.body.appendChild(a); + a.click(); + setImmediate(() => { + URL.revokeObjectURL(a.href); + document.body.removeChild(a); + }); + } +}); diff --git a/src/renderer/patches/index.ts b/src/renderer/patches/index.ts index aabff3e0..c9384a25 100644 --- a/src/renderer/patches/index.ts +++ b/src/renderer/patches/index.ts @@ -5,6 +5,7 @@ */ // TODO: Possibly auto generate glob if we have more patches in the future +import "./downloadEventFile"; import "./enableNotificationsByDefault"; import "./platformClass"; import "./hideSwitchDevice";