Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Discord Experiments.js
webpackChunkdiscord_app.push([["wp_isdev_patch"], {}, r => cache=Object.values(r.c)]);
var UserStore = cache.find(m => m?.exports?.default?.getCurrentUser).exports.default;
var actions = UserStore._dispatcher._actionHandlers._orderedActionHandlers["CONNECTION_OPEN"];
var user = UserStore.getCurrentUser();
actions.find(n => n.name === "ExperimentStore").actionHandler({
type: "CONNECTION_OPEN", user: {flags: user.flags |= 1}, experiments: [],
});
actions.find(n => n.name === "DeveloperExperimentStore").actionHandler();
webpackChunkdiscord_app.pop(); user.flags &= ~1; "done";
@MeguminSama
Copy link
Author

MeguminSama commented Dec 15, 2020

Allows you to enable experiments in the latest discord builds. Working as of 2022-10-12
Works on Stable, PTB, Canary on Web & Desktop.

If it doesn't work for you, check the following

  • Is your client modded? This is a no-brainer but if it's modded, please don't complain here if the script doesn't work
    • Some BetterDiscord plugins are known to do stupid stuff with the webpack cache.
  • Do you have a web extension that messes with Discord? Check the previous bullet-point :)
  • Are you running an old build of discord (e.g. Displunger)? If so, check the revision history and try an older version.

If the answer to any of these is "yes", then don't complain here.

This script supports SWC. Stop blaming issues on SWC.

@migue802
Copy link

migue802 commented May 27, 2021

Very useful! Thanks! ❤️

@MeguminSama
Copy link
Author

MeguminSama commented Jun 30, 2021

I'll start deleting dumb comments from now on. Let me make a small FAQ.

Q: "I enabled an experiment but cant use it!!!!"
A: Discord locks many experiments on the API. Enabling it on the client does not bypass this.

Q: "omg ur gonna steal my details"
A: Read the code. It literally just changes a zero to a one (false -> true).

Q: "How to I disable this?"
A: Press CTRL+R to refresh the client, or fully close it from the taskbar and restart it.

Q: "It didn't work!!!"
A: Good for you. I'm not your support agent.

@MeguminSama
Copy link
Author

MeguminSama commented Sep 6, 2021

[Reserved for future use]

@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

@jkosixtyfour
Copy link

jkosixtyfour commented Apr 10, 2022

thanks

@DeltaNachos
Copy link

DeltaNachos commented Oct 18, 2022

works :)

@Suni29
Copy link

Suni29 commented Oct 21, 2022

Its weird because the code that is shared by @MeguminSama isn't working every time.
I had it working for like 2 weeks and then it stopped working for a day or two.
I have this backup one which was working every time for me so I though I share it.

let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
mod = Object.values(wpRequire.c).find(x => typeof x?.exports?.Z?.isDeveloper !== "undefined");
usermod = Object.values(wpRequire.c).find(x => x?.exports?.default?.getUsers)
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) {}
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

@EvaxTheFox
Copy link

EvaxTheFox commented Nov 17, 2022

Its weird because the code that is shared by @MeguminSama isn't working every time.
I had it working for like 2 weeks and then it stopped working for a day or two.
I have this backup one which was working every time for me so I though I share it.

Yours doesnt work, the original one does.

@Suni29
Copy link

Suni29 commented Nov 19, 2022

Its weird because the code that is shared by @MeguminSama isn't working every time.
I had it working for like 2 weeks and then it stopped working for a day or two.
I have this backup one which was working every time for me so I though I share it.

Yours doesnt work, the original one does.

Weird, sometimes one of them doesn't work, sometimes works with both.
And there was users that reported that the original one doesn't work, but mine is, or the complete opposite.
I don't really know why is that but just use the one that works.

@BuyMyMojo
Copy link

BuyMyMojo commented Nov 30, 2022

I quickly made it into a Better Discord plugin so I didn't have to paste it in every time;

Name the file: Experiments.plugin.js

/**
 * @name Experiments
 * @description Blurs images and videos until you hover over them.
 * @version 1.0.0
 * @author BuyMyMojo
 * @authorId 383507911160233985
 * @website https://gist.github.com/MeguminSama/2cae24c9e4c335c661fa94e72235d4c4
 */
module.exports = class ExamplePlugin {
    start() {
		webpackChunkdiscord_app.push([["wp_isdev_patch"], {}, r => Cache=Object.values(r.c)]);
		var UserStore = Cache.find(m => m?.exports?.default?.getCurrentUser).exports.default;
		var actions = UserStore._dispatcher._actionHandlers._orderedActionHandlers["CONNECTION_OPEN"];
		var user = UserStore.getCurrentUser();
		actions.find(n => n.name === "ExperimentStore").actionHandler({
			type: "CONNECTION_OPEN", user: {flags: user.flags |= 1}, experiments: [],
		});
		actions.find(n => n.name === "DeveloperExperimentStore").actionHandler();
		webpackChunkdiscord_app.pop(); user.flags &= ~1; "done";
    }

    stop() {
		BdApi.alert("Experiments disabled!", "Just refresh discord (Ctl + R) and the experiments settings will be gone.");
    }
};

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