Last active
December 26, 2025 03:14
-
-
Save mynamebvh/418349230f66df497fc2f719c11c9e1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async () => { | |
| // 1. Initialize helpers and extract Discord internal modules | |
| const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | |
| delete window.$; | |
| let wpRequire = webpackChunkdiscord_app.push([[Symbol()], {}, (r) => r]); | |
| webpackChunkdiscord_app.pop(); | |
| const modules = Object.values(wpRequire.c); | |
| // Locate necessary Discord stores and dispatchers | |
| let RunningGameStore = modules.find(x => x?.exports?.ZP?.getRunningGames).exports.ZP; | |
| let QuestsStore = modules.find(x => x?.exports?.Z?.__proto__?.getQuest).exports.Z; | |
| let FluxDispatcher = modules.find(x => x?.exports?.Z?.__proto__?.flushWaitQueue).exports.Z; | |
| let api = modules.find(x => x?.exports?.tn?.get).exports.tn; | |
| // Function to enroll in a specific Quest | |
| async function enrollInQuest(questId) { | |
| try { | |
| const res = await api.post({ | |
| url: `/quests/${questId}/enroll`, | |
| body: { location: "store", source: "quest_page" }, | |
| }); | |
| return res.status === 200; | |
| } catch (err) { | |
| console.error(`Error enrolling in quest ${questId}:`, err); | |
| return false; | |
| } | |
| } | |
| // Function to simulate game playtime | |
| async function completeGameQuest(quest) { | |
| const pid = Math.floor(Math.random() * 30000) + 1000; | |
| const applicationId = quest.config.application.id; | |
| const applicationName = quest.config.application.name; | |
| const taskConfig = quest.config.taskConfig ?? quest.config.taskConfigV2; | |
| const taskName = "PLAY_ON_DESKTOP"; | |
| const secondsNeeded = taskConfig.tasks[taskName].target; | |
| let secondsDone = quest.userStatus?.progress?.[taskName]?.value ?? 0; | |
| console.log(`--- STARTING QUEST: ${quest.config.messages.questName} ---`); | |
| console.log(`Target: ${secondsNeeded}s | Current: ${secondsDone}s`); | |
| // Create a fake game object to spoof Discord's detection | |
| const fakeGame = { | |
| id: applicationId, | |
| name: applicationName, | |
| start: Date.now(), | |
| pid: pid, | |
| exeName: "FakeGame.exe", | |
| isLauncher: false | |
| }; | |
| // Inject the fake game into Discord's RunningGameStore | |
| const realGetRunningGames = RunningGameStore.getRunningGames; | |
| RunningGameStore.getRunningGames = () => [fakeGame]; | |
| // Trigger the internal dispatcher to notify Discord that a game has started | |
| FluxDispatcher.dispatch({ | |
| type: "RUNNING_GAMES_CHANGE", | |
| removed: [], | |
| added: [fakeGame], | |
| games: [fakeGame], | |
| }); | |
| // Progress reporting loop (every 30 seconds) | |
| while (secondsDone < secondsNeeded) { | |
| await sleep(30000); // Wait for 30 seconds | |
| secondsDone = Math.min(secondsDone + 30, secondsNeeded); | |
| try { | |
| const res = await api.post({ | |
| url: `/quests/${quest.id}/progress`, | |
| body: { progress: { [taskName]: secondsDone } }, | |
| }); | |
| console.log(`Progress: ${secondsDone}/${secondsNeeded}s (${applicationName})`); | |
| // Stop if the server marks the quest as completed | |
| if (res.body.completed_at) break; | |
| } catch (e) { | |
| console.error("Error sending progress heartbeat:", e); | |
| } | |
| } | |
| console.log(`✅ SUCCESS: Quest "${quest.config.messages.questName}" COMPLETED!`); | |
| // Restore original Discord functions and clean up the fake game state | |
| RunningGameStore.getRunningGames = realGetRunningGames; | |
| FluxDispatcher.dispatch({ | |
| type: "RUNNING_GAMES_CHANGE", | |
| removed: [fakeGame], | |
| added: [], | |
| games: [], | |
| }); | |
| } | |
| // --- MAIN EXECUTION LOGIC --- | |
| async function runSingleGameQuest() { | |
| // Get all active (non-expired) quests | |
| const allQuests = [...QuestsStore.quests.values()].filter( | |
| (q) => new Date(q.config.expiresAt).getTime() > Date.now() | |
| ); | |
| // Find the first "PLAY_ON_DESKTOP" quest that is not yet completed | |
| const targetQuest = allQuests.find(q => { | |
| const taskConfig = q.config.taskConfig ?? q.config.taskConfigV2; | |
| return taskConfig?.tasks["PLAY_ON_DESKTOP"] != null && !q.userStatus?.completedAt; | |
| }); | |
| if (!targetQuest) { | |
| return console.log("❌ No incomplete Game Quests found."); | |
| } | |
| // Auto-enroll if the user hasn't accepted the quest yet | |
| if (!targetQuest.userStatus || !targetQuest.userStatus.enrolledAt) { | |
| console.log(`Enrolling in quest: ${targetQuest.config.messages.questName}...`); | |
| await enrollInQuest(targetQuest.id); | |
| await sleep(2000); // Small delay to ensure enrollment is processed | |
| } | |
| // Start the completion process for the found quest | |
| await completeGameQuest(targetQuest); | |
| } | |
| // Run the script | |
| runSingleGameQuest(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment