Skip to content

Instantly share code, notes, and snippets.

@MeguminSama
Last active December 26, 2024 16:08
Show Gist options
  • Save MeguminSama/2cae24c9e4c335c661fa94e72235d4c4 to your computer and use it in GitHub Desktop.
Save MeguminSama/2cae24c9e4c335c661fa94e72235d4c4 to your computer and use it in GitHub Desktop.
Discord Experiments.js
let cache; webpackChunkdiscord_app.push([["wp_isdev_patch"], {}, r => cache=r.c]);
var UserStore = Object.values(cache).find(m => m?.exports?.default?.getUser).exports.default;
var actions = Object.values(UserStore._dispatcher._actionHandlers._dependencyGraph.nodes);
var user = UserStore.getCurrentUser();
actions.find(n => n.name === "ExperimentStore").actionHandler.CONNECTION_OPEN({
type: "CONNECTION_OPEN", user: {flags: user.flags |= 1}, experiments: [],
});
actions.find(n => n.name === "DeveloperExperimentStore").actionHandler.CONNECTION_OPEN();
webpackChunkdiscord_app.pop(); user.flags &= ~1; "done";
@MeguminSama
Copy link
Author

@Zyrenth thanks for the patch. Gist has been updated.

@vstudiocode
Copy link

very h

@NightSprite
Copy link

works as of may 2024

@CamperSamu
Copy link

Another patch because we love discord: (as of writing this the update is only pushed to canary and ptb)

This is still working, but if you're on linux and you're using wayland don't use this if you intend to stream since it breaks the new wayland screensharing tool.
I think it has something to do with it being some experiment that gets disabled by this snippet, but I couldn't get to the specific reason at 3AM.
I bisected the script and it happens after running the first actions.find, if someone that knows how discord works wants to help figure out a fix it would be great.

@MeguminSama
Copy link
Author

it could be worth grabbing the current experiments list and reinserting that into the CONNECTION_OPEN payload

@CamperSamu
Copy link

I tried digging inside the Discord Canary client to try and figure out a way to do it, but I couldn't figure it out.
I am not the most knowledgeable in JS RE or the inner workings of the Discord client in general, maybe someone else might figure it out.

I played around with Zere's Plugin Library since it hosts some helper functions to get experiments and stuff like that, but apparently the ExperimentStore gets created after the experiments get enabled on the client, so it might be something else that's causing the issue (maybe something related to changing user flags?)

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