Skip to content

Instantly share code, notes, and snippets.

@JohannesMP
Forked from ExordiumX/betaenabler.js
Last active May 23, 2024 07:56
Show Gist options
  • Save JohannesMP/afdf27383608c3b6f20a6a072d0be93c to your computer and use it in GitHub Desktop.
Save JohannesMP/afdf27383608c3b6f20a6a072d0be93c to your computer and use it in GitHub Desktop.
Enabling Discord Dev Experiments on Discord for Windows (2022-02)

Enable Dev Experiments in Discord for Windows

image

This guide shows how to enable dev mode for the Discord desktop application running on Windows (as of February 2022).

This can be used to view beta experiments to try features currently in development that are included but hidden by default in Discord release builds.


Enable the Discord Dev Console

Under the hood the Discord application is just trimmed down web browser, with much of the UI logic being written in javascript. Like Google Chrome, it includes a Developer console for running javascript code.

image

This dev console can be used to modify settings in Discord that are normally hidden. This includes beta/testing settings and experiments that are included in public builds but hidden by default.

If your Discord opens its dev console when you press Ctrl+Shift+i you can skip to the next section below.


As of 2022/01/28 this console is disabled unless you enable it manually in Discord's settings file:

  1. Use WIN+R to open the Windows 'Run' dialog and paste in the appropriate path to open the corresponding settings directory of your discord installation:

    • Discord: %APPDATA%\Discord\
    • Discord PTB (Public Test Build): %APPDATA%\DiscordPTB\
    • Discord Canary: %APPDATA%\discordcanary\
  2. In this directory, open the settings.json file

image

  1. Add the following entry to the settings.json file:
"DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING": true

So for example, if your settings.json looks like this:

{
  "BACKGROUND_COLOR": "#202225",
  "IS_MAXIMIZED": false,
  "IS_MINIMIZED": false,
  "WINDOW_BOUNDS": {
    "x": 288,
    "y": 51,
    "width": 1591,
    "height": 919
  },
  "OPEN_ON_STARTUP": false
}

You should modify it to look like this:

{
  "BACKGROUND_COLOR": "#202225",
  "IS_MAXIMIZED": false,
  "IS_MINIMIZED": false,
  "WINDOW_BOUNDS": {
    "x": 288,
    "y": 51,
    "width": 1591,
    "height": 919
  },
  "OPEN_ON_STARTUP": false,
  "DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING": true
}

NOTE: A comma is necessary after the "OPEN_ON_STARTUP": true/false line! MAKE SURE YOU ADD IT!!


  1. Save your settings.json file and completely shut down Discord

    • Ensure you don't just close the window, but also that Discord is no longer visible in your taskbar notification bar.
    • When in doubt, just force quit it using the task manager :P
  2. Restart Discord

  3. In Discord, open the Dev console using Ctrl+Shift+i


Using Discord Dev console to show dev options

WARNING: the Discord dev console can be used to access the internal settings of Discord, including your login credentials.

That is why the dev console explicitly outputs the following warnings: image

Treat any code you are asked to run in the dev console with strict scrutiny.


Since these instructions are having you do exactly that, you should first assure yourself that the code is actually safe to use.

Here is formatted version of the code you will be asked to run (note that line breaks and indenting does not change the code):

Object.defineProperty(
    (webpackChunkdiscord_app.push([
        [""],
        {},
        (e) => {
            m = [];
            for (let c in e.c) m.push(e.c[c]);
        },
    ]),
    m).find((m) => m?.exports?.default?.isDeveloper !== void 0).exports.default,
    "isDeveloper",
    { get: () => true }
);

This code ensures that all isDeveloper properties in Discord's intrnal objects are forced to return true. It does not communicate with any external server, or touch your credentials.

With that out of the way, here is the same code but with extra newlines and spaces removed:

Object.defineProperty((webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.isDeveloper!==void 0).exports.default,"isDeveloper",{get:()=>true});

Once you have assured yourself that this line is identical to the one shown above, copy the single line code completely and then paste it into the discord dev console and hit return:

image


You'll know that this worked if you when you open your Discord settings you see the following: image

NOTE: If your Discord settings were open when you ran the command close and open them again.


Enabling Discord Experiments

You can now view Discord experiments by selecting 'Experiments' at the bottom of the left sidebar in the Settings UI.

You can then search for specific settings, such as enabling the multi-account experiment:

image

@chrisssj2
Copy link

c = webpackChunkdiscord_app.push([[Symbol()],{},({c})=>Object.values(c)]);
u = c.find((x)=> x?.exports?.default?.getUsers).exports.default;
m = Object.values(u._dispatcher._actionHandlers._dependencyGraph.nodes);

