mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-29 16:34:25 -04:00
QuestCompleter: NavBar Option
This commit is contained in:
parent
ecb8fa1b96
commit
89be4cd54b
1 changed files with 55 additions and 2 deletions
|
@ -20,13 +20,33 @@ import "@equicordplugins/_misc/styles.css";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { ErrorBoundary } from "@components/index";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getTheme, Theme } from "@utils/discord";
|
import { getTheme, Theme } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByProps, findComponentByCodeLazy } from "@webpack";
|
import { findByProps, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Button, ChannelStore, FluxDispatcher, GuildChannelStore, NavigationRouter, RestAPI, Tooltip, UserStore } from "@webpack/common";
|
import { Button, ChannelStore, FluxDispatcher, GuildChannelStore, NavigationRouter, RestAPI, Tooltip, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
const QuestIcon = findComponentByCodeLazy("10.47a.76.76");
|
const QuestIcon = findComponentByCodeLazy("10.47a.76.76");
|
||||||
|
const HeaderBarIcon = findComponentByCodeLazy(".HEADER_BAR_BADGE_TOP:", '.iconBadge,"top"');
|
||||||
|
|
||||||
|
|
||||||
|
function ToolBarHeader() {
|
||||||
|
return (
|
||||||
|
<ErrorBoundary noop={true}>
|
||||||
|
<HeaderBarIcon
|
||||||
|
tooltip="Complete Quest"
|
||||||
|
position="bottom"
|
||||||
|
className="vc-quest-completer"
|
||||||
|
icon={QuestIcon}
|
||||||
|
onClick={openCompleteQuestUI}
|
||||||
|
>
|
||||||
|
</HeaderBarIcon>
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function openCompleteQuestUI() {
|
async function openCompleteQuestUI() {
|
||||||
const ApplicationStreamingStore = findByProps("getStreamerActiveStreamMetadata");
|
const ApplicationStreamingStore = findByProps("getStreamerActiveStreamMetadata");
|
||||||
|
@ -213,17 +233,35 @@ async function openCompleteQuestUI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
useNavBar: {
|
||||||
|
description: "Move quest button down to the server nav bar",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "QuestCompleter",
|
name: "QuestCompleter",
|
||||||
description: "A plugin to complete quests without having the game installed.",
|
description: "A plugin to complete quests without having the game installed.",
|
||||||
authors: [Devs.amia],
|
authors: [Devs.amia],
|
||||||
|
settings,
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "AppTitleBar",
|
find: "AppTitleBar",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=trailing:.{0,70}\(\i\.Fragment,{children:\[)/,
|
match: /(?<=trailing:.{0,70}\(\i\.Fragment,{children:\[)/,
|
||||||
replace: "$self.renderQuestButton(),"
|
replace: "$self.renderQuestButton(),"
|
||||||
}
|
},
|
||||||
|
predicate: () => !settings.store.useNavBar
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "toolbar:function",
|
||||||
|
replacement: {
|
||||||
|
match: /(function \i\(\i\){)(.{1,200}toolbar.{1,200}mobileToolbar)/,
|
||||||
|
replace: "$1$self.toolbarAction(arguments[0]);$2"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.useNavBar
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
renderQuestButton() {
|
renderQuestButton() {
|
||||||
|
@ -242,4 +280,19 @@ export default definePlugin({
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
toolbarAction(e) {
|
||||||
|
if (Array.isArray(e.toolbar))
|
||||||
|
return e.toolbar.push(
|
||||||
|
<ErrorBoundary noop={true}>
|
||||||
|
<ToolBarHeader />
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
|
||||||
|
e.toolbar = [
|
||||||
|
<ErrorBoundary noop={true} key={"QuestCompleter"}>
|
||||||
|
<ToolBarHeader />
|
||||||
|
</ErrorBoundary>,
|
||||||
|
e.toolbar,
|
||||||
|
];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue