Plugin

Experiments

Enable Access to Experiments & other dev-only features in Discord!

Developers Utility
index.tsx
Download

Source

src/plugins/experiments/index.tsx
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import { definePluginSettings } from "@api/Settings";
8import { disableStyle, enableStyle } from "@api/Styles";
9import ErrorBoundary from "@components/ErrorBoundary";
10import { ErrorCard } from "@components/ErrorCard";
11import { Paragraph } from "@components/Paragraph";
12import { BRAND_NAME } from "@utils/branding";
13import { Devs, IS_MAC } from "@utils/constants";
14import { Margins } from "@utils/margins";
15import definePlugin, { OptionType } from "@utils/types";
16import { findByPropsLazy } from "@webpack";
17import { ExperimentStore, Forms, React } from "@webpack/common";
18
19import hideBugReport from "./hideBugReport.css?managed";
20
21const KbdStyles = findByPropsLazy("key", "combo");
22
23const modKey = IS_MAC ? "cmd" : "ctrl";
24const altKey = IS_MAC ? "opt" : "alt";
25
26const settings = definePluginSettings({
27 toolbarDevMenu: {
28 type: OptionType.BOOLEAN,
29 description: "Change the Help (?) toolbar button (top right in chat) to Discord's developer menu",
30 default: false,
31 restartNeeded: true
32 }
33});
34
35export default definePlugin({
36 name: "Experiments",
37 description: "Enable Access to Experiments & other dev-only features in Discord!",
38 tags: ["Developers", "Utility"],
39 authors: [
40 Devs.Megu,
41 Devs.Ven,
42 Devs.Nickyux,
43 Devs.BanTheNons,
44 Devs.Nuckyz,
45 ],
46
47 settings,
48
49 patches: [
50 {
51 find: "Object.defineProperties(this,{isDeveloper",
52 replacement: {
53 match: /(?<={isDeveloper:\{[^}]+?,get:\(\)=>)\i/,
54 replace: "true"
55 }
56 },
57 {
58 find: &#039;type:"user",revision&#039;,
59 replacement: {
60 match: /!(\i)(?=&&"CONNECTION_OPEN")/,
61 replace: "!($1=true)"
62 }
63 },
64 {
65 find: &#039;placeholder:"Search experiments"&#039;,
66 replacement: [
67 {
68 match: /(?<=children:\[)(?=null!=.{0,150}"Installation ID:)/,
69 replace: "$self.WarningCard(),"
70 },
71 // for some reason the installation id and copy buttons are on
72 // different lines so it looks stupid when the card above is added
73 {
74 match: /(?<=,marginBottom:16)(?=\},children:\[)/,
75 replace: &#039;,flexDirection:"row",alignItems:"center"&#039;
76 }
77 ]
78 },
79 // Change top right toolbar button from the help one to the dev one
80 {
81 find: &#039;?"BACK_FORWARD_NAVIGATION":&#039;,
82 replacement: {
83 match: /hasBugReporterAccess:(\i)/,
84 replace: "_hasBugReporterAccess:$1=true"
85 },
86 predicate: () => settings.store.toolbarDevMenu
87 },
88 // Disable opening the bug report menu when clicking the top right toolbar dev button
89 {
90 find: &#039;navId:"staff-help-popout"&#039;,
91 replacement: {
92 match: /(isShown.+?)onClick:\i/,
93 replace: (_, rest) => `${rest}onClick:()=>{}`
94 }
95 },
96 // Enable experiment embed on sent experiment links
97 {
98 find: "Clear Treatment ",
99 replacement: [
100 {
101 match: /\i\?\.isStaff\(\)/,
102 replace: "true"
103 },
104 // Fix some tricky experiments name causing a client crash
105 {
106 match: /\.isStaffPersonal\(\).+?if\(null==(\i)\|\|null==\i(?=\)return null;)/,
107 replace: "$&||({})[$1]!=null"
108 }
109 ]
110 },
111 // Fix another function which cases crashes with tricky experiment names and the experiment embed
112 {
113 find: "}getServerAssignment(",
114 replacement: {
115 match: /}getServerAssignment\((\i),\i,\i\){/,
116 replace: "$&if($1==null)return;"
117 }
118 },
119
120 ],
121
122 start: () => ExperimentStore.getUserExperimentBucket("2026-01-bug-reporter") > 0 && enableStyle(hideBugReport),
123 stop: () => disableStyle(hideBugReport),
124
125 settingsAboutComponent: () => {
126 return (
127 <React.Fragment>
128 <Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
129 <Paragraph size="md">
130 You can open Discord&#039;s DevTools via {" "}
131 <div className={KbdStyles.combo} style={{ display: "inline-flex" }}>
132 <kbd className={KbdStyles.key}>{modKey}</kbd>{" "}
133 <kbd className={KbdStyles.key}>{altKey}</kbd>{" "}
134 <kbd className={KbdStyles.key}>O</kbd>{" "}
135 </div>
136 </Paragraph>
137 </React.Fragment>
138 );
139 },
140
141 WarningCard: ErrorBoundary.wrap(() => (
142 <ErrorCard id="vc-experiments-warning-card" className={Margins.bottom16}>
143 <Forms.FormTitle tag="h2">Hold on!!</Forms.FormTitle>
144
145 <Forms.FormText>
146 Experiments are unreleased Discord features. They might not work, or even break your client or get your account disabled.
147 </Forms.FormText>
148
149 <Forms.FormText className={Margins.top8}>
150 Only use experiments if you know what you&#039;re doing. {BRAND_NAME} is not responsible for any damage caused by enabling experiments.
151
152 If you don&#039;t know what an experiment does, ignore it. Do not ask us what experiments do either, we probably don&#039;t know.
153 </Forms.FormText>
154
155 <Forms.FormText className={Margins.top8}>
156 No, you cannot use server-side features like checking the "Send to Client" box.
157 </Forms.FormText>
158 </ErrorCard>
159 ), { noop: true })
160});
161