u.getCurrentUser().flags |= 1;
m.find((x)=>x.name === "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]();
try {m.find((x)=>x.name === "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user:{flags: 1}})} catch {}
m.find((x)=>x.name === "ExperimentStore").storeDidChange()

this works

How? ctrl+SHIFT+I doesn't open console. so what do you do with this code?

@RaspberryKitty1
Copy link

c = webpackChunkdiscord_app.push([[Symbol()],{},({c})=>Object.values(c)]);
u = c.find((x)=> x?.exports?.default?.getUsers).exports.default;
m = Object.values(u._dispatcher._actionHandlers._dependencyGraph.nodes);

u.getCurrentUser().flags |= 1;
m.find((x)=>x.name === "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]();
try {m.find((x)=>x.name === "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user:{flags: 1}})} catch {}
m.find((x)=>x.name === "ExperimentStore").storeDidChange()

this works

Yes this does work, thank you! Now what would I have to replace in my plugin to make it work? This is my old plugin:

/**
 * @name discordExperimentsfixed
 * @description Enables the experiments tab in discord's settings.
 * @author Aholicknight
 * @version 1.3.3.7
 */

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 Fixed";
    }

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

EDIT: Fixed it

what did you do to fix it?

image

@RaspberryKitty1
Copy link

c = webpackChunkdiscord_app.push([[Symbol()],{},({c})=>Object.values(c)]);
u = c.find((x)=> x?.exports?.default?.getUsers).exports.default;
m = Object.values(u._dispatcher._actionHandlers._dependencyGraph.nodes);

u.getCurrentUser().flags |= 1;
m.find((x)=>x.name === "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]();
try {m.find((x)=>x.name === "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user:{flags: 1}})} catch {}
m.find((x)=>x.name === "ExperimentStore").storeDidChange()

this works

Yeah! It works!

image
broken now

@Aholicknight
Copy link

Yup the plugin broke again. Need to wait for a fix

@Soleanna
Copy link

Soleanna commented Dec 6, 2023

loading the inspector for some reason forcibly logs me out, not sure if this is new or not...

@MedlockC
Copy link

MedlockC commented Dec 7, 2023

I took a crack at this, but I don't know if this fix will work for everyone, and could likely be optimized by people who understand this a bit more.

let wpRequire;
webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
u = Object.values(wpRequire.c).find((x)=> x?.exports?.default?.getCurrentUser && x?.exports?.default?._dispatcher?._actionHandlers).exports.default
m = Object.values(u._dispatcher._actionHandlers._dependencyGraph.nodes);

u.getCurrentUser().flags |= 1;
m.find((x)=>x.name === "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]();
try {m.find((x)=>x.name === "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user:{flags: 1}})} catch {}
m.find((x)=>x.name === "ExperimentStore").storeDidChange()

@Like4Schnitzel
Copy link

Fixes it for me. However, interestingly, it doesn't work on (re)load when used in the start() method of a plugin. After manually disabling and re-enabling the plugin, the experiments tab does appear though.

@Ayimforgoroldacc
Copy link

Ayimforgoroldacc commented Dec 7, 2023

let _,a=Object.values,b="getCurrentUser",c="actionHandler",d="_actionHandlers",l="_dispatcher",i="ExperimentStore";webpackChunkdiscord_app.push([[Date.now()],{},e=>{_=e}]),m=a((u=a(_.c).find(e=>e?.exports?.default?.[b]&&e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes),u[b]().flags|=1,m.find(e=>"Developer"+i==e.name)[c].CONNECTION_OPEN();try{m.find(e=>i==e.name)[c].OVERLAY_INITIALIZE({user:{flags:1}})}catch{}m.find(e=>i==e.name).storeDidChange()

This is working, golfed MedLock's solution 611 -> 477 characters
prettified below

let _, a = Object.values,
    b = "getCurrentUser",
    c = "actionHandler",
    d = "_actionHandlers",
    l = "_dispatcher",
    i = "ExperimentStore";
webpackChunkdiscord_app.push([
    [Date.now()], {},
    e => {
        _ = e
    }
]), m = a((u = a(_.c).find(e => e?.exports?.default?.[b] && e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes), u[b]().flags |= 1, m.find(e => "Developer" + i == e.name)[c].CONNECTION_OPEN();
try {
    m.find(e => i == e.name)[c].OVERLAY_INITIALIZE({
        user: {
            flags: 1
        }
    })
} catch {}
m.find(e => i == e.name).storeDidChange()

@ChrisZeThird
Copy link

Got the following error:

Uncaught TypeError: Cannot redefine property: isDeveloper
    at Function.defineProperty (<anonymous>)
    at <anonymous>:1:8```

@veintrip
Copy link

let _,a=Object.values,b="getCurrentUser",c="actionHandler",d="_actionHandlers",l="_dispatcher",i="ExperimentStore";webpackChunkdiscord_app.push([[Date.now()],{},e=>{_=e}]),m=a((u=a(_.c).find(e=>e?.exports?.default?.[b]&&e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes),u[b]().flags|=1,m.find(e=>"Developer"+i==e.name)[c].CONNECTION_OPEN();try{m.find(e=>i==e.name)[c].OVERLAY_INITIALIZE({user:{flags:1}})}catch{}m.find(e=>i==e.name).storeDidChange()

This is working, golfed MedLock's solution 611 -> 477 characters prettified below

let _, a = Object.values,
    b = "getCurrentUser",
    c = "actionHandler",
    d = "_actionHandlers",
    l = "_dispatcher",
    i = "ExperimentStore";
webpackChunkdiscord_app.push([
    [Date.now()], {},
    e => {
        _ = e
    }
]), m = a((u = a(_.c).find(e => e?.exports?.default?.[b] && e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes), u[b]().flags |= 1, m.find(e => "Developer" + i == e.name)[c].CONNECTION_OPEN();
try {
    m.find(e => i == e.name)[c].OVERLAY_INITIALIZE({
        user: {
            flags: 1
        }
    })
} catch {}
m.find(e => i == e.name).storeDidChange()

worked for me!

@Vann-Dev
Copy link

Vann-Dev commented Mar 4, 2024

let _,a=Object.values,b="getCurrentUser",c="actionHandler",d="_actionHandlers",l="_dispatcher",i="ExperimentStore";webpackChunkdiscord_app.push([[Date.now()],{},e=>{_=e}]),m=a((u=a(_.c).find(e=>e?.exports?.default?.[b]&&e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes),u[b]().flags|=1,m.find(e=>"Developer"+i==e.name)[c].CONNECTION_OPEN();try{m.find(e=>i==e.name)[c].OVERLAY_INITIALIZE({user:{flags:1}})}catch{}m.find(e=>i==e.name).storeDidChange()

This is working, golfed MedLock's solution 611 -> 477 characters prettified below

let _, a = Object.values,
    b = "getCurrentUser",
    c = "actionHandler",
    d = "_actionHandlers",
    l = "_dispatcher",
    i = "ExperimentStore";
webpackChunkdiscord_app.push([
    [Date.now()], {},
    e => {
        _ = e
    }
]), m = a((u = a(_.c).find(e => e?.exports?.default?.[b] && e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes), u[b]().flags |= 1, m.find(e => "Developer" + i == e.name)[c].CONNECTION_OPEN();
try {
    m.find(e => i == e.name)[c].OVERLAY_INITIALIZE({
        user: {
            flags: 1
        }
    })
} catch {}
m.find(e => i == e.name).storeDidChange()

worked for me!

Still worked for me as today

@GamerBossHarmon
Copy link

let _,a=Object.values,b="getCurrentUser",c="actionHandler",d="_actionHandlers",l="_dispatcher",i="ExperimentStore";webpackChunkdiscord_app.push([[Date.now()],{},e=>{_=e}]),m=a((u=a(_.c).find(e=>e?.exports?.default?.[b]&&e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes),u[b]().flags|=1,m.find(e=>"Developer"+i==e.name)[c].CONNECTION_OPEN();try{m.find(e=>i==e.name)[c].OVERLAY_INITIALIZE({user:{flags:1}})}catch{}m.find(e=>i==e.name).storeDidChange()

This is working, golfed MedLock's solution 611 -> 477 characters prettified below

let _, a = Object.values,
    b = "getCurrentUser",
    c = "actionHandler",
    d = "_actionHandlers",
    l = "_dispatcher",
    i = "ExperimentStore";
webpackChunkdiscord_app.push([
    [Date.now()], {},
    e => {
        _ = e
    }
]), m = a((u = a(_.c).find(e => e?.exports?.default?.[b] && e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes), u[b]().flags |= 1, m.find(e => "Developer" + i == e.name)[c].CONNECTION_OPEN();
try {
    m.find(e => i == e.name)[c].OVERLAY_INITIALIZE({
        user: {
            flags: 1
        }
    })
} catch {}
m.find(e => i == e.name).storeDidChange()

worked for me!

Still worked for me as today

Still worked for me

@Maple38
Copy link

Maple38 commented Apr 20, 2024

Any way to automate this?

@cryoelite
Copy link

let _, a = Object.values,
    b = "getCurrentUser",
    c = "actionHandler",
    d = "_actionHandlers",
    l = "_dispatcher",
    i = "ExperimentStore";
webpackChunkdiscord_app.push([
    [Date.now()], {},
    e => {
        _ = e
    }
]), m = a((u = a(_.c).find(e => e?.exports?.default?.[b] && e?.exports?.default?.[l]?.[d]).exports.default)[l][d]._dependencyGraph.nodes), u[b]().flags |= 1, m.find(e => "Developer" + i == e.name)[c].CONNECTION_OPEN();
try {
    m.find(e => i == e.name)[c].OVERLAY_INITIALIZE({
        user: {
            flags: 1
        }
    })
} catch {}
m.find(e => i == e.name).storeDidChange()

Still worked for me

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