Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ Win
code %appdata%/discord/settings.json
```

Linux
Linux (Deb)

```sh
code ~/.config/discord/settings.json
```

Linux (Flatpak)

```sh
code ~/.var/app/com.discordapp.Discord/config/discord/settings.json
```

macOS

```sh
Expand Down
51 changes: 44 additions & 7 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
#!/usr/bin/env zx

async function findAndPatchLinuxConfig() {
const debPath = `${os.homedir()}/.config/discord/settings.json`;
const flatpakPath = `${os.homedir()}/.var/app/com.discordapp.Discord/config/discord/settings.json`;

const pathsToTry = [debPath, flatpakPath];

for (const configFile of pathsToTry) {
try {
const config = await fs.readJson(configFile);

config.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
await fs.writeJson(configFile, config, { spaces: 2 });
console.log(chalk.black.bgGreen(" DEVTOOLS ENABLED "), configFile);

return true;
} catch (error) {}
}

return false;
}

const osPaths = {
// tested os.platform() values
darwin: `${os.homedir()}/Library/Application Support/discord/settings.json`,
win32: `${os.homedir()}/AppData/Roaming/discord/settings.json`,
linux: `${os.homedir()}/.config/discord/settings.json`,
// https://nodejs.org/api/process.html#process_process_platform
// not fully tested os.platform() values
// if one of these is your platform and the script doesn't work, please open an issue
Expand All @@ -15,13 +35,30 @@ const osPaths = {
android: `/data/data/com.discord/files/discord/settings.json`, // typical Android path
};

const configFile = osPaths[os.platform()];

try {
const config = await fs.readJson(configFile);
config.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
await fs.writeJson(configFile, config, { spaces: 2 });
console.log(chalk.black.bgGreen(' DEVTOOLS ENABLED '), configFile);
let success = false;

if (os.platform() === "linux") {
success = await findAndPatchLinuxConfig();

if (!success) {
throw new Error(
"Could not find settings.json for standard or Flatpak install."
);
}
} else {
const configFile = osPaths[os.platform()];
if (!configFile) {
throw new Error(
`Platform ${os.platform()} is not supported by this modified script.`
);
}

const config = await fs.readJson(configFile);
config.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
await fs.writeJson(configFile, config, { spaces: 2 });
console.log(chalk.black.bgGreen(" DEVTOOLS ENABLED "), configFile);
}
} catch (error) {
console.error(chalk.red('Error:'), error);
console.log(chalk.yellow('Debug Info:'), {
Expand Down