Advertisement
drculun

Complete Discord Quest

Sep 13th, 2024 (edited)
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. delete window.$;
  2. let wpRequire;
  3. window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
  4.  
  5. let ApplicationStreamingStore = Object.values(wpRequire.c).find(x => x?.exports?.Z?.getStreamerActiveStreamMetadata).exports.Z;
  6. let RunningGameStore = Object.values(wpRequire.c).find(x => x?.exports?.ZP?.getRunningGames).exports.ZP;
  7. let QuestsStore = Object.values(wpRequire.c).find(x => x?.exports?.Z?.getQuest).exports.Z;
  8. let ChannelStore = Object.values(wpRequire.c).find(x => x?.exports?.Z?.getAllThreadsForParent).exports.Z;
  9. let GuildChannelStore = Object.values(wpRequire.c).find(x => x?.exports?.ZP?.getSFWDefaultChannel).exports.ZP;
  10. let FluxDispatcher = Object.values(wpRequire.c).find(x => x?.exports?.Z?.flushWaitQueue).exports.Z;
  11. let api = Object.values(wpRequire.c).find(x => x?.exports?.tn?.get).exports.tn;
  12.  
  13. let quest = [...QuestsStore.quests.values()].find(x => x.id !== "1248385850622869556" && x.userStatus?.enrolledAt && !x.userStatus?.completedAt && new Date(x.config.expiresAt).getTime() > Date.now())
  14. let isApp = navigator.userAgent.includes("Electron/")
  15. if(!quest) {
  16.     console.log("You don't have any uncompleted quests!")
  17. } else {
  18.     const pid = Math.floor(Math.random() * 30000) + 1000
  19.    
  20.     const applicationId = quest.config.application.id
  21.     const applicationName = quest.config.application.name
  22.     const taskName = ["WATCH_VIDEO", "PLAY_ON_DESKTOP", "STREAM_ON_DESKTOP", "PLAY_ACTIVITY"].find(x => quest.config.taskConfig.tasks[x] != null)
  23.     const secondsNeeded = quest.config.taskConfig.tasks[taskName].target
  24.     const secondsDone = quest.userStatus?.progress?.[taskName]?.value ?? 0
  25.  
  26.     if(taskName === "WATCH_VIDEO") {
  27.         const tolerance = 2, speed = 10
  28.         const diff = Math.floor((Date.now() - new Date(quest.userStatus.enrolledAt).getTime())/1000)
  29.         const startingPoint = Math.min(Math.max(Math.ceil(secondsDone), diff), secondsNeeded)
  30.         let fn = async () => {
  31.             for(let i=startingPoint;i<=secondsNeeded;i+=speed) {
  32.                 try {
  33.                     await api.post({url: `/quests/${quest.id}/video-progress`, body: {timestamp: Math.min(secondsNeeded, i + Math.random())}})
  34.                 } catch(ex) {
  35.                     console.log("Failed to send increment of", i, ex.message)
  36.                 }
  37.                 await new Promise(resolve => setTimeout(resolve, tolerance * 1000))
  38.             }
  39.             if((secondsNeeded-secondsDone)%speed !== 0) {
  40.                 await api.post({url: `/quests/${quest.id}/video-progress`, body: {timestamp: secondsNeeded}})
  41.             }
  42.             console.log("Quest completed!")
  43.         }
  44.         fn()
  45.         console.log(`Spoofing video for ${applicationName}. Wait for ${Math.ceil((secondsNeeded - startingPoint)/speed*tolerance)} more seconds.`)
  46.     } else if(taskName === "PLAY_ON_DESKTOP") {
  47.         if(!isApp) {
  48.             console.log("This no longer works in browser for non-video quests. Use the desktop app to complete the", applicationName, "quest!")
  49.         }
  50.        
  51.         api.get({url: `/applications/public?application_ids=${applicationId}`}).then(res => {
  52.             const appData = res.body[0]
  53.             const exeName = appData.executables.find(x => x.os === "win32").name.replace(">","")
  54.            
  55.             const games = RunningGameStore.getRunningGames()
  56.             const fakeGame = {
  57.                 cmdLine: `C:\\Program Files\\${appData.name}\\${exeName}`,
  58.                 exeName,
  59.                 exePath: `c:/program files/${appData.name.toLowerCase()}/${exeName}`,
  60.                 hidden: false,
  61.                 isLauncher: false,
  62.                 id: applicationId,
  63.                 name: appData.name,
  64.                 pid: pid,
  65.                 pidPath: [pid],
  66.                 processName: appData.name,
  67.                 start: Date.now(),
  68.             }
  69.             games.push(fakeGame)
  70.             FluxDispatcher.dispatch({type: "RUNNING_GAMES_CHANGE", removed: [], added: [fakeGame], games: games})
  71.            
  72.             let fn = data => {
  73.                 let progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.PLAY_ON_DESKTOP.value)
  74.                 console.log(`Quest progress: ${progress}/${secondsNeeded}`)
  75.                
  76.                 if(progress >= secondsNeeded) {
  77.                     console.log("Quest completed!")
  78.                    
  79.                     const idx = games.indexOf(fakeGame)
  80.                     if(idx > -1) {
  81.                         games.splice(idx, 1)
  82.                         FluxDispatcher.dispatch({type: "RUNNING_GAMES_CHANGE", removed: [fakeGame], added: [], games: []})
  83.                     }
  84.                     FluxDispatcher.unsubscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
  85.                 }
  86.             }
  87.             FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
  88.            
  89.             console.log(`Spoofed your game to ${applicationName}. Wait for ${Math.ceil((secondsNeeded - secondsDone) / 60)} more minutes.`)
  90.         })
  91.     } else if(taskName === "STREAM_ON_DESKTOP") {
  92.         if(!isApp) {
  93.             console.log("This no longer works in browser for non-video quests. Use the desktop app to complete the", applicationName, "quest!")
  94.         }
  95.        
  96.         let realFunc = ApplicationStreamingStore.getStreamerActiveStreamMetadata
  97.         ApplicationStreamingStore.getStreamerActiveStreamMetadata = () => ({
  98.             id: applicationId,
  99.             pid,
  100.             sourceName: null
  101.         })
  102.        
  103.         let fn = data => {
  104.             let progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.STREAM_ON_DESKTOP.value)
  105.             console.log(`Quest progress: ${progress}/${secondsNeeded}`)
  106.            
  107.             if(progress >= secondsNeeded) {
  108.                 console.log("Quest completed!")
  109.                
  110.                 ApplicationStreamingStore.getStreamerActiveStreamMetadata = realFunc
  111.                 FluxDispatcher.unsubscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
  112.             }
  113.         }
  114.         FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
  115.        
  116.         console.log(`Spoofed your stream to ${applicationName}. Stream any window in vc for ${Math.ceil((secondsNeeded - secondsDone) / 60)} more minutes.`)
  117.         console.log("Remember that you need at least 1 other person to be in the vc!")
  118.     } else if(taskName === "PLAY_ACTIVITY") {
  119.         const channelId = ChannelStore.getSortedPrivateChannels()[0]?.id ?? Object.values(GuildChannelStore.getAllGuilds()).find(x => x != null && x.VOCAL.length > 0).VOCAL[0].channel.id
  120.         const streamKey = `call:${channelId}:1`
  121.        
  122.         let fn = async () => {
  123.             console.log("Completing quest", applicationName, "-", quest.config.messages.questName)
  124.            
  125.             while(true) {
  126.                 const res = await api.post({url: `/quests/${quest.id}/heartbeat`, body: {stream_key: streamKey, terminal: false}})
  127.                 const progress = res.body.progress.PLAY_ACTIVITY.value
  128.                 console.log(`Quest progress: ${progress}/${secondsNeeded}`)
  129.                
  130.                 await new Promise(resolve => setTimeout(resolve, 20 * 1000))
  131.                
  132.                 if(progress >= secondsNeeded) {
  133.                     await api.post({url: `/quests/${quest.id}/heartbeat`, body: {stream_key: streamKey, terminal: true}})
  134.                     break
  135.                 }
  136.             }
  137.            
  138.             console.log("Quest completed!")
  139.         }
  140.         fn()
  141.     }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement