Instantly share code, notes, and snippets.
Save IPostStuff/0945ee65f5e589c66df95833cd002d27 to your computer and use it in GitHub Desktop.
Note
This does not works in browser for non-video, non-activity quests! For stream/play quests use the desktop app!
Note
When doing stream quests, you need at least 1 other account in the vc!
How to use this script:
- Accept a quest under User Settings -> Gift Inventory
- PressCtrl+Shift+I to open DevTools
- Go to the
Consoletab - Paste the following code and hit enter:
Click to expand
deletewindow.$;letwpRequire;window.webpackChunkdiscord_app.push([[Math.random()],{},(req)=>{wpRequire=req;}]);letApplicationStreamingStore=Object.values(wpRequire.c).find(x=>x?.exports?.Z?.getStreamerActiveStreamMetadata).exports.Z;letRunningGameStore=Object.values(wpRequire.c).find(x=>x?.exports?.ZP?.getRunningGames).exports.ZP;letQuestsStore=Object.values(wpRequire.c).find(x=>x?.exports?.Z?.getQuest).exports.Z;letChannelStore=Object.values(wpRequire.c).find(x=>x?.exports?.Z?.getAllThreadsForParent).exports.Z;letGuildChannelStore=Object.values(wpRequire.c).find(x=>x?.exports?.ZP?.getSFWDefaultChannel).exports.ZP;letFluxDispatcher=Object.values(wpRequire.c).find(x=>x?.exports?.Z?.flushWaitQueue).exports.Z;letapi=Object.values(wpRequire.c).find(x=>x?.exports?.tn?.get).exports.tn;letquest=[...QuestsStore.quests.values()].find(x=>x.id!=="1248385850622869556"&&x.userStatus?.enrolledAt&&!x.userStatus?.completedAt&&newDate(x.config.expiresAt).getTime()>Date.now())letisApp=navigator.userAgent.includes("Electron/")if(!quest){console.log("You don't have any uncompleted quests!")}else{constpid=Math.floor(Math.random()*30000)+1000constapplicationId=quest.config.application.idconstapplicationName=quest.config.application.nameconsttaskName=["WATCH_VIDEO","PLAY_ON_DESKTOP","STREAM_ON_DESKTOP","PLAY_ACTIVITY"].find(x=>quest.config.taskConfig.tasks[x]!=null)constsecondsNeeded=quest.config.taskConfig.tasks[taskName].targetconstsecondsDone=quest.userStatus?.progress?.[taskName]?.value??0if(taskName==="WATCH_VIDEO"){consttolerance=2,speed=10constdiff=Math.floor((Date.now()-newDate(quest.userStatus.enrolledAt).getTime())/1000)conststartingPoint=Math.min(Math.max(Math.ceil(secondsDone),diff),secondsNeeded)letfn=async()=>{for(leti=startingPoint;i<=secondsNeeded;i+=speed){try{awaitapi.post({url:`/quests/${quest.id}/video-progress`,body:{timestamp:Math.min(secondsNeeded,i+Math.random())}})}catch(ex){console.log("Failed to send increment of",i,ex.message)}awaitnewPromise(resolve=>setTimeout(resolve,tolerance*1000))}if((secondsNeeded-secondsDone)%speed!==0){awaitapi.post({url:`/quests/${quest.id}/video-progress`,body:{timestamp:secondsNeeded}})}console.log("Quest completed!")}fn()console.log(`Spoofing video for${applicationName}. Wait for${Math.ceil((secondsNeeded-startingPoint)/speed*tolerance)} more seconds.`)}elseif(taskName==="PLAY_ON_DESKTOP"){if(!isApp){console.log("This no longer works in browser for non-video quests. Use the desktop app to complete the",applicationName,"quest!")}api.get({url:`/applications/public?application_ids=${applicationId}`}).then(res=>{constappData=res.body[0]constexeName=appData.executables.find(x=>x.os==="win32").name.replace(">","")constgames=RunningGameStore.getRunningGames()constfakeGame={cmdLine:`C:\\Program Files\\${appData.name}\\${exeName}`,exeName,exePath:`c:/program files/${appData.name.toLowerCase()}/${exeName}`,hidden:false,isLauncher:false,id:applicationId,name:appData.name,pid:pid,pidPath:[pid],processName:appData.name,start:Date.now(),}games.push(fakeGame)FluxDispatcher.dispatch({type:"RUNNING_GAMES_CHANGE",removed:[],added:[fakeGame],games:games})letfn=data=>{letprogress=quest.config.configVersion===1 ?data.userStatus.streamProgressSeconds :Math.floor(data.userStatus.progress.PLAY_ON_DESKTOP.value)console.log(`Quest progress:${progress}/${secondsNeeded}`)if(progress>=secondsNeeded){console.log("Quest completed!")constidx=games.indexOf(fakeGame)if(idx>-1){games.splice(idx,1)FluxDispatcher.dispatch({type:"RUNNING_GAMES_CHANGE",removed:[fakeGame],added:[],games:[]})}FluxDispatcher.unsubscribe("QUESTS_SEND_HEARTBEAT_SUCCESS",fn)}}FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS",fn)console.log(`Spoofed your game to${applicationName}. Wait for${Math.ceil((secondsNeeded-secondsDone)/60)} more minutes.`)})}elseif(taskName==="STREAM_ON_DESKTOP"){if(!isApp){console.log("This no longer works in browser for non-video quests. Use the desktop app to complete the",applicationName,"quest!")}letrealFunc=ApplicationStreamingStore.getStreamerActiveStreamMetadataApplicationStreamingStore.getStreamerActiveStreamMetadata=()=>({id:applicationId,pid,sourceName:null})letfn=data=>{letprogress=quest.config.configVersion===1 ?data.userStatus.streamProgressSeconds :Math.floor(data.userStatus.progress.STREAM_ON_DESKTOP.value)console.log(`Quest progress:${progress}/${secondsNeeded}`)if(progress>=secondsNeeded){console.log("Quest completed!")ApplicationStreamingStore.getStreamerActiveStreamMetadata=realFuncFluxDispatcher.unsubscribe("QUESTS_SEND_HEARTBEAT_SUCCESS",fn)}}FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS",fn)console.log(`Spoofed your stream to${applicationName}. Stream any window in vc for${Math.ceil((secondsNeeded-secondsDone)/60)} more minutes.`)console.log("Remember that you need at least 1 other person to be in the vc!")}elseif(taskName==="PLAY_ACTIVITY"){constchannelId=ChannelStore.getSortedPrivateChannels()[0]?.id??Object.values(GuildChannelStore.getAllGuilds()).find(x=>x!=null&&x.VOCAL.length>0).VOCAL[0].channel.idconststreamKey=`call:${channelId}:1`letfn=async()=>{console.log("Completing quest",applicationName,"-",quest.config.messages.questName)while(true){constres=awaitapi.post({url:`/quests/${quest.id}/heartbeat`,body:{stream_key:streamKey,terminal:false}})constprogress=res.body.progress.PLAY_ACTIVITY.valueconsole.log(`Quest progress:${progress}/${secondsNeeded}`)awaitnewPromise(resolve=>setTimeout(resolve,20*1000))if(progress>=secondsNeeded){awaitapi.post({url:`/quests/${quest.id}/heartbeat`,body:{stream_key:streamKey,terminal:true}})break}}console.log("Quest completed!")}fn()}}
- Follow the printed instructions depending on what type of quest you have
- If your quest says to "play" the game, you can just wait and do nothing
- If your quest says to "stream" the game, join a vc with a friend or alt and stream any window
- Wait for 15 minutes
- You can now claim the reward in User Settings -> Gift Inventory!
You can track the progress by looking at theQuest progress: prints in the Console tab, or by reopening the Gift Inventory tab in settings.
Q: Ctrl + Shift + I doesn't work
A: Either download theptb client, or usethis to enable DevTools on stable
Q: I get an error saying "Unauthorized"
A: Discord has patched the script from working in browsers. Use the desktop app, or alternatively find some extension which lets you change your User-Agent and append the stringElectron/ anywhere in it.
They have also started checking how many people are in the vc, so make sure you join it on at least 1 other account.
Q: I get a syntax error/unexpected token error
A: Make sure your browser isn't auto-translating this website before copying the script. Turn off any translator extensions and try again.
Q: I get the errorCannot read properties of undefined (reading 'nativeModules')
A: You're on a modded client which is a browser wrapper (i.e. Vesktop). Use an actual desktop app.
Q: I get a different error
A: Make sure you're copy/pasting the script correctly and that you've have done all the steps.
Q: Can you make the script auto accept the quest/reward?
A: No. Both of those actions may show a captcha, so automating them is not a good idea. Just do the two clicks yourself.
Side note: Please don't post your "fixed" or "improved" versions of the script in the comments. It creates unnecessary confusion, often doesn't fix anything, and sometimes puts other people's accounts at risk. I might redact/delete such comments without notice. Thank you for understanding.