Make QuestCompleter Patch Reasonable

This commit is contained in:
thororen1234 2024-10-29 02:30:38 -04:00
parent f2f7d3ad56
commit 6862e0a590
4 changed files with 25 additions and 103 deletions

View file

@ -196,7 +196,7 @@ function ExcludedPluginsList({ search }: { search: string; }) {
discordDesktop: "Discord Desktop app",
vencordDesktop: "Vesktop app",
equicordDesktop: "Equibop app",
web: "Vesktop app and the Web version of Discord",
web: "Vesktop & Equibop apps as well as the Web version of Discord",
dev: "Developer version of Equicord"
};

View file

@ -23,7 +23,7 @@ import { getTheme, Theme } from "@utils/discord";
import { classes } from "@utils/misc";
import definePlugin from "@utils/types";
import { findByProps, findExportedComponentLazy } from "@webpack";
import { Button, FluxDispatcher, RestAPI, Text, Tooltip, UserStore } from "@webpack/common";
import { Button, FluxDispatcher, RestAPI, Tooltip, UserStore } from "@webpack/common";
const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider");
const isApp = navigator.userAgent.includes("Electron/");
@ -66,12 +66,7 @@ async function openCompleteQuestUI() {
const QuestsStore = findByProps("getQuest");
const quest = [...QuestsStore.quests.values()].find(x => x.id !== "1248385850622869556" && x.userStatus?.enrolledAt && !x.userStatus?.completedAt && new Date(x.config.expiresAt).getTime() > Date.now());
if (!isApp) {
showNotification({
title: "Quests Completer",
body: "This no longer works in browser. Use the desktop app!",
});
} else if (!quest) {
if (!quest) {
showNotification({
title: "Quests Completer",
body: "No Quests To Complete",
@ -197,8 +192,8 @@ export default definePlugin({
{
find: "\"invite-button\"",
replacement: {
match: /(function .+?\(.+?\){let{inPopout:.+allowIdle.+?}=.+?\.\i\)\("popup"\),(.+?)=\[\];if\(.+?\){.+"chat-spacer"\)\)\),\(\d,.+?\.jsx\)\(.+?,{children:).+?}}/,
replace: "$1[$self.renderQuestButton(),...$2]})}}"
match: /(\i\.Fragment,{children:)(\i\i)/,
replace: "$1[$self.renderQuestButton(),...$2]"
}
},
{
@ -239,19 +234,5 @@ export default definePlugin({
</ErrorBoundary>,
e.toolbar,
];
},
settingsAboutComponent() {
return (<>
{
isApp ?
<Text variant="text-lg/bold">
The plugin should work properly because you are on the Desktop Client.
</Text>
:
<Text variant="text-lg/bold">
This plugin won't work because you are not on the Desktop Client.
</Text>
}
</>);
}
});

View file

@ -1,69 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { addContextMenuPatch, removeContextMenuPatch } from "@api/ContextMenu";
import { ScreenshareIcon } from "@components/Icons";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Menu, UploadHandler } from "@webpack/common";
const OptionClasses = findByPropsLazy("optionName", "optionIcon", "optionLabel");
let recoder: MediaRecorder;
export default definePlugin({
name: "ScreenRecorder",
description: "epic screen recorder lol",
authors: [Devs.AutumnVN],
contextMenus: {
"channel-attach": startRecording
}
});
function startRecording(children) {
children.push(
<Menu.MenuItem
id="start-recording"
label={
<div className={OptionClasses.optionLabel}>
<ScreenshareIcon className={OptionClasses.optionIcon} height={24} width={24} />
<div className={OptionClasses.optionName}>Start Recording</div>
</div>
}
action={async () => {
const stream = await navigator.mediaDevices.getDisplayMedia({ audio: true, video: { frameRate: { ideal: 60 } } });
recoder = new MediaRecorder(stream);
recoder.start();
removeContextMenuPatch("channel-attach", startRecording);
addContextMenuPatch("channel-attach", stopRecording);
}}
/>
);
}
function stopRecording(children, props) {
children.push(
<Menu.MenuItem
id="stop-recording"
label={
<div className={OptionClasses.optionLabel}>
<ScreenshareIcon className={OptionClasses.optionIcon} height={24} width={24} />
<div className={OptionClasses.optionName}>Stop Recording</div>
</div>
}
action={() => {
recoder.addEventListener("dataavailable", e => {
const file = new File([e.data], "watch if cute.webm", { type: "video/webm" });
UploadHandler.promptToUpload([file], props.channel, 0);
});
recoder.stop();
removeContextMenuPatch("channel-attach", stopRecording);
addContextMenuPatch("channel-attach", startRecording);
}}
/>
);
}