QuestCompleter Stuff

Remove Quest Completer CSS

Fix Lint
This commit is contained in:
thororen1234 2024-12-01 05:51:37 -05:00
parent 240771a464
commit 193c65b182
3 changed files with 72 additions and 53 deletions

View file

@ -110,6 +110,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
- PolishWording (Grammar) by Samwich - PolishWording (Grammar) by Samwich
- PlatformSpoofer by Drag - PlatformSpoofer by Drag
- PurgeMessages by bhop & nyx - PurgeMessages by bhop & nyx
- QuestCompleter by HappyEnderman, SerStars, maintained by thororen
- QuestionMarkReplacement by nyx - QuestionMarkReplacement by nyx
- Quoter by Samwich - Quoter by Samwich
- RemixMe by kvba - RemixMe by kvba
@ -163,7 +164,6 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
### Discord Desktop Only ### Discord Desktop Only
- MediaDownloader by Colorman - MediaDownloader by Colorman
- QuestCompleter by HappyEnderman, SerStars, maintained by thororen
- StatusWhilePlaying by thororen - StatusWhilePlaying by thororen
### Equicord Devbuilds Only ### Equicord Devbuilds Only

View file

@ -1,12 +0,0 @@
.quest-warning {
font-size: 16px !important;
background-color: rgb(240 71 71 / 10%) !important;
color: rgb(240 71 71) !important;
border: 1px solid rgb(240 71 71 / 60%) !important;
border-radius: 5px !important;
font-weight: 500;
padding: 6px 10px;
text-align: center;
margin-top: 10px;
font-style: bold;
}

View file

