forked from Inve1951/BetterDiscordStuff
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdiscordexperiments.plugin.js
31 lines (27 loc) · 1.37 KB
/
discordexperiments.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @name discordExperiments
* @description Enables the experiments tab in discord's settings.
* @author square, AAGaming00
* @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._dependencyGraph.nodes);
try {
nodes.find(x => x.name == "ExperimentStore").actionHandler["CONNECTION_OPEN"]({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["CONNECTION_OPEN"]()
userStore.default.__proto__.getCurrentUser = oldGetUser
}
stop(){
Object.values(settingsStore.default._dispatcher._dependencyGraph.nodes).find(x => x.name == "ExperimentStore").actionHandler["CONNECTION_OPEN"]({user: {flags: 0}, type: "CONNECTION_OPEN"})
}
};