Skip to content

Instantly share code, notes, and snippets.

@Malix-off
Last active February 14, 2024 17:08
Show Gist options
  • Save Malix-off/e84f0085b3cd82b4ee98b1b72e4dac5c to your computer and use it in GitHub Desktop.
Save Malix-off/e84f0085b3cd82b4ee98b1b72e4dac5c to your computer and use it in GitHub Desktop.
Discord Desktop (Windows) Amoled Switching Tool
# GitHub Gists
*/
# Environment
*env*

Discord Desktop (Windows) Amoled Switching Tool

preview

If you want to keep this gist, you can star it;
Furthermore, if you want to keep it updated, you can subscribe to it.

Status (2023-12-26): ✅

Requirement

  • Desktop Windows OS (any version)
  • Discord Desktop (stable only, no support for PTB or canary as of now)

Features

  • Switch (with persistence) official theme of Discord desktop (windows) between original and amoled (midnight)

Instructions

  1. Download as ZIP
  2. Extract the directory
  3. Launch main.ps1 (no need to launch as administrator)
  4. Due to this program being "not commonly downloaded" Microsoft Defender SmartScreen will be triggered

Possible Enhancements

  • Support for other discord desktop plans
  • Restart Discord process after it being killed (didn't succeed to implement currently because of a weird behavior causing the discord process to be a child of main.ps1 (exiting it would also exit discord))

Stop of Support

Reason

I think the future of all electron apps (hence also Discord) are in PWAs. I started using discord as a browser shortcut as a new window until Discord comes up with an official PWA The only downside is that there is no global shortcuts (see https://issues.chromium.org/issues/40749250). If you want to use mods, I recommend using Vencord Web

Redirection

Links

module.exports = require('./core.asar');
const { BrowserWindow } = require('electron')
setTimeout(() => {
const windows = BrowserWindow.getAllWindows();
windows.forEach(e => e.webContents.executeJavaScript(`document.body.classList.add("theme-midnight");`))
}, 4000)
module.exports = require('./core.asar');
# PowerShell Script for Discord Desktop Windows Amoled
# Find the correct Discord directory
$discordDirectory = Get-Item -Path "$env:LocalAppData\Discord\app-*" | Where-Object { $_.PSIsContainer }
# Find the correct discord_desktop_core directory
$discordCoreDirectory = Get-Item -Path "$($discordDirectory.FullName)\modules\discord_desktop_core-*" | Where-Object { $_.PSIsContainer }
# Define the file path
$fileTarget = Join-Path -Path $discordCoreDirectory.FullName -ChildPath 'discord_desktop_core\index.js'
function Add-Newline {
Write-Host ""
}
# Display menu
do {
Clear-Host
Write-Host "Discord Desktop Windows Amoled"
Add-Newline
Write-Host "Choose an option:"
Add-Newline
Write-Host "1. Original Theme"
Write-Host "2. Amoled Theme"
Add-Newline
$choice = Read-Host "Enter your choice"
Add-Newline
if ($choice -eq "1") {
Write-Host "Applying Original"
$fileSource = "fileOriginal.js"
}
elseif ($choice -eq "2") {
Write-Host "Applying Amoled"
$fileSource = "fileAmoled.js"
}
else {
Write-Host "Invalid choice."
Pause
}
} while ($choice -ne "1" -and $choice -ne "2")
# Remove read-only to allow overwriting
Set-ItemProperty -Path $fileTarget -Name IsReadOnly -Value $false
# Overwrite the file
Copy-Item -Path $fileSource -Destination $fileTarget -Force
# Add back read-only to prevent Discord from breaking the file
Set-ItemProperty -Path $fileTarget -Name IsReadOnly -Value $true
# Display confirmation
Write-Host "Changes Applied."
Add-Newline
# Check if Discord is running and offer to kill the process
$discordProcess = Get-Process -Name "Discord" -ErrorAction SilentlyContinue
if ($discordProcess) {
Write-Host "Killing Discord Process"
Stop-Process -Name "Discord" -Force
Write-Host "Discord Process Killed"
Add-Newline
}
# Done
Write-Host "Done."
Add-Newline
Pause
@R-Rajaneesh
Copy link

R-Rajaneesh commented Oct 2, 2023

Just open dev tools and paste

document.body.classList.add("theme-midnight");

@Malix-off
Copy link
Author

Just open dev tools and paste

document.body.classList.add("theme-amoled");

This solution is not persistent.

@Malix-off
Copy link
Author

className changed from "theme-amoled" to "theme-midnight"

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