@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import "./style.css";
import { showNotification } from "@api/Notifications"; import { showNotification } from "@api/Notifications";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs, EquicordDevs } from "@utils/constants"; import { Devs, EquicordDevs } from "@utils/constants";
@ -25,7 +23,7 @@ import { getTheme, Theme } from "@utils/discord";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findByProps, findExportedComponentLazy } from "@webpack"; import { findByProps, findExportedComponentLazy } from "@webpack";
import { Button, FluxDispatcher, Forms, RestAPI, Tooltip, UserStore } from "@webpack/common"; import { Button, FluxDispatcher, RestAPI, Tooltip, UserStore } from "@webpack/common";
const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider"); const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider");
const isApp = navigator.userAgent.includes("Electron/"); const isApp = navigator.userAgent.includes("Electron/");
@ -64,13 +62,12 @@ function ToolBarHeader() {
async function openCompleteQuestUI() { async function openCompleteQuestUI() {
const ApplicationStreamingStore = findByProps("getStreamerActiveStreamMetadata"); const ApplicationStreamingStore = findByProps("getStreamerActiveStreamMetadata");
const RunningGameStore = findByProps("getRunningGames"); const RunningGameStore = findByProps("getRunningGames");
const ExperimentStore = findByProps("getGuildExperiments");
const QuestsStore = findByProps("getQuest"); 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()); 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 (!quest) { if (!quest) {
showNotification({ showNotification({
title: "Quests Completer", title: "Quest Completer",
body: "No Quests To Complete", body: "No Quests To Complete",
}); });
} else { } else {
@ -79,27 +76,52 @@ async function openCompleteQuestUI() {
? "light" ? "light"
: "dark"; : "dark";
let applicationId, applicationName, secondsNeeded, secondsDone, canPlay, icon, questId; const applicationId = quest.config.application.id;
if (quest.config.configVersion === 1) { const applicationName = quest.config.application.name;
questId = quest.id; const taskName = ["WATCH_VIDEO", "PLAY_ON_DESKTOP", "STREAM_ON_DESKTOP"].find(x => quest.config.taskConfig.tasks[x] != null);
applicationId = quest.config.applicationId; // @ts-ignore
applicationName = quest.config.applicationName; const secondsNeeded = quest.config.taskConfig.tasks[taskName].target;
secondsNeeded = quest.config.streamDurationRequirementMinutes * 60; // @ts-ignore
secondsDone = quest.userStatus?.streamProgressSeconds ?? 0; const secondsDone = quest.userStatus?.progress?.[taskName]?.value ?? 0;
icon = `https://cdn.discordapp.com/assets/quests/${questId}/${theme}/${quest.config.assets.gameTile}`; const icon = `https://cdn.discordapp.com/assets/quests/${quest.id}/${theme}/${quest.config.assets.gameTile}`;
canPlay = quest.config.variants.includes(2); if (taskName === "WATCH_VIDEO") {
} else if (quest.config.configVersion === 2) { const tolerance = 2, speed = 10;
questId = quest.id; const diff = Math.floor((Date.now() - new Date(quest.userStatus.enrolledAt).getTime()) / 1000);
applicationId = quest.config.application.id; const startingPoint = Math.min(Math.max(Math.ceil(secondsDone), diff), secondsNeeded);
applicationName = quest.config.application.name; const fn = async () => {
icon = `https://cdn.discordapp.com/assets/quests/${questId}/${theme}/${quest.config.assets.gameTile}`; for (let i = startingPoint; i <= secondsNeeded; i += speed) {
canPlay = ExperimentStore.getUserExperimentBucket("2024-04_quest_playtime_task") > 0 && quest.config.taskConfig.tasks.PLAY_ON_DESKTOP; try {
const taskName = canPlay ? "PLAY_ON_DESKTOP" : "STREAM_ON_DESKTOP"; await RestAPI.post({ url: `/quests/${quest.id}/video-progress`, body: { timestamp: Math.min(secondsNeeded, i + Math.random()) } });
secondsNeeded = quest.config.taskConfig.tasks[taskName]?.target; } catch (ex) {
secondsDone = quest.userStatus?.progress?.[taskName]?.value ?? 0; console.log("Failed to send increment of", i, ex);
} }
if (canPlay) { await new Promise(resolve => setTimeout(resolve, tolerance * 1000));
await RestAPI.get({ url: `/applications/public?application_ids=${applicationId}` }).then(res => { }
if ((secondsNeeded - secondsDone) % speed !== 0) {
await RestAPI.post({ url: `/quests/${quest.id}/video-progress`, body: { timestamp: secondsNeeded } });
showNotification({
title: `${applicationName} - Quest Completer`,
body: "Quest Completed.",
icon: icon,
});
}
};
fn();
showNotification({
title: `${applicationName} - Quest Completer`,
body: `Wait for ${Math.ceil((secondsNeeded - startingPoint) / speed * tolerance)} more seconds.`,
icon: icon,
});
console.log(`Spoofing video for ${applicationName}.`);
} else if (taskName === "PLAY_ON_DESKTOP") {
if (!isApp) {
showNotification({
title: `${applicationName} - Quest Completer`,
body: `${applicationName}'s quest requires the desktop app.`,
icon: icon,
});
}
RestAPI.get({ url: `/applications/public?application_ids=${applicationId}` }).then(res => {
const appData = res.body[0]; const appData = res.body[0];
const exeName = appData.executables.find(x => x.os === "win32").name.replace(">", ""); const exeName = appData.executables.find(x => x.os === "win32").name.replace(">", "");
@ -123,14 +145,14 @@ async function openCompleteQuestUI() {
const fn = data => { const fn = data => {
const progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.PLAY_ON_DESKTOP.value); const progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.PLAY_ON_DESKTOP.value);
showNotification({ showNotification({
title: `${applicationName} - Quests Completer`, title: `${applicationName} - Quest Completer`,
body: `Current progress: ${progress}/${secondsNeeded} seconds.`, body: `Current progress: ${progress}/${secondsNeeded} seconds.`,
icon: icon, icon: icon,
}); });
if (progress >= secondsNeeded) { if (progress >= secondsNeeded) {
showNotification({ showNotification({
title: `${applicationName} - Quests Completer`, title: `${applicationName} - Quest Completer`,
body: "Quest Completed.", body: "Quest Completed.",
icon: icon, icon: icon,
}); });
@ -144,16 +166,29 @@ async function openCompleteQuestUI() {
} }
}; };
FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn); FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn);
console.log(`Spoofed your game to ${applicationName}.`);
}); });
} else { } else if (taskName === "STREAM_ON_DESKTOP") {
const stream = ApplicationStreamingStore.getAnyStreamForUser(UserStore.getCurrentUser()?.id); if (!isApp) {
if (!stream) {
showNotification({ showNotification({
title: "You're not streaming - Quests Completer", title: `${applicationName} - Quest Completer`,
body: `${applicationName} requires you to be streaming.`, body: `${applicationName}'s quest requires the desktop app.`,
icon: icon, icon: icon,
}); });
} }
const stream = ApplicationStreamingStore.getAnyStreamForUser(UserStore.getCurrentUser()?.id);
if (!stream) {
showNotification({
title: "You're not streaming - Quest Completer",
body: `${applicationName} requires you to be streaming.\nPlease stream any window in vc.`,
icon: icon,
});
}
showNotification({
title: `${applicationName} - Quest Completer`,
body: "Remember that you need at least 1 other person to be in the vc!",
icon: icon,
});
const realFunc = ApplicationStreamingStore.getStreamerActiveStreamMetadata; const realFunc = ApplicationStreamingStore.getStreamerActiveStreamMetadata;
ApplicationStreamingStore.getStreamerActiveStreamMetadata = () => ({ ApplicationStreamingStore.getStreamerActiveStreamMetadata = () => ({
id: applicationId, id: applicationId,
@ -164,14 +199,14 @@ async function openCompleteQuestUI() {
const fn = data => { const fn = data => {
const progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.STREAM_ON_DESKTOP.value); const progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.STREAM_ON_DESKTOP.value);
showNotification({ showNotification({
title: `${applicationName} - Quests Completer`, title: `${applicationName} - Quest Completer`,
body: `Current progress: ${progress}/${secondsNeeded} seconds.`, body: `Current progress: ${progress}/${secondsNeeded} seconds.`,
icon: icon, icon: icon,
}); });
if (progress >= secondsNeeded) { if (progress >= secondsNeeded) {
showNotification({ showNotification({
title: `${applicationName} - Quests Completer`, title: `${applicationName} - Quest Completer`,
body: "Quest Completed.", body: "Quest Completed.",
icon: icon, icon: icon,
}); });
@ -181,6 +216,7 @@ async function openCompleteQuestUI() {
} }
}; };
FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn); FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn);
console.log(`Spoofed your stream to ${applicationName}.`);
} }
return; return;
} }
@ -190,11 +226,6 @@ 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.HappyEnderman, EquicordDevs.SerStars, EquicordDevs.thororen], authors: [Devs.HappyEnderman, EquicordDevs.SerStars, EquicordDevs.thororen],
settingsAboutComponent: () => <>
<Forms.FormText className="remixme-warning">
We can't guarantee this plugin won't get you warned or banned.
</Forms.FormText>
</>,
patches: [ patches: [
{ {
find: "\"invite-button\"", find: "\"invite-button\"",