Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Discord Experiments.js
var cache = Object.values(webpackChunkdiscord_app.push([["wp_isdev_patch"], {}, r => r.c]));
webpackChunkdiscord_app.pop();
var DevStore = cache.find(m => m?.exports?.default?.isDeveloper !== void 0).exports.default;
var UserStore = cache.find(m => m?.exports?.default?.getUsers).exports.default;
var nodes = Object.values(DevStore._dispatcher._actionHandlers._dependencyGraph.nodes);
try {
nodes.find(n => n.name == "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({
user: { flags: 1 }, type: "CONNECTION_OPEN"
});
} catch { }
var oldGetUser = UserStore.getCurrentUser;
UserStore.getCurrentUser = () => ({ hasFlag: () => true });
nodes.find(n => n.name == "DeveloperExperimentStore").actionHandler["OVERLAY_INITIALIZE"]();
UserStore.getCurrentUser = oldGetUser;
@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

@ichigo86150
Copy link

ichigo86150 commented Sep 27, 2022

They changed it again I guess
image

@Suni29
Copy link

Suni29 commented Sep 27, 2022

They changed it again I guess image

Yeah, they care a lot more now about these. If anyone got something new, please let me know. Thanks.

@Suni29
Copy link

Suni29 commented Sep 27, 2022

They changed it again I guess image

Yeah, they care a lot more now about these. If anyone got something new, please let me know. Thanks.

Okay turns out Discord just started changing words randomly in their webpack code, anyways this should work.

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

@Fishvap
Copy link

Fishvap commented Sep 27, 2022

They changed it again I guess image

Yeah, they care a lot more now about these. If anyone got something new, please let me know. Thanks.

Okay turns out Discord just started changing words randomly in their webpack code, anyways this should work.

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

I can't use this, it appears that it doesn't let you view the Experiments tab?

@Suni29
Copy link

Suni29 commented Sep 27, 2022

They changed it again I guess image

Yeah, they care a lot more now about these. If anyone got something new, please let me know. Thanks.

Okay turns out Discord just started changing words randomly in their webpack code, anyways this should work.

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

I can't use this, it appears that it doesn't let you view the Experiments tab?

It works fine for me, after you executed it click on another tab like "My Account" or just reopen the settings menu to update it.
Or idk where are you using it but it works fine on Stable 149345 (f0be125).

@BachLe2000
Copy link

BachLe2000 commented Sep 27, 2022

They changed it again I guess image

Yeah, they care a lot more now about these. If anyone got something new, please let me know. Thanks.

Okay turns out Discord just started changing words randomly in their webpack code, anyways this should work.

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

I can't use this, it appears that it doesn't let you view the Experiments tab?

It works fine for me, after you executed it click on another tab like "My Account" or just reopen the settings menu to update it. Or idk where are you using it but it works fine on Stable 149345 (f0be125).

Thanks! It's working! Canary 149626 (91c1a81)
image

@Suni29
Copy link

Suni29 commented Sep 28, 2022

They changed it again I guess image

Yeah, they care a lot more now about these. If anyone got something new, please let me know. Thanks.

Okay turns out Discord just started changing words randomly in their webpack code, anyways this should work.

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

I can't use this, it appears that it doesn't let you view the Experiments tab?

It works fine for me, after you executed it click on another tab like "My Account" or just reopen the settings menu to update it. Or idk where are you using it but it works fine on Stable 149345 (f0be125).

Thanks! It's working! Canary 149626 (91c1a81) image

Cool, now it's confirmed to be working.

@Aholicknight
Copy link

Aholicknight commented Sep 28, 2022

image

@Suni29 the code snippet you shared for some reason does not work (unless I did something wrong. I am using PTB and you can view the code here: https://gist.github.com/Aholicknight/d3a5e717a8bb50eaf4d61becda6a3879

image

EDIT: Works now

EDIT 2: And I am back in buisness

@net-wayfarer
Copy link

net-wayfarer commented Sep 29, 2022

@Aholicknight I am curious how you fixed the issue. Looking from your screenshot, you are still using Bd and so brings relevance to my question.

Based on your old (now deleted) PR, My guess is your latest fix changes default? to Z? and edit on nodes.find to remove that , type: "CONNECTION_OPEN"})?

diff --git a/plugins/discordexperiments.plugin.js b/plugins/discordexperiments.plugin.js
index d917ebf..f63aa62 100644
--- a/plugins/discordexperiments.plugin.js
+++ b/plugins/discordexperiments.plugin.js
@@ -1,15 +1,15 @@
 /**
  * @name discordExperiments
  * @description Enables the experiments tab in discord's settings.
- * @author square, AAGaming00, ImperiusFate750, dav1312, Aholicknight
- * @version 1.3.1
+ * @author square, AAGaming00, ImperiusFate750, dav1312, Aholicknight, Suni29
+ * @version 1.3.2
  * @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);
+ const settingsStore = BdApi.findModule(m => typeof m?.Z?.isDeveloper !== "undefined");
+ const userStore = BdApi.findModule(m => m?.Z?.getUsers);
  
  module.exports = class {
         getName(){ return "Discord Experiments"; }
@@ -17,7 +17,7 @@
         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"})
+                        nodes.find(x => x.name == "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({user: {flags: 1}})
                 } catch (e) {} // this will always intentionally throw
                 const oldGetUser = userStore.default.__proto__.getCurrentUser;
                 userStore.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})

P.S: I got the idea from @Suni29 and @acendvgnt that the main changes were those. I am just unsure if that was all that was needed, or is there more. Could also do a PR on your public fork, following @Inve1951 reaction, but I am also privately maintaining my own variant.

@Inve1951
Copy link

Inve1951 commented Oct 1, 2022

btw guys, feel free to strip me from the @author field - this code doesn't share a single line with what i had written anymore.
furthermore @updateUrl, @website, @source can go as-well

@Suni29
Copy link

Suni29 commented Oct 1, 2022

image

@Suni29 the code snippet you shared for some reason does not work (unless I did something wrong. I am using PTB and you can view the code here: https://gist.github.com/Aholicknight/d3a5e717a8bb50eaf4d61becda6a3879

image

EDIT: Works now

EDIT 2: And I am back in buisness

Sorry for late response, though as i can see you managed to fix it. I'm not really using bd but if you have any problems mention me.

@Suni29
Copy link

Suni29 commented Oct 1, 2022

Btw if anyone works or worked with the dev portal webpack before then please explain it to me that how i can enable experimental features there.

@Aholicknight
Copy link

Aholicknight commented Oct 1, 2022

Btw if anyone works or worked with the dev portal webpack before then please explain it to me that how i can enable experimental features there.

E626BAA1-B9C1-4B8E-9853-FAE833EDDA17

A051ABE7-C3B2-4811-9ECF-4C7D8FB23124

@Suni29 are you talking about the client-side dev tools?

@thehomelander11
Copy link

thehomelander11 commented Oct 1, 2022

can i keep experiments on without having to enter the code every time i start discord or not?

@DaEnder
Copy link

DaEnder commented Oct 2, 2022

Btw if anyone works or worked with the dev portal webpack before then please explain it to me that how i can enable experimental features there.

E626BAA1-B9C1-4B8E-9853-FAE833EDDA17

A051ABE7-C3B2-4811-9ECF-4C7D8FB23124 A051ABE7-C3B2-4811-9ECF-4C7D8FB23124

@Suni29 are you talking about the client-side dev tools?

How do you get that?

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