Skip to content

Instantly share code, notes, and snippets.

@v57
Created November 12, 2021 18:48
Show Gist options
  • Save v57/da4a84cf20ae66407fad660a0e9d458f to your computer and use it in GitHub Desktop.
Save v57/da4a84cf20ae66407fad660a0e9d458f to your computer and use it in GitHub Desktop.
Adding dark mode to MongoDB Compass on macOS
#!/bin/sh
# Make sure that you opened Compass once before running this script
# This script was tested in 1.29.0 version.
# Other versions may have different index.html location
# so i'll leave you easy access to path properties:
appPath=/Applications/MongoDB\ Compass.app/Contents/Resources
htmlPath=app/build
# Opening our compass directory
cd $appPath
echo Extracting
npx asar extract app.asar app
echo Backup
mv app.asar app.asar.backup
echo Downloading darkreader.js
cd $htmlPath
wget -q https://unpkg.com/[email protected]/darkreader.js
echo Adding code to automatically enable darkmode on startup
echo "DarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 })" >> darkreader.js
echo Enabling darkreader.js script in index.html
# Adding "<script src="darkreader.js" charset="UTF-8" async></script>" before </html>
sed 's/\(<\/html>\)/<script src="darkreader.js" charset="UTF-8" async><\/script>\1/g' index.html >> _index.html
mv _index.html index.html
echo Creating a new package
cd $appPath
npx asar pack app app.asar
echo Cleaning
rm -rf app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment