Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Discord Experiments.js
window.___wp = function(e) {
let id = e.c[Object.keys(e.c).find((k) => e.c[k]?.exports?.default?.isDeveloper === false)];
if (id) Object.defineProperty(id.exports.default, "isDeveloper", {get:()=>true});
delete window.___wp;
}
webpackChunkdiscord_app.push([["wp_isdev_patch"], {},window.___wp]);
@ThatRedPandaDev
Copy link

ThatRedPandaDev commented Sep 7, 2021

Discord literally even tells you that if you are uncomfortable with pasting stuff, then don't do it.

@Dragonizedpizza
Copy link

Dragonizedpizza commented Oct 4, 2021

Screenshot_20211004-172514
LOL

Copy link

ghost commented Oct 30, 2021

image
I don't know whether to be offended, or to laugh lol

@erickonlive
Copy link

erickonlive commented Mar 3, 2022

thanks pal, I loved that QA disclaimer

@13-05
Copy link

13-05 commented Mar 12, 2022

ggz, pog code

@TheRealHyped
Copy link

TheRealHyped commented Apr 10, 2022

thanks

@RossMdevs
Copy link

RossMdevs commented Jun 16, 2022

As @MeguminSama stated,

Discord has learned from past mistakes to now hide experiments behind their API.

You'll be 403'd for a lot of the experiments

https://discord.com/api/v8/science

Example 403

@kotx
Copy link

kotx commented Jun 16, 2022

@RossMdevs I don't know what you mean, those are build overrides, not experiments?

@RossMdevs
Copy link

RossMdevs commented Jun 17, 2022

@RossMdevs I don't know what you mean, those are build overrides, not experiments?

It’s an example of 1 of many 403’s you can get when enabling discord experiments.

@XxUnkn0wnxX
Copy link

XxUnkn0wnxX commented Aug 2, 2022

Current working code: Credits to HypedDomi#1711 | AAGaming#9395 (BetterDiscord Community)

let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
mod = Object.values(wpRequire.c).find(x => typeof x?.exports?.default?.isDeveloper !== "undefined")
usermod = Object.values(wpRequire.c).find(x => x?.exports?.default?.getUsers)
nodes = Object.values(mod.exports.default._dispatcher._dependencyGraph.nodes)
try {
    nodes.find(x => x.name == "ExperimentStore").actionHandler["CONNECTION_OPEN"]({user: {flags: 1}, type: "CONNECTION_OPEN"})
} catch (e) {}
oldGetUser = usermod.exports.default.__proto__.getCurrentUser;
usermod.exports.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})
nodes.find(x => x.name == "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]()
usermod.exports.default.__proto__.getCurrentUser = oldGetUser

Edit: Note However, both browser ver & plugin ver on BD kills all file uploads with experiments on. which odd.

V2 Credits to ace19#1790 for a different action handler "OVERLAY_INITIALIZE"

let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
mod = Object.values(wpRequire.c).find(x => typeof x?.exports?.default?.isDeveloper !== "undefined")
usermod = Object.values(wpRequire.c).find(x => x?.exports?.default?.getUsers)
nodes = Object.values(mod.exports.default._dispatcher._dependencyGraph.nodes)
try {
    nodes.find(x => x.name == "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user: {flags: 1}})
} catch (e) {}
oldGetUser = usermod.exports.default.__proto__.getCurrentUser;
usermod.exports.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})
nodes.find(x => x.name == "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]()
usermod.exports.default.__proto__.getCurrentUser = oldGetUser

this one has no issues with file uploads..

@MeguminSama
Copy link
Author

MeguminSama commented Aug 2, 2022

Thanks @XxUnkn0wnxX
I'm going to try finding a cleaner way of doing this. But this seems like the best thing to do for now :/

@hackermondev
Copy link

hackermondev commented Aug 2, 2022

thanks

@Aholicknight
Copy link

Aholicknight commented Aug 3, 2022

Current working code: Credits to HypedDomi#1711 | AAGaming#9395 (BetterDiscord Community)

@XxUnkn0wnxX Thank you for sharing this, when discord opens, do you have to paste this everytime in the debug console?

@alexsquibbs
Copy link

alexsquibbs commented Aug 3, 2022

Current working code: Credits to HypedDomi#1711 | AAGaming#9395 (BetterDiscord Community)

@XxUnkn0wnxX Thank you for sharing this, when discord opens, do you have to paste this everytime in the debug console?

yes, every time you start or refresh discord you have to inject the code into your client.

also, quick question: when will the one currently displayed stop working, as i see someone has posted a new one, but the one on display still works on even the latest canary windows desktop client?

@ra1nbow1
Copy link

ra1nbow1 commented Aug 3, 2022

let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
mod = Object.values(wpRequire.c).find(x => typeof x?.exports?.default?.isDeveloper !== "undefined")
usermod = Object.values(wpRequire.c).find(x => x?.exports?.default?.getUsers)
nodes = Object.values(mod.exports.default._dispatcher._dependencyGraph.nodes)
try {
    nodes.find(x => x.name == "ExperimentStore").actionHandler["CONNECTION_OPEN"]({user: {flags: 1}, type: "CONNECTION_OPEN"})
} catch (e) {}
oldGetUser = usermod.exports.default.__proto__.getCurrentUser;
usermod.exports.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})
nodes.find(x => x.name == "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]()
usermod.exports.default.__proto__.getCurrentUser = oldGetUser

Thanks a lot!

@Pro55624
Copy link

Pro55624 commented Aug 4, 2022

how do i keep the experimental feature on?
is there a code to auto paste it on start?

@kotx
Copy link

kotx commented Aug 4, 2022

how do i keep the experimental feature on? is there a code to auto paste it on start?

Powercord has a setting to always show the experiments tab.

@cooolgamer
Copy link

cooolgamer commented Aug 5, 2022

how do i keep the experimental feature on? is there a code to auto paste it on start?

Powercord has a setting to always show the experiments tab.

I already tried but it doesn't work, and I uninstalled it because I always use discord on browser anyways

@leafpool243
Copy link

leafpool243 commented Aug 6, 2022

how do i keep the experimental feature on? is there a code to auto paste it on start?

Powercord has a setting to always show the experiments tab.

@kotx @cooolgamer Powercord is EOL, so their Experiments thing no longer works (as it uses the old code).

@kotx
Copy link

kotx commented Aug 6, 2022

works well enough for me...

@Vadym-beep
Copy link

Vadym-beep commented Aug 7, 2022

Does not wok for me, it gives type error. (I use betterdiscord btw)

@NurMarvin
Copy link

NurMarvin commented Aug 9, 2022

As stated semi-publicly by a Discord staff member, anything that will be posted here, will eventually get patched since literally everyone that searches for "Discord Experiments" on Google will be able to find this:

experiments

I've gone ahead and redacted the Discord staff member's name and avatar to prevent potential harassment over this. Their reasoning is that less technical people will use this to access experiments and then might end up in a state that they can't recover from without technical knowledge and then annoy support about something they shouldn't be able to access to begin with. If you do have a working way to access experiments, keep it to yourself as it will get patched eventually if you post about it here.

@oq-x
Copy link

oq-x commented Aug 10, 2022

this doesnt work now

@Aholicknight
Copy link

Aholicknight commented Aug 10, 2022

this doesnt work now

@oq-x Did you use the fork from AAGaming00/BetterDiscordStuff-1/plugins/discordexperiments.plugin.js ? This is the updated version and it works.

@Vendicated
Copy link

Vendicated commented Aug 10, 2022

Current working code: Credits to HypedDomi#1711 | AAGaming#9395 (BetterDiscord Community)

[...]

Edit: Note However, both browser ver & plugin ver on BD kills all file uploads with experiments on. which odd.

V2 Credits to ace19#1790 for a different action handler "OVERLAY_INITIALIZE"

[...]

this one has no issues with file uploads..

These snippets are now broken in the latest canary: Uncaught TypeError: Cannot read properties of undefined (reading 'nodes') (breaking commit is this.)

The fix is to replace

nodes = Object.values(mod.exports.default._dispatcher._dependencyGraph.nodes)

with

nodes = Object.values(mod.exports.default._dispatcher._actionHandlers._dependencyGraph.nodes);

Thus, the updated snippet is

let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
mod = Object.values(wpRequire.c).find(x => typeof x?.exports?.default?.isDeveloper !== "undefined")
usermod = Object.values(wpRequire.c).find(x => x?.exports?.default?.getUsers)
nodes = Object.values(mod.exports.default._dispatcher._actionHandlers._dependencyGraph.nodes);
try {
    nodes.find(x => x.name == "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user: {flags: 1}})
} catch (e) {}
oldGetUser = usermod.exports.default.__proto__.getCurrentUser;
usermod.exports.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})
nodes.find(x => x.name == "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]()
usermod.exports.default.__proto__.getCurrentUser = oldGetUser

@Aholicknight
Copy link

Aholicknight commented Aug 11, 2022

@Vendicated updated plugin with your fix is here:

/**
 * @name discordExperiments
 * @description Enables the experiments tab in discord's settings.
 * @author square
 * @version 1.3.1
 * @website https://betterdiscord.app/plugin/Discord%20Experiments
 * @source https://github.com/Inve1951/BetterDiscordStuff/blob/master/plugins/discordexperiments.plugin.js
 * @updateUrl https://betterdiscord.app/gh-redirect?id=206
 */

 const settingsStore = BdApi.findModule(m => typeof m?.default?.isDeveloper !== "undefined");
 const userStore = BdApi.findModule(m => m?.default?.getUsers);
 
 module.exports = class {
	 getName(){ return "Discord Experiments"; }
 
	 start() {
		const nodes = Object.values(settingsStore.default._dispatcher._actionHandlers._dependencyGraph.nodes); // Fix by dav1312
		 try {
			 nodes.find(x => x.name == "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user: {flags: 1}, type: "CONNECTION_OPEN"})
		 } catch (e) {} // this will always intentionally throw
		 const oldGetUser = userStore.default.__proto__.getCurrentUser;
		 userStore.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})
		 nodes.find(x => x.name == "DeveloperExperimentStore").actionHandler["OVERLAY_INITIALIZE"]()
		 userStore.default.__proto__.getCurrentUser = oldGetUser
	 }
 
	 stop(){
		 Object.values(settingsStore.default._dispatcher._dependencyGraph.nodes).find(x => x.name == "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user: {flags: 0}, type: "CONNECTION_OPEN"})
	 }
 };

@MasicoreLord
Copy link

MasicoreLord commented Aug 12, 2022

Unfortunately thanks to these snippets being on a gists that comes up near the top on Google for "enable discord experiments", it's very likely Discord will make them useless soon.

@MasicoreLord
Copy link

MasicoreLord commented Aug 12, 2022

Although not only would workarounds have to stay away from the top of Google, it'd also likely have to stay out of client mods that also are easily found on Google. Means they can't bake it in safely, and a plugin dev can't make a plugin for it easy to find/install from google as well.

@Divoret
Copy link

Divoret commented Aug 12, 2022

I only wanted to use one experiment feature and that's called "role popout". Also, I tried pasting the above code into a js file but it doesn't work

@oq-x
Copy link

oq-x commented Aug 12, 2022

this doesnt work now

@oq-x Did you use the fork from AAGaming00/BetterDiscordStuff-1/plugins/discordexperiments.plugin.js ? This is the updated version and it works.

how can i use this without better discord?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment